I'm trying to extract all supplementary alignments (specifically, reads that are split and aligned to different regions of the genome) from a bam file generated by mapping Oxford Nanopore reads to a reference genome with minimap2. I'm trying to extract these alignments using the following samtools (v1.15.1) command:
samtools view -f 2048 -o ${supp_align_bam} ${my_bam}
The above command outputs the correct number of alignments as indicated when I run the samtools stats
command. However, there are many reads in the resulting bam file that only occur once. I thought that supplementary alignments are split alignments and therefore each read should be represented at least twice? I need to have all aligned parts of each 'split read'. My worry is that the -f 2048
filter does not include the best aligning region of the split reads (which would explain a read name occurring only once in this file). Any advice on what is occurring would be greatly appreciated!
with samtools view -f 2048 , you 'll only get suppl read (only one if there is only one split), BUT the primary/main alignment is lost, you can always later find reads by name.