Closed Timothy-WANG closed 5 years ago
Please ask questions like this on the Bioconductor support site https://support.bioconductor.org
If you'd like to query the bam file for those reads, importing them into R, use GenomicAlignments::readGAlignments()
or readGAlignmentPairs()
or readGAlignmentList()
.
Restrict the reads input using the argument param =
with ScanBamParam(which = GRanges("chrX:1-xxx"))
, where xxx
is the length of the X chromosome, e.g., as(seqinfo(BamFile("test.chrX.bam")), "GRanges")["chrX"]
If you'd like to filter a large bam file to a small bam file (but this is not usually necessary or desirable) use Rsamtools::filterBam()
with a similar param=
argument.
I'll close this issue here, anticipating any follow-up questions on the support site.
Previously, in linux shell, I could extract the reads mapping to chrX like this:
$ samtools view -h -b test.bam chrX -o test.chrX.bam
How to I get the same result in R using Rsamtools, any one knows?
Thanks