Convert processed bam file to fastq
Entering edit mode
12 weeks ago

I found some 10x single-cell RNA seq data on GEO that I want to use for a study (SRR7754181). Unfortunately, it looks like the author only submitted read2 of the raw fastq files. They did include a bam file but it looks like it is already processed.

I was wondering if there is a way to split this file into fastq read1 and read2 so that I can realign it with cellranger. The study in question used an outdated version of cellranger count. When I try to split with samtools fastq, I get two empty fastq files. Am I missing something obvious?


samtools flagstat /12.5.bam.1
241289956 + 0 in total (QC-passed reads + QC-failed reads)
78389287 + 0 secondary
0 + 0 supplementary
1246988 + 0 duplicates
220870315 + 0 mapped (91.54% : N/A)
0 + 0 paired in sequencing
0 + 0 read1
0 + 0 read2
0 + 0 properly paired (N/A : N/A)
0 + 0 with itself and mate mapped
0 + 0 singletons (N/A : N/A)
0 + 0 with mate mapped to a different chr
0 + 0 with mate mapped to a different chr (mapQ>=5)

samtools fastq -@ 8 /12.5.bam.1     -1 E12_R1.fastq.gz     -2 E12_R2.fastq.gz     -0 /dev/null -s /dev/null -n
[M::bam2fq_mainloop] discarded 0 singletons
[M::bam2fq_mainloop] processed 162900669 reads
alignment sequence bam samtools fastq • 189 views
Entering edit mode

You could try SamToFastq from Pircard

java -jar picard.jar SamToFastq I=/12.5.bam.1 FASTQ=E12_R1.fastq.gz --SECOND_END_FASTQ=E12_R2.fastq.gz
Entering edit mode
12 weeks ago
GenoMax 100k

Under the "Data Access" tab of the SRA link you provided above there is original BAM file available. Use 10x supplied bamtofastq (LINK) utility to convert the data back to fastq using that BAM file. This will correctly recreate the fastq files specific for 10x data.

Entering edit mode

Thanks that worked really well!

In retrospect, I see that this answer was pretty accessible on google. My apologies, I didn't think to add 10x into my search terms so I was getting misdirected to things like samtools and bedtools.


Login before adding your answer.

Traffic: 2420 users visited in the last hour
Help About
Access RSS

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

Powered by the version 2.3.6