This is a test version of Biostars. For the public version, visit https://www.biostars.org.
? in cram files

I have an original bam file that when compressed to cram format, the quality encoding scores are lost and replaced as question marks ? and other symbols. The following questions come up:

  1. Why is it that the original base quality scores are changed when compressing from bam to cram?
    1. Is it possible to map back the base quality scores from a cram file to original bam file using a reference file?

Example:

Converted Cram File

CCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAAACCTTACCATAAACCTAACCCTAACCCAAAACCTAACCCATAAACAAACCATAAAAAAAAAAATAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

????????????????????????????????????????????+5?++5?55????+??++?5??'+??'+'+?+++++??'?5++++'+++&+?5+++'++++++'++'++++++++++?+++++????+???+?????+?????+???

sequencing genomics

As an alternative, you might also want to check my Genozip tool, which usually compresses better than CRAM, and is 100% lossless. It can even compress cram files. Some benchmarks here: https://genozip.com/benchmarks.html

Please make a tool post rather than putting this in unrelated threads.

in addition, the compression is not fully open/free. It needs licensing in clinical and commercial settings.

1 answer

  1. The base qualities don't have to be lost, that's an optional feature and should generally not produce what you posted.
  2. Unlikely. Someone messed something up when creating the CRAM file. Note that phred scores aren't actually that informative when it comes to SNP calling these days, which is why newer sequencers are starting to bin them.

Overall, review how the CRAM file was made, likely there was a mistake at that point.

Thanks for the response Devon!

  1. Is there an optional feature when using samtools then I believe? I was trying to use RevertSam to put the cram back to it's original state (bam) and thought with the reference would get the scores but didn't happen.
  2. The phred scores are needed in some pipelines, hence why I wanted to keep them.

Thanks

Can you try samtools view to do the conversions of CRAM to BAM? Using a third party tool like Picard may not be following the latest CRAM/BAM specs.

Samtools itself doesn't have an option to modify base qualities, it turns out that it's just read names and some auxiliary information (MD tags) that it can be told to store in a lossy manner. So the error must have occurred upstream if you used samtools for conversion.

Thanks Devon, this clarifies quite a bit what I was looking for and the direction I need to take!

Log in to answer this question.