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}
48
\alias{[,GAlignmentsList-method}
49
\alias{[<-,GAlignmentsList,ANY,ANY,ANY-method}
50
\alias{[[<-,GAlignmentsList-method}
51
\alias{[[<-,GAlignmentsList,ANY,ANY-method}
54
49
\alias{c,GAlignmentsList-method}
65
60
The GAlignmentsList class is a container for storing a collection of
66
GappedAlignments objects.
61
\link{GAlignments} objects.
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}.
75
70
\section{Constructors}{
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.
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
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.
216
204
the cigar information. The resulting ranges span the entire
217
205
range, including any gaps or spaces between paired-end reads.
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{*}.
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.
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{*}.
231
224
\code{as(x, "GRangesList")}, \code{as(x, "GRanges")},
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}.
304
gal1 <- GappedAlignments(
305
303
seqnames=Rle(factor(c("chr1", "chr2", "chr1", "chr3")),
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)
311
gal2 <- GappedAlignments(
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)),
358
356
## C. mcols()/elementMetadata()
359
357
## ---------------------------------------------------------------------
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.
366
364
mcols(galist) ## no metadata on the GAlignmentsList object
367
365
mcols(galist, level="within")
370
368
## ---------------------------------------------------------------------
371
## D. readBamGAlignmentsList()
369
## D. readGAlignmentsListFromBam()
372
370
## ---------------------------------------------------------------------
374
373
library(pasillaBamSubset)
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)
375
## 'file' as character.
376
fl <- untreated3_chr4()
377
galist1 <- readGAlignmentsList(fl)
381
table(elementLengths(galist1))
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)
390
## Use a 'param' to fine tune the results.
391
param <- ScanBamParam(flag=scanBamFlag(isProperPair=TRUE))
392
galist2 <- readGAlignmentsList(fl, param=param)
381
396
## ---------------------------------------------------------------------
383
398
## ---------------------------------------------------------------------
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.
390
406
granges(galist[1], ignore.strand=TRUE)
391
granges(galist[1], ignore.strand=FALSE)
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)
411
grglist(galist, ignore.strand=TRUE)
398
414
\keyword{methods}