Entering edit mode
3.4 years ago
nrk_02
▴
10
Hello!
I have a BAM file that was aligned to Feb. 2009 GRCh37/hg19 Assembly, and I would like to convert it to a CRAM file. I use this command:
samtools view -C -T reference/hs37d5.fa -o file.cram file.bam
However, I get an error as:
[E::cram_get_ref] Failed to populate reference for id 0
[main_samview] failed to write the SAM header
Also, I know that my BAM file is sorted as the header returns -> SO:coordinate
What do you think can be the issue here?
What is the output of
grep '^>' reference/hs37d5.fa
andsamtools view -H file.bam | grep '^@'SQ
?BAM file header format:
Reference header format:
There is your answer, a mismatch in chromosome identifiers.
Thank you very much! I know that I can change the BAM file chr notation, but then I am still not sure how it should look after editing, should it just be "chromosome" instead of "chr" ?
I would rather try to find the exact reference that was used for alignment. It should match the bam file, so it must be
>chr1, >chr2
etc. Don't manipulate the bam, this is probably way more prone to chaos than altering the reference file names.Thank you very much for your replies so far! I am just curious and want ro learn: If I were to manipulate BAM to make a match, how would I do it?
You would need a conversion table that lists the chromosome name in the BAM file, and the matched name in the reference and then do some
gsub
operation to find replace them. I do not have code for it at hand, sorry.