samtools index error
Hello everyone
I am trying to extract uniquely aligned reads and sort them with samtools with the following command
samtools view -h -f 2 -q 10 -bS -@ 20 hg38.sam | samtools sort -n -@ 1 > hg38.sort.bam
after this when I try to index the output file
samtools index hg38.sort.bam
I get this error message
[E::hts_idx_push] Unsorted positions on sequence #16: 73874275 followed by 73874203
[E::sam_index] Read 'SRR10984462.26' with ref_name='chr16', ref_length=90338345, flags=163, pos=73874203 cannot be indexed
samtools index: failed to create index for "hg38.sort.bam": No such file or directory
any suggestions ?
• 1,940 views
•
link
1 answer
option -n of samtools sort is for sorting on read name, not on coordinate. Remove this this.option.
• 0 views
•
link
Log in to answer this question.