Convert a BAM from GRCh37 to hg19?
1
0
Entering edit mode
5 weeks ago

Hello!

I was about to re-run the mapping step to create BAM files with hg19 coordinates, but realised that perhaps it's easier to convert the existing GRCh37 BAM files to hg19 coordinates, without having to re-run the aligner completely.

I looked around for ways to do this but only find methods for creating chain files e.g. hg19-h38.

I would greatly appreciate some help with this. :-]

Joel

GRCh37 hg19 BAM • 648 views
1
Entering edit mode

GRCh37 is hg19. hg19 is simply a synonym.

Edit: I should add that the major genome build is identical. There are specific differences in some components noted in my comment below.

0
Entering edit mode

I was under the impression that chrM was actually different between the two?

1
Entering edit mode

While major genome builds are identical there are specific differences in non-chromosomal members: https://gatk.broadinstitute.org/hc/en-us/articles/360035890711-GRCh37-hg19-b37-humanG1Kv37-Human-Reference-Discrepancies

There is a comparison table.

0
Entering edit mode
2
Entering edit mode
5 weeks ago

I ended up using samtools reheader, as the chromosomes seemed similar enough. I ended up wasting some hours thinking reheader ONLY changed the header section. I wish the samtools documentation was better... turns out reheader changes the chromosome names everywhere in the file.

Thanks for your help though, I found salvation much faster thanks to you :-]

My command in case someone is curious:

samtools reheader -c "sed -e 's/SN:$$[0-9XY]\+$$/SN:chr\1/' -e 's/SN:MT/SN:chrM/'" h37.bam > hg19.bam

1
Entering edit mode

Thanks for sharing the solution!

0
Entering edit mode

Correction: I changed the * to \+, elsewise lots of things went wrong... sorry!