Question: How to get chrM chr1 ...chr22 chrX chrY order in my bam file
0
gravatar for Ada
16 months ago by
Ada0
Ada0 wrote:

Hi

I went BWA alignment and sorted my bam file when I was doing my WES analysis to find SNP and Indel, however, my bam file look like this: chr1 ... chr22 chrX chrY chrM, now I want get my bam file : chrM chr1 ...chr22 chrX chrY ,what should I do?

Thank you

sort bam snp picard gatk • 432 views
ADD COMMENTlink modified 16 months ago by jkbonfield490 • written 16 months ago by Ada0
1

I think you should go for variant calling and then sort the resulted vcf file as per your liking..!!

ADD REPLYlink written 16 months ago by hafiz.talhamalik290
1

Why would you do that? Which larger problem are you trying to solve by changing the order of chromosomes in your bam file?

ADD REPLYlink written 16 months ago by WouterDeCoster45k

I need to do variant calling with GATK and GATK may give incorrect results if the order of my bam file is chr1 ... chr22 chrX chrY chrM

ADD REPLYlink modified 16 months ago • written 16 months ago by Ada0
2

No it wouldn't. What makes you think that?

ADD REPLYlink written 16 months ago by WouterDeCoster45k

cause I found that someone else had a bam file with the order of chrM, chr1, chr2, ... ,chrX, chrY and he mentioned it's very important. I will check it again and find the original information about the order of bam files.

ADD REPLYlink written 16 months ago by Ada0

I found it. These are defined by historical karotyping of largest to smallest chromosomes, followed by the X, Y, and MT for the b3x references; the order is thus 1, 2, 3, ..., 10, 11, 12, ... 20, 21, 22, X, Y, MT. The hg1x references differ in that the chromosome names are prefixed with "chr" and chrM appears first instead of last hg

ADD REPLYlink written 16 months ago by Ada0
1
gravatar for jkbonfield
16 months ago by
jkbonfield490
jkbonfield490 wrote:

I don't agree that it is necessary to have your chromosome names in any particular order, but if you absolutely must do this the only way I can think of it is convert to SAM format (not BAM), replace the header with a reordered one, convert back to BAM again and re-sort to get the alignments in the same order as the header. Some of these steps can be amalgamated. You cannot replace the header while in BAM format as internally BAM stored chromosome by the Nth SQ number in the header, thus it would simply migrate alignments to the wrong chromosomes.

That's all very messy, and IMO pointless, but something like this (untested) ought to work:

(cat new_header; samtools view in.bam) | samtools sort -o out.bam -
ADD COMMENTlink written 16 months ago by jkbonfield490

Thanks a lot, I'll give it a shot.

ADD REPLYlink written 16 months ago by Ada0
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 2014 users visited in the last hour
_