Thanks! I think I need to rename the fast file and then do mapping agian.
I have several bam files with illegal chromosome names, eg: ENSMUST00000193812.1_4933401J01Rik
I wanna visualize these bam files in IGV and those illegal names are causing problems.
I know that I can edit the reference .fasta file header and do mapping again, But I really wanna know how to directly edit the bam file using awk or sed command. I see similar post here: Bam File: Change Chromosome Notation However it is quite difficult for me to understand and apply it to my own situation.
What I wanna do is just replace all the dot in the bam file chromosome name using lower dash.
Thanks in advance for any help!
2 answers
You should use samtools reheader. Do not do this with sed or awk - you could compromise the file.
bam files are compressed. You'd have to feed in the uncomprassed version into sed or awk. Easiest way to do that with with samtools, in which case, you might as well use samtools to do it by itself.
Log in to answer this question.
how do you know it's 'illegal' ? why is it causing any problem ?
IGV cannot read this bam files, please see this issue that I posted: https://github.com/igvteam/igv/issues/832#issuecomment-665877615