omics.co.in logo omics.co.in

Chapter 18: Automated Cell Type Annotation (SingleR, Azimuth, CellTypist) & Functional Analysis

Tested Stacks: GATK 4.6.1 Samtools 1.21 Nextflow 24.10 Seurat v5.1 Python 3.12
Prerequisites: Basic Linux CLI & Sequencing Formats
📚 Chapter 18 of 18 0% Course Completed

1. Automated Reference-Based Cell Label Transfer

Manual marker inspection is subjective, time-consuming, and prone to investigator bias. Automated reference annotation tools map single-cell query profiles against expertly curated, high-depth reference cell atlases:

Automated ToolMethodology & ArchitectureReference LibrariesBest Suited For
SingleRSpearman rank correlation on variable genes; iterative pruningHuman Primary Cell Atlas (HPCA), Blueprint/ENCODE, ImmGenUniversal, unbiased cell identification across diverse human & mouse tissues
AzimuthReference-based supervised projection on multimodal CITE-seq referencesHuman PBMC, Lung, Bone Marrow, Kidney, Liver, Motor CortexHigh-resolution fine subtyping (e.g., CD4 Naive vs Central Memory T cells)
CellTypistLogistic regression classifiers trained on consensus single-cell atlasesComprehensive Human Immune Atlas, Specialized Organ AtlasesFast cross-platform immune cell classification

2. Complete SingleR Automated Annotation Script

if (!requireNamespace("SingleR", quietly = TRUE)) BiocManager::install("SingleR")
if (!requireNamespace("celldex", quietly = TRUE)) BiocManager::install("celldex")

library(SingleR)
library(celldex)
library(Seurat)

# 1. Download Curated Reference Transcriptome (Human Primary Cell Atlas)
hpca_ref <- celldex::HumanPrimaryCellAtlasData()

# 2. Extract Single-Cell Test Matrix (SCT or RNA counts)
query_counts <- GetAssayData(pbmc, assay = "RNA", slot = "counts")

# 3. Execute SingleR Automated Annotation
# Computes correlation per cell and iteratively prunes ambiguous cell types
predictions <- SingleR(
    test = query_counts,
    ref = hpca_ref,
    labels = hpca_ref$label.main
)

# 4. Integrate Predicted Labels into Seurat Object
pbmc$SingleR_Label <- predictions$labels

# Diagnostic: Score heatmap checking classification confidence
plotScoreHeatmap(predictions)

# 5. Visualizing Final Annotated Single-Cell UMAP
DimPlot(pbmc, group.by = "SingleR_Label", reduction = "umap", label = TRUE, repel = TRUE) +
    labs(
        title = "Final Annotated Single-Cell Immune Atlas",
        subtitle = "Automated reference label transfer via SingleR & Human Primary Cell Atlas"
    ) +
    theme_minimal(base_size = 14)

3. Downstream Single-Cell Functional Frontiers

Beyond Clustering: High-Impact Downstream Analyses

  • Pseudobulk Differential Expression: Aggregating single-cell counts per patient sample within each cell type, followed by DESeq2 modeling. This completely eliminates single-cell false discoveries caused by pseudo-replication.
  • Cell-Cell Communication (CellChat & SingleCellSignalR): Quantifying ligand-receptor pair expression to infer paracrine and autocrine communication networks between immune infiltrates and tumor cells.
  • RNA Velocity & Trajectory Inference (scVelo & Monocle 3): Distinguishing unspliced from spliced mRNAs to project future cellular differentiation vectors.
⚠️

Common Pitfalls & Troubleshooting Checklist

  • Java Heap Exhaustion (GATK / Picard): If processes terminate with java.lang.OutOfMemoryError, set your environment variable explicitly: export _JAVA_OPTIONS="-Xmx16g -Djava.io.tmpdir=/tmp".
  • Index Timestamp Mismatch: If tools complain that a BAM index is missing or out of date, regenerate with samtools index -@ 4 sample.bam.
  • Conda Channel Conflicts: Avoid ABI incompatibilities between bioconda and conda-forge by setting strict priority: conda config --set channel_priority strict.
  • Chromosome Naming Contamination: Always verify whether reference FASTA headers use chr1 or 1; divergent naming causes silent alignment drops.
Was this guide helpful to your research?
Help us maintain 100% accurate, peer-reviewed bioinformatics standards.
📝 Propose Edit on GitHub ↗