FORUMCatégorie: BioinformaticsFiltering bam files using samtools
ramaniak personnel demandée il y a 3 ans

How do I filter by bam file using samtools (only mapped reads, only unmapped reads, subset a bam file)?

1 Réponses
Best Answer
jflucier personnel répondue il y a 3 ans

To filter bam files using samtool you need to call samtools view with the appropriate hex flag. To get output in bam format, you need to use the -b flag. To retreive all mapped read use this command
samtools view -b -F 4 file.bam > mapped.bam
to get unmapped: samtools view -b -f 4 file.bam > unmapped.bam
To know what sam flags to pass to the -f option, i found this utility quite usefull: