Hi,
I have scaffold level data, and I know the chromosomal assignment of each scaffold, and am trying to rename each scaffold to each chromosome it belongs to.
Here's the command I tried to rename one scaffold to chromosome 1 as a test:
samtools view -h s2907.bam |sed -e 's/SN:QRBIO1000092.1/SN:chr1/' | samtools reheader - s2907.bam > test_s2907.bam
It appears to work, but then when I check the test_s2907.bam file, the original scaffold name (QRBIO1000092.1) is still there, not the new chromosome name (chr1) I tried to assign.
I'd appreciate any help.
Thanks.
1 answer
Giving the -c option to samtools reheader seems to work:
samtools reheader -c 'sed -e "s/SN:QRBIO1000092.1/SN:chr1/"' s2907.bam > test_s2907.bam
While this worked for me it doesn't seem to be the most efficient way to do it. Rather the reheader docs say you can use a SAM file with a template header to replace the header in your BAM file in place, which seems like it would be much more efficient (if you need that).
Log in to answer this question.
Any help is appreciated.