1
$\begingroup$

10x Genomics data are stored in three FASTQ files, besides the standard R1 and R2 reads, there is also a I1 file with some metadata. Sometimes however they are shipped in a single bam/cram file (e.g. the data from the Darwin Tree of Life). How can I convert the BAM or CRAM files to FASTQ?

-- edit --

Apparently, the I3 file is not 10x specific thing. It is an index generated when demultiplexing any Illumina data. See this question for a nice explanation.

$\endgroup$
2
  • $\begingroup$ Isn't I1 the index read not unique to 10x data? But normally demultiplexing Illumina data with bcl2fastq does not generate these reads with default arguments $\endgroup$ Jun 8, 2021 at 20:12
  • $\begingroup$ @Chris_Rands (after a bit of googling) you are right. I just not aware of its existence before I run into this question on the tDToL GitHub. And then I thought I might as well put it here so it's easier to google it. $\endgroup$ Jun 8, 2021 at 22:44

2 Answers 2

1
$\begingroup$

All can be done with samtools. This is how the Darwin Tree of Life folks convert it:

samtools fastq -@4 -i \
  -1 ${sample}_S${tag}_L%03s_R1_001.fastq.gz \
  -2 ${sample}_S${tag}_L%03s_R2_001.fastq.gz \
  --i1 ${sample}_S${tag}_L%03s_I1_001.fastq.gz \
  --index-format i8 ${lane}.cram
$\endgroup$
4
  • $\begingroup$ I don't know if that solution will work with 10xGenomics files. You have to recreate R2 out of the contents of tags; there will be no reads with the read2 binary flag set. $\endgroup$
    – swbarnes2
    Jun 9, 2021 at 19:41
  • $\begingroup$ @swbarnes2 I just have seen this thread: github.com/darwintreeoflife/darwintreeoflife.data/issues/… and tried to make it more googlable (because I do think there will be quite a few people who will be downloading the tDToL data). $\endgroup$ Jun 10, 2021 at 9:39
  • $\begingroup$ I saw that thread too. I don't think it's right. samtools fastq -2 will work fine for bams from many applications, but not 10XGenomics. $\endgroup$
    – swbarnes2
    Jun 10, 2021 at 16:45
  • $\begingroup$ @kamil, can you post a couple of lines of the BAM file showing how tags for R1 and R2 appear in 10x data? I can probably quite easily add support for this in genozip.com/sam2fq.html $\endgroup$
    – Divon
    Jul 25, 2021 at 1:21
1
$\begingroup$

You'll want to use the 10x provided bamtofastq tool to preserve the indices properly: https://github.com/10XGenomics/bamtofastq

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.