DaehwanKimLab / hisat2

Graph-based alignment (Hierarchical Graph FM index)
GNU General Public License v3.0
464 stars 112 forks source link

Extract reads aligned concordantly exactly 1 time from hisat2 output (.sam file) #358

Open poecile-palustris opened 2 years ago

poecile-palustris commented 2 years ago

Good morning,

I obtained .sam file after running hisat2 -x indexed -1 R1.fastq.gz -2 R2.fastq.gz -S hisat2_map.sam.I would like to filter this file so that only the reads that are aligned concordantly (1) exactly 1 time (2)* remain.

Could you help me with this please? Thank you very much in advance!

*I mean ... reads; of these: ... (...%) were paired; of these: ... (...%) aligned concordantly 0 times ... (...%) aligned concordantly exactly 1 time - these reads ... (...%) aligned concordantly >1 times

Edit: It seems I need to use such a command samtools view -hf 0x2 -q 3 hisat2_map.bam, where -f 0x2- save properly paired alignments, -q 3- skip alignments with MAPQ smaller than 3, because

60 - uniquely mapped read, regardless of number of mismatches / indels (which I need) 1 - multiply mapped, perfect match or few mismatches / indels 0 - unmapped, or multiply mapped and with lots of mismatches / indels

Is it true? Thanks a lot!

Best regards, Poecile