Changing chromosome names in BAM files
1
0
Entering edit mode
18 months ago
aodabas20 • 0

Hi all,

I have ATAC-seq datas and I am trying to find TF binding motifs. I trimmed adapters(trim-galore), aligned to genome(with bowtie2), converted sam files to bam files and filtered them (according to mapping quality, duplicates and mitocondrial reads). Then, I wanted to look at my bam files. These are the results of "samtools idxstats"![enter image description here][1] command

chr1_KI270892v1_alt 162212 308 0

chr2_KI270894v1_alt 214158 1585 0

chr3_KI270895v1_alt 162896 540 0

chr6_GL000251v2_alt 4795265 10343 0

chr7_KI270899v1_alt 190869 942 0

I want to change those chromosome names with short names. Like this chr1_KI270892v1_alt -> chr1

How can I change all this names with short ones?

ChIP-Seq RNA-Seq alignment • 376 views
ADD COMMENT
1
Entering edit mode

I want to change those chromosome names with short names. Like this chr1_KI270892v1_alt -> chr1

uh ? why would you want to do that ?

ADD REPLY
0
Entering edit mode

Because I have found a tool that can find TF activities between 2 conditions.But ıt only accepts chr1,chr2 ... format.

ADD REPLY
1
Entering edit mode

I am not sure how it uses chromosome names, but chr1_KI270892v1_alt is not the same thing as chr1. It would make as much sense to rename that as it would chr2 to chr1. While technically possible, it is not very meaningful.

You probably should use samtools (or another tool) to filter for just the relevant chromosomes.

ADD REPLY
0
Entering edit mode
18 months ago

I think the key point in doing this is this:

When you eyeball a .sam file, you see the chromosome name in each row But I think in bam format, the chromosome name is not actually stored in every row, it's only stored in the header, and when you make a sam file, it gets the chromosome name from the header.

So I believe changing the header properly is all you have to do.

However, for reproducibility, it might be best to make a reference with the names you want, and re-align. Lest some day, someone wonder why your chromosomes don't match what you supposedly aligned to.

ADD COMMENT
0
Entering edit mode

How can I change the header in sam files?

İ thougt there are some scripts that allow us to change chromosome names as we want

ADD REPLY
1
Entering edit mode

Look into samtools reheader option that can be used for this purpose. @Igor makes a good point above.

ADD REPLY

Login before adding your answer.

Traffic: 875 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6