omics.co.in logo omics.co.in

9. Single-Cell & Spatial Transcriptomics

⚡ Category 9 of 14  ·  🧬 11 Primary Tools

Resolving cellular heterogeneity at single-cell and spatial resolution: UMI deduplication, dimension reduction, batch integration, RNA velocity, and spatial cell-cell interaction networks.

🔍 Ctrl + K

9. Single-Cell & Spatial Transcriptomics (scRNA-seq / Spatial)

11 Primary Tools

Deconvolution, cellular clustering, cell-type annotation, trajectory inference, RNA velocity, and 2D spatial tissue organization across single-cell ecosystems.

ToolPrimary Role & PurposeSupported PlatformsExecutable Pipeline
Cell Ranger (10x Genomics) →Industry pipeline for 10x Chromium 3'/5' and spatial data10x Chromium / VisiumView Code ↓
STARsolo →Open-source drop-in replacement for Cell Ranger with lower runtimes10x Chromium / Smart-seqView Code ↓
Alevin / Alevin-fry →Fast, memory-lean pseudoalignment for single-cell data10x Chromium / Parse / Drop-seqView Code ↓
Seurat (v4 / v5) →QC, normalization (SCTransform), multimodal integration, clusteringR EcosystemView Code ↓
Scanpy →Scalable graph-based single-cell analysis for millions of cellsPython / AnnDataView Code ↓
scVI (scvi-tools) →Variational autoencoders for batch correction, integration, and imputationPyTorch / GPUView Code ↓
Harmony →Fast projection and batch-effect correction across multiple donors/runsR / Python EcosystemView Code ↓
Monocle3 / Slingshot →Pseudotime ordering and lineage branch point analysisR EcosystemView Code ↓
scVelo / Velocyto →Resolves directional dynamics via spliced/unspliced transcript ratiosPython / LoomView Code ↓
Squidpy / Giotto →Spatial graph analysis, neighborhood enrichment, spatial co-occurrence10x Visium / Xenium / MERFISHView Code ↓
CellChat / SingleCellSignalR →Inferring ligand-receptor interaction networks from scRNA datasetsSingle-Cell & Spatial (R)View Code ↓
🌐 Extended Single-Cell & Spatial Ecosystem: Single-Cell, Spatial & Multi-Omics
Pre-Processing & Counts: Cell Ranger, STARsolo, alevin-fry, kallisto|bustools
Core Frameworks: Seurat (v5), Scanpy, scVI-tools, SingleCellExperiment (scran)
Batch Integration & QC: Harmony, BBKNN, scVI / scANVI, LIGER, SoupX, CellBender, DoubletFinder
Cell Typing & Trajectories: CellTypist, SingleR, Azimuth, scArches, Monocle3, Slingshot, scVelo, CellRank
Cell-Cell & Networks: CellChat, NicheNet, CellPhoneDB, LIANA, SCENIC / pySCENIC
Spatial & Epigenome: Space Ranger, Squidpy, Giotto, cell2location, BayesSpace, ArchR, Signac, SnapATAC2
🧬

Chromium 3'/5' & Visium Demultiplexing and Counting

10x Genomics Demux & UMI

Cell Ranger is 10x Genomics’ official processing pipeline for Chromium Single Cell gene expression. It processes raw BCL or FASTQ files, demultiplexes cellular barcodes, maps reads to transcripts, deduplicates UMIs, and generates feature-barcode matrices.

# 1. Run Cell Ranger count on 10x 3' Gene Expression libraries
cellranger count \
  --id=pbmc_10k_sample \
  --transcriptome=/ref/refdata-gex-GRCh38-2024-A \
  --fastqs=/data/pbmc_10k_fastqs/ \
  --sample=pbmc_10k \
  --expect-cells=10000 \
  --localcores=16 \
  --localmem=64

# Filtered gene-barcode matrix:
# pbmc_10k_sample/outs/filtered_feature_bc_matrix.h5
# Interactive web report: pbmc_10k_sample/outs/web_summary.html
Key Flags: --expect-cells=10000 guides automated EmptyDrops background cell-calling algorithm; --localcores=16 --localmem=64 sets compute limits.
⭐

Open-Source Drop-in Cell Ranger Replacement in C++

STAR C++ 10x Faster

STARsolo is built into STAR for mapping single-cell RNA-seq. It emulates 10x Genomics Cell Ranger barcode and UMI algorithms, delivering identical cell-by-gene matrices with up to 10x lower runtime and flexible barcode geometries.

# 1. Run STARsolo on 10x Chromium v3 data
STAR --runThreadN 16 \
  --genomeDir ./star_index/ \
  --readFilesIn sample_R2.fq.gz sample_R1.fq.gz \
  --readFilesCommand zcat \
  --soloType CB_UMI_Simple \
  --soloCBwhitelist 3M-february-2018.txt \
  --soloCBlen 16 --soloUMIlen 12 --soloUMIstart 17 \
  --soloCellFilter EmptyDrops_CR \
  --soloFeatures Gene GeneFull \
  --outSAMtype None \
  --outFileNamePrefix ./starsolo_out/
Key Flags: --soloType CB_UMI_Simple specifies single-cell protocol; --soloCellFilter EmptyDrops_CR runs exact Cell Ranger empty droplets filter.
🐟

Ultra-Fast Memory-Lean Single-Cell Pseudoalignment

Alevin-fry Memory Lean

Alevin and Alevin-fry provide an ultra-fast, memory-lean suite for processing single-cell and single-nucleus RNA-seq data, resolving ambiguous multimapping reads with parsimonious UMI graphs.

# 1. Generate RAD file with Salmon Alevin
salmon alevin -l ISR -1 sample_R1.fq.gz -2 sample_R2.fq.gz \
  --chromiumV3 -i salmon_splici_index \
  -p 16 -o alevin_rad_out --rad

# 2. Permit list generation and collating with alevin-fry
alevin-fry generate-permit-list -d fw -k -i alevin_rad_out -o alevin_fry_work
alevin-fry collate -r alevin_rad_out -t 16 -i alevin_fry_work
alevin-fry quant -m cr-like -i alevin_fry_work -o alevin_counts -t 16 --use-unspliced
Key Flags: --chromiumV3 sets 10x Chromium v3 barcode geometry; quant -m cr-like generates Cell-Ranger compatible count matrices.
🎨

The R Single-Cell Genomics Benchmark Platform

R Benchmark SCTransform v2

Seurat is an R package designed for QC, analysis, and exploration of single-cell RNA-seq and spatial data. It features SCTransform variance-stabilizing normalization, PCA/UMAP embeddings, Louvain/Leiden clustering, and multi-modal CITE-seq integration.

library(Seurat)
library(dplyr)

# 1. Load 10x Genomics matrix and filter low-quality cells
pbmc.data <- Read10X(data.dir = "filtered_feature_bc_matrix/")
pbmc <- CreateSeuratObject(counts = pbmc.data, project = "PBMC", min.cells = 3, min.features = 200)
pbmc[["percent.mt"]] <- PercentageFeatureSet(pbmc, pattern = "^MT-")
pbmc <- subset(pbmc, subset = nFeature_RNA > 200 & nFeature_RNA < 2500 & percent.mt < 10)

# 2. Run SCTransform normalization
pbmc <- SCTransform(pbmc, vars.to.regress = "percent.mt", verbose = FALSE)

# 3. Dimensionality reduction and Clustering
pbmc <- RunPCA(pbmc, verbose = FALSE)
pbmc <- FindNeighbors(pbmc, dims = 1:30)
pbmc <- FindClusters(pbmc, resolution = 0.6)
pbmc <- RunUMAP(pbmc, dims = 1:30)

# 4. Find cluster biomarker markers
markers <- FindAllMarkers(pbmc, only.pos = TRUE, min.pct = 0.25, logfc.threshold = 0.25)
head(markers)
Key Flags: PercentageFeatureSet(pattern = "^MT-") computes mitochondrial proportion; SCTransform(vars.to.regress = "percent.mt") regularizes negative binomial models.
🐍

Scalable Python Single-Cell Analysis on AnnData

Python Benchmark AnnData Ecosystem

Scanpy is a scalable toolkit for analyzing single-cell gene expression data built on AnnData and NumPy/SciPy. It executes preprocessing, highly variable gene selection, PCA, k-NN graph construction, UMAP embeddings, and Leiden community detection across millions of cells.

import scanpy as sc

# 1. Ingest 10x HDF5 matrix
adata = sc.read_10x_h5("filtered_feature_bc_matrix.h5")
adata.var_names_make_unique()

# 2. Calculate QC metrics and filter
adata.var["mt"] = adata.var_names.str.startswith("MT-")
sc.pp.calculate_qc_metrics(adata, qc_vars=["mt"], inplace=True)
adata = adata[(adata.obs.n_genes_by_counts < 2500) & (adata.obs.pct_counts_mt < 10)]

# 3. Normalize and identify highly variable genes
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)
sc.pp.highly_variable_genes(adata, n_top_genes=2000)
adata.raw = adata
adata = adata[:, adata.var.highly_variable]

# 4. Dimensionality reduction & Leiden clustering
sc.pp.scale(adata, max_value=10)
sc.tl.pca(adata, svd_solver="arpack")
sc.pp.neighbors(adata, n_neighbors=15, n_pcs=30)
sc.tl.umap(adata)
sc.tl.leiden(adata, resolution=0.5)

# 5. Plot and save
sc.pl.umap(adata, color=["leiden"], save="_clusters.png")
Key Flags: sc.pp.highly_variable_genes(n_top_genes=2000) identifies top informative genes; sc.tl.leiden(resolution=0.5) groups single cells into distinct clusters.
🤖

Deep Probabilistic Generative Models in PyTorch

Deep Generative VAE Batch Integration

scvi-tools is a suite of deep probabilistic models for single-cell omics data. scVI utilizes Variational Autoencoders (VAEs) to learn a non-linear latent space that captures cell identity while explicitly removing batch effects and library size differences.

import scvi
import scanpy as sc

# 1. Setup AnnData with raw counts and batch key
adata = sc.read_h5ad("combined_cohort.h5ad")
scvi.model.SCVI.setup_anndata(adata, layer="counts", batch_key="donor_batch")

# 2. Initialize and train Variational Autoencoder
vae = scvi.model.SCVI(adata, n_latent=30, gene_likelihood="nb")
vae.train(max_epochs=200, early_stopping=True)

# 3. Extract integrated latent representation
adata.obsm["X_scVI"] = vae.get_latent_representation()

# 4. Cluster on integrated latent space
sc.pp.neighbors(adata, use_rep="X_scVI")
sc.tl.umap(adata)
sc.pl.umap(adata, color=["donor_batch", "cell_type"])
Key Flags: setup_anndata(batch_key="donor_batch") specifies batch covariate to eliminate; vae.get_latent_representation() extracts corrected low-dimensional embeddings.
🤝

Fast Iterative Clustering Batch-Effect Correction

Fast Integration PCA Space

Harmony aligns single-cell transcriptomics data from multiple donors, experimental batches, and technologies. By operating iteratively on low-dimensional PCA space, it projects cells into a shared embedding while preserving real biological variation.

library(harmony)
library(Seurat)

# 1. Merge Seurat objects across batches and run PCA
merged_seurat <- NormalizeData(merged_seurat) %>%
  FindVariableFeatures() %>%
  ScaleData() %>%
  RunPCA(verbose = FALSE)

# 2. Run Harmony integration across donor batches
merged_seurat <- RunHarmony(merged_seurat, group.by.vars = "batch", dims.use = 1:30)

# 3. Build UMAP on Harmony embeddings
merged_seurat <- RunUMAP(merged_seurat, reduction = "harmony", dims = 1:30)
DimPlot(merged_seurat, reduction = "umap", group.by = "batch")
Key Flags: group.by.vars = "batch" specifies batch metadata to correct; reduction = "harmony" passes integrated coordinates to UMAP.
🌿

Single-Cell Trajectory Inference & Pseudotime Ordering

Trajectory Inference Pseudotime

Monocle 3 discovers dynamic biological transitions (stem cell differentiation, immune activation) by learning principal graph trajectories through single-cell transcriptomes and calculating pseudotime along developmental branches.

library(monocle3)

# 1. Construct cell_data_set from Seurat or count matrix
cds <- new_cell_data_set(expression_data, cell_metadata = col_data, gene_metadata = row_data)
cds <- preprocess_cds(cds, num_dim = 50)
cds <- reduce_dimension(cds)

# 2. Cluster cells and learn principal trajectory graph
cds <- cluster_cells(cds)
cds <- learn_graph(cds, use_partition = FALSE)

# 3. Order cells by pseudotime from root node
cds <- order_cells(cds)
plot_cells(cds, color_cells_by = "pseudotime", label_cell_groups = FALSE)
Key Flags: learn_graph(use_partition = FALSE) connects all clusters into a unified lineage graph; order_cells() assigns pseudotime progression values.
➡️

Directional Dynamics via Spliced/Unspliced Kinetics

RNA Velocity Dynamical Model

scVelo solves the full transcriptional dynamics of splicing kinetics using a likelihood-based dynamical model. By comparing unspliced pre-mRNA with mature spliced mRNA, it projects directional cell differentiation vectors onto UMAP embeddings.

import scvelo as scv

# 1. Load loom file containing spliced and unspliced layers
adata = scv.read("sample_velocyto.loom", cache=True)

# 2. Preprocess and compute moments
scv.pp.filter_and_normalize(adata, min_shared_counts=20, n_top_genes=2000)
scv.pp.moments(adata, n_pcs=30, n_neighbors=30)

# 3. Recover dynamics and compute velocity graph
scv.tl.recover_dynamics(adata)
scv.tl.velocity(adata, mode="dynamical")
scv.tl.velocity_graph(adata)

# 4. Project velocity streams on UMAP
scv.pl.velocity_embedding_stream(adata, basis="umap", color="cell_type", save="velocity_stream.png")
Key Flags: mode="dynamical" fits differential equations of transcription, splicing, and degradation; velocity_embedding_stream visualizes differentiation arrows.
🗺️

Spatial Molecular Graph Analysis & Co-occurrence

Spatial Transcriptomics Neighborhood Graphs

Squidpy brings spatial analysis to AnnData. It constructs spatial cellular neighborhood graphs, computes Moran’s I spatial autocorrelation, tests cellular co-occurrence, and integrates histology images with gene expression in Visium and Xenium assays.

import squidpy as sq

# 1. Ingest 10x Visium spatial dataset
adata = sq.read.visium("visium_data_dir/")

# 2. Build spatial neighborhood graph from physical spot coordinates
sq.gr.spatial_neighbors(adata, coord_type="grid", n_rings=2)

# 3. Calculate spatial autocorrelation (Moran's I) to identify spatially variable genes
sq.gr.spatial_autocorr(adata, mode="moran", genes=adata.var_names[:1000], n_perms=100)

# 4. Compute cellular neighborhood enrichment across cell types
sq.gr.nhood_enrichment(adata, cluster_key="cluster")
sq.pl.nhood_enrichment(adata, cluster_key="cluster", save="nhood_enrichment.png")
Key Flags: sq.gr.spatial_neighbors connects neighboring tissue spots based on physical distance; spatial_autocorr(mode="moran") discovers spatially patterned genes.
💬

Ligand-Receptor Communication Networks

Cell-Cell Signaling Ligand-Receptor

CellChat quantitatively infers intercellular communication networks from single-cell gene expression data using a comprehensive database of human and mouse ligand-receptor interactions, co-factors, and multi-subunit complexes.

library(CellChat)

# 1. Initialize CellChat object with expression and cell cluster labels
cellchat <- createCellChat(object = normalized_counts, meta = meta_data, group.by = "cell_type")
CellChatDB <- CellChatDB.human
cellchat@DB <- CellChatDB

# 2. Subset to signaling genes and compute communication probabilities
cellchat <- subsetData(cellchat)
cellchat <- identifyOverExpressedGenes(cellchat)
cellchat <- identifyOverExpressedInteractions(cellchat)
cellchat <- computeCommunProb(cellchat, raw.use = TRUE)
cellchat <- aggregateNet(cellchat)

# 3. Visualize intercellular communication network
netVisual_circle(cellchat@net$count, vertex.weight = groupSize, weight.scale = TRUE,
                  label.edge= FALSE, title.name = "Number of Interactions")
Key Flags: CellChatDB.human loads curated ligand-receptor pairs; computeCommunProb() estimates interaction strengths with mass action law.
← Return to Home Hub
📦 Practice Datasets
🗺️ NGS Data Analysis Process & Workflow Architecture (High-Resolution)
⬇️ Download
NGS Analysis Process Graph Full View