omics.co.in

Chapter 2: Raw Read Processing, STARsolo & Cell Ranger Count

Chapter 2: Raw Read Processing, STARsolo & Cell Ranger Count

Single-cell FASTQ data contains non-biological barcode sequences intermixed with biological RNA fragments. Processing these files requires matching cell barcodes against valid whitelist dictionaries, correcting single-base PCR/sequencing errors, aligning cDNA inserts to the reference genome, and assembling digital gene expression (DGE) matrices.

The Anatomy of a 10x Genomics FASTQ Pair

In standard Illumina paired-end sequencing for 10x Chromium v3:

  • Read 1 (R1, 28 bp): Bases 1–16 encode the 10x Cell Barcode; Bases 17–28 encode the 12 bp Unique Molecular Identifier (UMI).
  • Read 2 (R2, 91–150 bp): The cDNA biological sequence that is aligned to the reference genome.
  • Index Read (I1 / I2, 8–10 bp): Sample index used to demultiplex pooled sequencing libraries.

1. Running 10x Genomics Cell Ranger

The standard industry pipeline is cellranger count. It performs alignment with STAR, barcode filtering with an adaptive EmptyDrops algorithm, UMI counting, and secondary PCA/clustering analysis.

# 1. Download and verify pre-built reference (e.g., GRCh38 2024-A)
curl -O https://cf.10xgenomics.com/supp/cell-exp/refdata-gex-GRCh38-2024-A.tar.gz
tar -xzvf refdata-gex-GRCh38-2024-A.tar.gz

# 2. Run cellranger count across 16 CPU cores
cellranger count \
    --id=pbmc_10k_run \
    --transcriptome=/ref/refdata-gex-GRCh38-2024-A \
    --fastqs=/data/pbmc_10k_fastqs \
    --sample=pbmc_10k \
    --expect-cells=10000 \
    --localcores=16 \
    --localmem=64

2. Ultra-Fast Alternative: STARsolo

While Cell Ranger requires substantial compute time and memory, STARsolo is a built-in submodule of the STAR aligner that reproduces Cell Ranger output ~10x faster with identical results.

# STARsolo high-throughput single-cell alignment
STAR --runThreadN 16 \
     --genomeDir /ref/STAR_GRCh38_index \
     --readFilesIn sample_R2.fastq.gz sample_R1.fastq.gz \
     --readFilesCommand zcat \
     --soloType CB_UMI_Simple \
     --soloCBwhitelist /ref/10x_v3_whitelist.txt \
     --soloCBstart 1 --soloCBlen 16 \
     --soloUMIstart 17 --soloUMIlen 12 \
     --soloStrand Reverse \
     --soloFeatures Gene GeneFull \
     --soloCellFilter EmptyDrops_CR \
     --outSAMtype BAM SortedByCoordinate \
     --outFileNamePrefix ./starsolo_out/

3. Inspecting Sparse Matrix Outputs (MEX Format)

Single-cell expression matrices are >95% sparse (zeros where a gene was not captured in a given cell). Storing them as dense matrices would consume hundreds of gigabytes of RAM. Pipelines output matrices in Market Exchange (MEX) sparse format:

# Inspecting the Cell Ranger / STARsolo filtered matrix directory:
# output/sample/outs/filtered_feature_bc_matrix/
#   โ”œโ”€โ”€ barcodes.tsv.gz   -> List of 10,240 detected cellular barcodes (e.g. AAACCTGAGAAACCAT-1)
#   โ”œโ”€โ”€ features.tsv.gz   -> List of 36,601 genomic features (ENSG ID, Gene Symbol, Feature Type)
#   โ””โ”€โ”€ matrix.mtx.gz     -> Coordinate-list sparse matrix (row, col, UMI count)

# Peak at the matrix header
zcat matrix.mtx.gz | head -n 5
# %%MatrixMarket matrix coordinate integer general
# %
# 36601 10240 38459201   <-- (36,601 genes, 10,240 cells, 38.4 million non-zero entries)

4. The EmptyDrops Barcode Calling Logic

To distinguish genuine cells from cell-free ambient RNA floating in solution, Cell Ranger uses the EmptyDrops algorithm (Lun et al.). Instead of an arbitrary hard UMI cutoff, it estimates the multinomial profile of ambient RNA from droplets with very low UMIs (<100). Droplets whose expression profiles deviate significantly from this ambient background (\(p < 0.01\) after FDR correction) are retained as true cells, rescuing quiescent cells (e.g. naive T-cells or platelets) with low total RNA content.

← Return to Home Hub Scroll to Top ↑