~ubuntu-branches/ubuntu/wily/r-bioc-genomicranges/wily-proposed

« back to all changes in this revision

Viewing changes to man/GAlignmentsList-class.Rd

  • Committer: Package Import Robot
  • Author(s): Andreas Tille
  • Date: 2013-11-26 19:52:13 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20131126195213-1zwbthnie0a7fdns
Tags: 1.14.3-1
* New upstream version
  Closes: #730574
* Build-Depends: r-bioc-xvector

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
\alias{coerce,GAlignmentsList,GRanges-method}
39
39
\alias{coerce,GAlignmentsList,RangesList-method}
40
40
\alias{coerce,GAlignmentsList,Ranges-method}
 
41
\alias{coerce,GAlignmentPairs,GAlignmentsList-method}
41
42
\alias{grglist,GAlignmentsList-method}
42
43
\alias{granges,GAlignmentsList-method}
43
44
\alias{rglist,GAlignmentsList-method}
44
45
\alias{ranges,GAlignmentsList-method}
45
46
\alias{introns,GAlignmentsList-method}
46
47
 
47
 
% Subsetting:
48
 
\alias{[,GAlignmentsList-method}
49
 
\alias{[<-,GAlignmentsList,ANY,ANY,ANY-method}
50
 
\alias{[[<-,GAlignmentsList-method}
51
 
\alias{[[<-,GAlignmentsList,ANY,ANY-method}
52
 
 
53
48
% Combining:
54
49
\alias{c,GAlignmentsList-method}
55
50
 
63
58
 
64
59
\description{
65
60
  The GAlignmentsList class is a container for storing a collection of
66
 
  GappedAlignments objects.
 
61
  \link{GAlignments} objects.
67
62
}
68
63
 
69
64
\details{
70
 
  A GAlignmentsList object contains a list of GappedAlignments. The
71
 
  majority of operations on this page are described in more detail
72
 
  on the GappedAlignments man page, see ?\code{GappedAlignments}.
 
65
  A GAlignmentsList object contains a list of \link{GAlignments} objects.
 
66
  The majority of operations on this page are described in more detail
 
67
  on the GAlignments man page, see ?\code{GAlignments}.
73
68
74
69
 
75
70
\section{Constructors}{
76
71
  \describe{
77
72
    \item{}{
78
73
      \code{GAlignmentsList(...)}:
79
 
      Creates a GAlignmentsList from a list of GappedAlignments objects.
 
74
      Creates a GAlignmentsList from a list of \link{GAlignments} objects.
80
75
    }
81
76
    \item{}{
82
77
      \code{readGAlignmentsList(file, format="BAM", use.names=FALSE, ...)}:
83
78
      Read a file containing aligned reads as a GAlignmentsList object.
84
79
      Note that this function is just a front-end that delegates to the
85
 
      \code{\link[Rsamtools]{readBamGAlignmentsList}} function defined
 
80
      \code{\link[Rsamtools]{readGAlignmentsListFromBam}} function defined
86
81
      in the Rsamtools package. 
87
 
      See \code{?\link[Rsamtools]{readBamGAlignmentsList}} for
 
82
      See \code{?\link[Rsamtools]{readGAlignmentsListFromBam}} for
88
83
      more information.
89
84
 
90
 
      The \code{param} and \code{asProperPairs} arguments described on the
91
 
      \code{\link[Rsamtools]{readBamGAlignmentsList}} man page fine tune the 
92
 
      records are returned. \code{param} is specifed by the standard
93
 
      \code{ScanBamParam()} options. When \code{asProperPairs=TRUE} (default), 
94
 
      only the proper pairs are returned. This is the same QC filtering that 
95
 
      is done by \code{readBamGappedAlignmentPairs} but the records are
96
 
      returned in a \code{GAlignmentsList} instead of
97
 
      \code{GappedAlignmentsPairs} object. If \code{asProperPairs=FALSE}, all 
98
 
      records in the file are retained (i.e., no QC) and the list structure is 
99
 
      split by read id (QNAME in SAM/BAM). This format allows the flexibility 
100
 
      to retain singletons, pairs, and multi-fragment reads in a single class. 
 
85
      The \code{param} described on the
 
86
      \code{\link[Rsamtools]{readGAlignmentsListFromBam}} man page fine tunes
 
87
      which records are returned and how they are grouped. \code{param} is
 
88
      specified by the standard \code{ScanBamParam()} options.
101
89
    }
102
90
 
103
91
    \item{}{
216
204
      the cigar information. The resulting ranges span the entire
217
205
      range, including any gaps or spaces between paired-end reads.
218
206
 
219
 
      The \code{granges} coercion supports \code{ignore.strand} to
220
 
      allow ranges of opposite strand to be combined (see examples).
 
207
      \code{granges} coercion supports \code{ignore.strand} to allow 
 
208
      ranges of opposite strand to be combined (see examples). All
 
209
      ranges in the resulting GRanges will have strand \sQuote{*}.
221
210
    }
222
211
    \item{}{
223
 
      \code{grglist(x)}, 
 
212
      \code{grglist(x, ignore.strand=FALSE)}, 
224
213
      \code{rglist(x)}:
225
214
      Return either a \link{GRangesList} or a \link[IRanges]{IRangesList}
226
215
      object of length \code{length(x)}. This coercion RESPECTS the cigar 
227
216
      information. The resulting ranges are fragments of the original ranges 
228
 
      that do not include gaps or spaces between paired-end reads. 
 
217
      that do not include gaps or spaces between paired-end reads.
 
218
 
 
219
      \code{grglist} coercion supports \code{ignore.strand} to allow 
 
220
      ranges of opposite strand to be combined (see examples). All 
 
221
      ranges in the resulting GRangesList will have strand \sQuote{*}.
229
222
    }
230
223
    \item{}{
231
224
      \code{as(x, "GRangesList")}, \code{as(x, "GRanges")},
233
226
      Alternate ways of doing \code{grglist(x)}, \code{granges(x)},
234
227
      \code{rglist(x)}, \code{ranges(x)}, respectively.
235
228
    }
 
229
    \item{}{
 
230
      \code{as(x, "GALignmentsList")}: Return a \link{GAlignmentsList} object of 
 
231
      length \code{length(x)} where the i-th list element represents the ranges 
 
232
      of the i-th alignment pair in \code{x}.
 
233
    }
236
234
  }
237
235
}
238
236
 
243
241
    \item{}{
244
242
      \code{x[i]}, \code{x[i] <- value}:
245
243
      Get or set list elements \code{i}. \code{i} can be a numeric 
246
 
      or logical vector. \code{value} must be a GappedAlignments.
 
244
      or logical vector. \code{value} must be a GAlignments.
247
245
    }
248
246
    \item{}{
249
247
      \code{x[[i]]}, \code{x[[i]] <- value}:
253
251
      \code{x[i, j]}, \code{x[i, j] <- value}:
254
252
      Get or set list elements \code{i} with optional metadata columns
255
253
      \code{j}. \code{i} can be a numeric, logical or missing. 
256
 
      \code{value} must be a GappedAlignments.
 
254
      \code{value} must be a GAlignments.
257
255
    }
258
256
  }
259
257
}
292
290
 
293
291
\seealso{
294
292
  \itemize{
295
 
    \item \link{GappedAlignments-class}.
296
 
    \item \link{GappedAlignmentPairs-class}.
297
 
    \item \code{\link[Rsamtools]{readBamGappedAlignments}}.
298
 
    \item \code{\link[Rsamtools]{readBamGappedAlignmentPairs}}.
 
293
    \item \link{GAlignments-class}.
 
294
    \item \link{GAlignmentPairs-class}.
 
295
    \item \code{\link[Rsamtools]{readGAlignmentsFromBam}}.
 
296
    \item \code{\link[Rsamtools]{readGAlignmentPairsFromBam}}.
299
297
    \item \link{findOverlaps-methods}.
300
298
  }
301
299
}
302
300
 
303
301
\examples{
304
 
gal1 <- GappedAlignments(
 
302
gal1 <- GAlignments(
305
303
    seqnames=Rle(factor(c("chr1", "chr2", "chr1", "chr3")),
306
304
        c(1, 3, 2, 4)),
307
305
    pos=1:10, cigar=paste0(10:1, "M"),
308
306
    strand=Rle(strand(c("-", "+", "*", "+", "-")), c(1, 2, 2, 3, 2)),
309
307
    names=head(letters, 10), score=1:10)
310
308
 
311
 
gal2 <- GappedAlignments(
 
309
gal2 <- GAlignments(
312
310
    seqnames=Rle(factor(c("chr2", "chr4")), c(3, 4)), pos=1:7,
313
311
    cigar=c("5M", "3M2N3M2N3M", "5M", "10M", "5M1N4M", "8M2N1M", "5M"),
314
312
    strand=Rle(strand(c("-", "+")), c(4, 3)),
349
347
galist[gaps]
350
348
 
351
349
## Different ways to subset:
352
 
galist[2]             # a GappedAlignments object of length 1
353
 
galist[[2]]           # a GappedAlignments object of length 1
 
350
galist[2]             # a GAlignments object of length 1
 
351
galist[[2]]           # a GAlignments object of length 1
354
352
grglist(galist[2])  # a GRangesList object of length 1
355
353
rglist(galist[2])   # a NormalIRangesList object of length 1
356
354
 
358
356
## C. mcols()/elementMetadata()
359
357
## ---------------------------------------------------------------------
360
358
 
361
 
## Metadata can be defined on the individual GappedAlignment elements
 
359
## Metadata can be defined on the individual GAlignment elements
362
360
## and the overall GAlignmentsList object. By default, 'level=between' 
363
361
## extracts the GALignmentsList metadata. Using 'level=within' 
364
 
## will extract the metadata on the individual GappedAliginments.
 
362
## will extract the metadata on the individual GAlignments objects.
365
363
 
366
364
mcols(galist) ## no metadata on the GAlignmentsList object
367
365
mcols(galist, level="within")
368
366
 
369
367
 
370
368
## ---------------------------------------------------------------------
371
 
## D. readBamGAlignmentsList() 
 
369
## D. readGAlignmentsListFromBam()
372
370
## ---------------------------------------------------------------------
373
371
 
 
372
library(Rsamtools)
374
373
library(pasillaBamSubset)
375
 
library(Rsamtools)
376
 
fl <- sortBam(untreated3_chr4(), tempfile(), byQname=TRUE)
377
 
bf <- BamFile(fl, index=character(0), yieldSize=50, obeyQname=TRUE)
378
 
galist <- readGAlignmentsList(bf, asProperPairs=FALSE)
379
 
galist
 
374
 
 
375
## 'file' as character.
 
376
fl <- untreated3_chr4()
 
377
galist1 <- readGAlignmentsList(fl)
 
378
 
 
379
galist1[1:3]
 
380
length(galist1)
 
381
table(elementLengths(galist1))
 
382
 
 
383
## When 'file' is a BamFile, 'asMates' must be TRUE. If FALSE,
 
384
## the data are treated as single-end and each list element of the
 
385
## GAlignmentsList will be of length 1. For single-end data 
 
386
## use readGAlignments() instead of readGAlignmentsList().
 
387
bf <- BamFile(fl, yieldSize=3, asMates=TRUE)
 
388
readGAlignmentsList(bf)
 
389
 
 
390
## Use a 'param' to fine tune the results.
 
391
param <- ScanBamParam(flag=scanBamFlag(isProperPair=TRUE))
 
392
galist2 <- readGAlignmentsList(fl, param=param)
 
393
length(galist2)
 
394
 
380
395
 
381
396
## ---------------------------------------------------------------------
382
397
## E. COERCION 
383
398
## ---------------------------------------------------------------------
384
399
 
385
 
## The granges() coercion supports 'ignore.strand' to allow ranges
386
 
## from different strand to be combined. In this example paired-end
387
 
## reads aligned to opposite strands were read into a GAlignmentsList. 
388
 
## If the desired operation is to combine these ranges, reguardless of 
389
 
## gaps or the space between pairs, 'ignore.strand' must be TRUE.
 
400
## The granges() and grlist() coercions support 'ignore.strand' to 
 
401
## allow ranges from different strand to be combined. In this example 
 
402
## paired-end reads aligned to opposite strands were read into a 
 
403
## GAlignmentsList. If the desired operation is to combine these ranges, 
 
404
## reguardless of gaps or the space between pairs, 'ignore.strand' must be TRUE.
 
405
granges(galist[1])
390
406
granges(galist[1], ignore.strand=TRUE)
391
 
granges(galist[1], ignore.strand=FALSE)
392
407
 
393
 
## grglist() splits ranges by gap and the space bein each list element
 
408
## grglist() splits ranges by gap and the space between list elements.
394
409
galist <- GAlignmentsList(noGaps=gal1, Gaps=gal2)
395
410
grglist(galist)
 
411
grglist(galist, ignore.strand=TRUE)
396
412
}
397
413
 
398
414
\keyword{methods}