<p>I have a bam file that I would like sorted karyotypically (not lexicographically) but my contigs are not matching the reference file provided by GATK. Getting the reference file that was originally used for alignment and realigning my sample are unavailable options.</p>

<p>My reference uses &quot;1,2,3,...,X,Y,MT&quot; notation but my bam file uses &quot;chr1,chr2,chr3,...chrX,chrY,chrM&quot; notation. Is there a way to remove the chr prefix and change chrM to MT in my bam file? Can I get by with just revising the header only without messing with the reads in the bam file? Thank you for your help!</p>

If all your bams are this way, it's probably easier to change your reference to match the bams. (That's just changing a few lines of a fasta and rebuilding an index or two).

If you do end up needing to reformat your bams, there is good advice in previous threads:

 - https://www.biostars.org/p/119295/
 - https://www.biostars.org/p/13462/