minimap2 icon indicating copy to clipboard operation
minimap2 copied to clipboard

possibility of removing secondary alignments that are actually supplementary (chimera)?

Open xinehc opened this issue 1 year ago • 1 comments

Hi,

I noticed that if the primary alignment is chimeric (multiple tp:A:P tags) and say one or multiple pieces of the alignment has a low alignment score (ms or AS tag), then many secondary alignments also have an extremely low alignment score (possibly all chimera? I guess this is a feature of -p?).

Using samtools view -F0x800 it is possible to remove all chimeras of the primary alignment but these low-score secondary alignments retain. I wonder is there a way to remove these secondary alignments or know which of them are not the "primary" ones?

My command:

minimap2 -ax map-ont --sam-hit-only rps.mmi $filename.fasta -N 1000 -t 64 > $filename.sam

Thanks!

xinehc avatar Apr 12 '23 09:04 xinehc

After some digging I saw by default the sam file is sorted like (for a single query sequence):

line 1 -- primary 1
line 2 -- secondary 1 of primary 1
line 3 -- secondary 2 of primary 1
...
line 3+n -- supplementary 1 of primary 1
line 3+n+1 -- secondary 1 of supplementary 1
line 3+n+2 -- secondary 2 of supplementary 1
...
line 3+n+m -- supplementary 2 of primary 1
line 3+n+m+1 -- secondary 1 of supplementary 2
line 3+n+m+2 -- secondary 2 of supplementary 2

Would it be a safe way to remove all supplementary plus secondary of these supplementary by discarding all lines after 3+n-1?

Thanks, Xi

xinehc avatar Apr 12 '23 11:04 xinehc