Entering edit mode
Marcus Davy
▴
390
@marcus-davy-5153
Last seen 6.6 years ago
Hi,
I would like to export certain reads filtered using Rsamtools, for
example
aligning against contaminant references
to exclude a set of sequences filtering on the bitwise flag=0x4
(similar to
SamToFastq.jar in the picard http://picard.sourceforge.net/ tools),
but couldn't find much on exporting/writing to file in the
Rsamtools-Overview.pdf vignette or on google.
Is there a function/utility which converts an Rsamtools bam list
region to
ShortReadQ object(s) for export using writeFastq()
with single end *and* paired end alignments which have been read in
via the
Rsamtools interface?
## Load a bam
bam <- scanBam(...)
## Filter using R's subsetting,
bamRegion <- bam[[1]][ ... ] ## list of list
## Should work for single end alignments, but not paired end
alignments
## Read pairs may have to index on mpos = PNEXT field
rfq <- ShortReadQ(bamRegion[["seq"]], bamRegion[["qual"]],
BStringSet(bamRegion[["qname"]]))
If not is the area of exporting from Rsamtools worth developing
futher?
cheers,
Marcus
[[alternative HTML version deleted]]