This post is useful for removing specific chromosomes from a BAM: Remove mitochondrial reads from BAM files -Remove mitochondrial reads from BAM files
So I have metagenome bam files which contain reads for both human and bacteria. I would like to remove all the human reads so I can focus on the bacterial reads. Has anyone been able to remove human reads from their RNA-seq data using samtools or any other software?
2 answers
Align your reads to the human genome first, then extract all the unmapped reads to work with further. The unmapped reads will have all your bacteria (as well as other non-human things). Extracting unmapped paired end from an alignment - C: Extracting unmapped paired end from an alignment
Agree with @WouterDeCoster, BBSplit can be used, although it is very slow. Here is an example of it Tool to separate human and mouse rna seq reads from one of my posts.
You can probably use seal.sh from BBmap itself which is very fast. The example of Seal.sh is in the above link.
Log in to answer this question.
You have it in a bam file, meaning it's already aligned? To what?
It was aligned to a metagenome database for human and bacteria.