3
$\begingroup$

I am trying to reproduce some results of a scRNASeq experiment. However I am new to the server-side aspect of such analyses and am very confused at the moment.

The data provided by the authors of the paper is in .BAM format and from there I wish to derive a gene expression matrix (UMI counts per gene per cell). The authors stated that they did this using the 10X genomics pipeline, however it seems that .BAM outputs are sort of the "final version" of the pipeline and, the pipeline only really deals with truly raw sequencing files (bcl/fastq).

I have considered converting it back to fastq format and following the pipeline from the beginning, but it just seems like I would be moving backwards by doing such.

I have also found some R packages that can integrate BAM files in the environment like Rsamtools, but I would much rather do this on the server and then upload a csv into R for the downstream analysis as the files are +60GB each.

Essentially I am just asking for some advice, or a vignette/article I can read that would clear up how to proceed with the BAM outputs to derive the gene expression data. I have already read the cellranger pages on the 10X genomics website but they were of no help in answering this quesion.

Thank you for your time,

$\endgroup$
  • 3
    $\begingroup$ You might just email the authors. They just uploaded the BAM files because that's the easiest thing to do. CellRanger produces 3 files that describe the counts (they're in "matrix market format") and presumably they can just email them to you. $\endgroup$ – Devon Ryan Feb 22 at 7:44
  • $\begingroup$ Thanks Devon for your reply. Thing is though, I am trying to learn how to do all this processing myself as I will need to eventually. Unfortunately, most of the documents I have read end up making me more confused. I know BAM files are technically already processed and aligned but, how would I get the counts from the file? $\endgroup$ – h3ab74 Feb 25 at 15:11
  • 1
    $\begingroup$ If you're going to use cell ranger anyway then this isn't something you have to bother learning how to do, it's done by cell ranger internally. $\endgroup$ – Devon Ryan Feb 25 at 15:14
  • 1
    $\begingroup$ If you accept using other tools than those that the authors mention, one that can get you from a bam file to counts is featureCounts (bioinf.wehi.edu.au/featureCounts). You would also need an annotation file in gtf format. $\endgroup$ – bli Feb 25 at 15:25
  • $\begingroup$ @DevonRyan thanks for clearing that up, I get what you are saying now as well as your earlier comment. I will probably just contact the authors directly. $\endgroup$ – h3ab74 Feb 25 at 15:43
3
$\begingroup$

You should be able to parse out what you need using the tags in the .bam. 10xGenomics' website says what tags they add.

https://support.10xgenomics.com/single-cell-gene-expression/software/pipelines/latest/output/bam

Going backwards would also involve parsing the tags, because you have to make two fastq files, and a simple bam -> fastq pipeline won't do that correctly.

$\endgroup$
  • $\begingroup$ Could you be more specific please? I'm very new to this procedure and bash scripting in general. $\endgroup$ – h3ab74 Feb 21 at 22:13
  • 1
    $\begingroup$ Yes, 10xGenomics single cell bams have the genes called in the bam tags. support.10xgenomics.com/single-cell-gene-expression/software/… And no, samtools fastq will not make paired end fastqs suitable to rerun through cellranger, because the read data from the read containing the cell barcode and UMI will not have its own line in the bams. $\endgroup$ – swbarnes2 Feb 25 at 16:45
  • $\begingroup$ @swbarnes2 There are indeed many tags, but isn't the UMI tag different than UMI counts? So how would I derive the expression matrix from these said tags? Thank you btw for your answer! $\endgroup$ – h3ab74 Feb 25 at 18:50
  • $\begingroup$ Each read has its UMI as a bam tag. You can go through the bam line by line and figure out which reads were assigned to what cell barcode, UMI and gene. $\endgroup$ – swbarnes2 Feb 25 at 20:18
  • $\begingroup$ This reverse process is also complicated by the fact that error-correction is performed on the barcodes and UMIs as well. For scRNA-seq, you typically start with 4 FASTQs: UMIs, barcodes, R1, and R2. There will likely be errors in those sequences, so barcodes/UMIs are corrected for by comparing to a whitelist of known input barcodes. You can take a look at the "Feature Barcoding Tags" section of the 10x support page @swbarnes2 listed to see what tags to look for. As mentioned, it's not a simple BAM -> FASTQ operation, but you should be able to do it $\endgroup$ – James Hawley Sep 27 at 14:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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