Hello everyone! How are you all doing? I hope all is well with you! 
I'm having a difficult time indexing my sorted bam files. I would like to use IGV to visualize my bam file. I used samtools to sort and index the bam file. Here's my code:
samtools sort -n <path of .bam file> <sorted .bam file>
samtools index <sorted .bam file>
But then I get this message:
[bam_index_core] the alignment is not sorted .....
[bam_index_build2] fail to index the BAM file.
So I tried to re-sort the bam file based on coordinates instead of gene name:
samtools sort <path of .bam file> <sorted .bam file>
samtools index <sorted .bam file>
This time I didn't have a problem with indexing but when I loaded my bam file (both sorted and unsorted), I couldn't visualize my reads. I can really use someone's help here.

I'm having a difficult time indexing my sorted bam files. I would like to use IGV to visualize my bam file. I used samtools to sort and index the bam file. Here's my code:
samtools sort -n <path of .bam file> <sorted .bam file>
samtools index <sorted .bam file>
But then I get this message:
[bam_index_core] the alignment is not sorted .....
[bam_index_build2] fail to index the BAM file.
So I tried to re-sort the bam file based on coordinates instead of gene name:
samtools sort <path of .bam file> <sorted .bam file>
samtools index <sorted .bam file>
This time I didn't have a problem with indexing but when I loaded my bam file (both sorted and unsorted), I couldn't visualize my reads. I can really use someone's help here.

Comment