Subset bam file in R
1
0
Entering edit mode
ferbecneu • 0
@ferbecneu-16188
Last seen 3.6 years ago

Hi, I want to subset alignments in chromosome 7 from a BAM file and write a new BAM of only chr7 alignments.

I made this:

seq3<-"HF6_1_1fragmm9.bam"
seq3reads<-readGAlignments(seq3)
seq3chr7 <- seq3reads[seqnames(seq3reads) == 'chr7']

But I dont know how can I export seq3chr7 as a BAM file, can it be done?

Thank you very much!

rsamtools genomicalignments genomicranges • 1.2k views
ADD COMMENT
0
Entering edit mode
@michael-lawrence-3846
Last seen 2.4 years ago
United States

You could use the rtracklayer export() function. But I think you really want Rsamtools::filterBam() in this case.

ADD COMMENT

Login before adding your answer.

Traffic: 489 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6