This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to delect lines from BAM? using manual input index

I have 2 BAMs of the some reads, but mapped to different genome. I extracted MAPQ from both, and get some index which correspond to reads that have the same MAPQ in both BAMs (using R). Then I can export those index in txt format.

Now how do I use the index found, for example, 2,3,4,5,8,9, to subset one of the BAM file?

The real problem is a bit more complex, as there are more than 2 BAMs, and I need to summarize the MAPQ across them.

Many thanks!

bam

1 answer

Found a solution here (https://bioinformatics.stackexchange.com/questions/3380/how-to-subset-a-bam-by-a-list-of-qnames): samtools view file.bam | grep -f 'qnames.txt > subset.sam

The frustrated thing is, it seems that after filtering the BAM, in 10X, you have to convert it back to fastq then rerun the analysis.

Log in to answer this question.