it seems to me that this samplesheet should work f...
# sarek
m
it seems to me that this samplesheet should work for mapping
Copy code
patient,sample,lane,cram,crai
user,ASAMPLE,lane_1,s3://mybucket/my.cram,s3://mybucket/my.cram.crai
since the equivalent bam based one does work. but it is rejected with the message
Copy code
ERROR ~ Validation of pipeline parameters failed!
     -- Check '.nextflow.log' file for details
    The following invalid input values have been detected:
    * --input (s3://mybucket/myjob.csv): Validation of file failed:
     -> Entry 1: Object does not have some of the required properties [[fastq_1]]
     -> Entry 1: Object does not have some of the required properties [[spring_1]]
     -> Entry 1: Object does not have some of the required properties [[bam]]
     -> Entry 1: Value does not match against any of the schemas
     -- Check script '/home/myuser/.nextflow/assets/nf-core/sarek/subworkflows/nf-core/utils_nfschema_plugin/main.nf' at line: 39
or see '.nextflow.log' file for more details
based on https://github.com/nf-core/sarek/blob/5fe5cdff171e3baed603b3990cab7f7fd3fcb992/docs/usage.md?plain=1#L187 I could perhaps try and remove the 'lane' but it seems an extra column shouldn't cause a failure. ?!
perhaps this 'explains' it https://github.com/nf-core/sarek/blob/5fe5cdff171e3baed603b3990cab7f7fd3fcb992/docs/usage.md?plain=1#L103 but why would CRAM be unacceptable when BAM is fine? If all I have is a CRAM in s3, must I convert it to CRAM with samtools before this pipeline step can execute?
a
That seems fairly explanatory as to the error. To answer the point about CRAM, it conceptually doesn’t make much sense to support mapping directly from CRAM because unaligned CRAM whilst possible is rare and tools often can’t work easily with it. I think in theory you could go from aligned cram -> BAM for the alignment input but then you would need the reference that the original aligned CRAM was generated with PLUS the reference you want to re-align against. That would add even more complexity to an already complex pipeline so I guess that is why it is not supported.
m
thanks @Arthur for the response
m
Well, technically, unaligned cram has no reference, since it’s not aligned 😅 so unaligned cram shouldn’t be an issue
Also, if I’m not mistaken, even aligned crams should work with ‘samtools fastq’ without a reference
It’s the required ‘collate’ before that’s the issue I think
a
Hmm... can you get back from the aligned cram to the original fastq without a reference?
m
We do 🤷‍♂️
For unaligned data at least. Not entirely sure about aligned
a
My assumption was that it would because the compression benefit is partly due to information in the reference. Seems like maybe it uses one that it infers if you don't provide it? https://www.htslib.org/doc/samtools.html#REFERENCE_SEQUENCES
m
In the case of unaligned cram, there is no reference sequence by definition, so nothing to compress there. It just uses libdeflate etc to compress the data more than zlib can in the bam format. https://www.htslib.org/doc/samtools-import.html
Just did a quick check for aligned data, that doesn’t work
samtools <1.22 did try to fetch reference data online
a
Yeah I figured. AFAIK CRAM stores aligned data by storing only the differences to the reference. Which means it needs the reference to decode it back to BAM/FASTQ. That reference can be made available multiple ways, but it’s back to the complexity issues for the pipeline designer. CRAM is in theory great, but the poor general support for it from so many tools makes it not hugely appealing imo. I basically just use it for storage due to the lower space. Processing is all done on BAMs.
m
We tend to cram all the things, but it does introduce quite a bit of hassle I’ll admit. IMO either the samtools team or GA4GH should provide more “official” libs in different programming languages to drive adoption in the community
Currently, there’s only the C API and HTSjdk ( 🥶 java ) and community projects for python (pysam) and rust (noodles) with decent support for cram
I’d loooooove a good library for go
a
The problem is that so many tools simply don’t allow for it, even if written in C/Python.
m
I know. Most first issues I make when checking out a new tool is “Can you please add cram support?“, followed by “Can you please add this to bioconda”?
😂 2
m
FWIW This commandline is sufficient for my needs
Copy code
samtools view -@1 --customized-index --write-index --fai-reference /ref/src_ref.fna -o /dest/basename.bam /src/srcname.cram /src/srcname.cram.crai
It does the cram to bam without needing to depend on the cram for reference info. but if this were done at a slightly lower level, and each worker that knew it was responsible for region chr4:1-10000000 would pull just that from a samtools supported https://www.htslib.org/doc/htslib-s3-plugin.html and or https://github.com/awslabs/mountpoint-s3 the world would be a better place. it'll eventually happen, and we'll regret not getting there sooner.
I don't think the problem is language and library support. The hassle of the cram, is the 'oops sometimes no reference' issue doesn't actually exist if we use the designed for this md5sum in the cram with refget
but why no lack of wider adoption, on the md5sum & refget? • if your cram could embed an ordered list of servers I think we'd trust it more. • if you could trust that any resource would still be up and stable in 30 years. • if you could sustain a server that gets occasionally intentionally abused