Converting CRAM slices to get a CRAM file
1
0
Entering edit mode
11 months ago
vinayjrao ▴ 200

Hi,

We received some data from EGA, but all of it is in CRAM format. Upon reading, I understood that it is a further compressed version of a BAM file, however the data provided is in CRAM slices (I'm guessing multiple slices would make up one CRAM file). Can someone please educate me on how to convert these to a single CRAM file which can be used for my analysis?

Thanks in advance.

samtools • 524 views
ADD COMMENT
1
Entering edit mode

Upon reading, I understood that it is a further compressed version of a BAM file

Not in the sense you are thinking of. For reference:

BAM and CRAM are both compressed forms of SAM; BAM (for Binary Alignment Map) is a lossless compression while CRAM can range from lossless to lossy depending on how much compression you want to achieve (up to very much indeed). BAMs and CRAMs hold the same information as their SAM equivalent, structured in the same way; what is different between them is how the files themselves are encoded.

ADD REPLY
2
Entering edit mode
11 months ago
jkbonfield ▴ 720

CRAM is it's own format rather than a derivation or improved version of BAM; much like BAM is a binary encoding of SAM, CRAM is just a different (smaller) binary encoding of SAM.

Ignore the "slice" terminology as it's just confusing things. You simply need a program capable of reading CRAM and, if desired, spitting it out in SAM or BAM format if that's what your other software needs, although many tools based on either htslib or htsjdk now natively accept CRAM anyway.

My personal recommendation for format conversion would be to use samtools. Eg:

samtools view -@8 in.cram -o out.bam


You may also need to set REF_PATH or supply a fasta file with -T. Seem the samtools.1 man page for details.

However check first whether you actually need to convert. If you need to merge, do region queries, sort, etc then you don't need to convert to BAM first. Anything samtools can do on BAM can also be done on SAM or CRAM directly.

ADD COMMENT
0
Entering edit mode

Thanks for the suggestion, but my concern is that most directories contain cram files, while the others contain cram.slice files, and it is these files that I am unable to convert. I will try this command and update the outcome.

ADD REPLY
0
Entering edit mode

I have no idea what a cram.slice file is. I've never heard of it!

I assume someone has binary bisected CRAM on the slice boundaries, but that'd be just speculation. If you concatenate them together do you get a valid CRAM file that can be read by tools?

ADD REPLY

Login before adding your answer.

Traffic: 2836 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6