Annotates cell clusters with biological cell type labels using multiple methods: direct assignment, ScType, scCATCH, hitype, or CellTypist...
Annotates cell clusters with biological cell type labels using multiple methods: direct assignment, ScType, scCATCH, hitype, or CellTypist. This process is essential for interpreting clustering results by assigning meaningful biological identities to each cluster.
[CellTypeAnnotation]
cache = true # Cache results for faster re-runs
[CellTypeAnnotation.in]
sobjfile = ["SeuratClustering"] # Path or reference to Seurat object
[CellTypeAnnotation.envs]
# Annotation method selection
tool = "direct" # Options: "direct", "sctype", "hitype", "sccatch", "celltypist"
# Cluster identity column (required for h5ad input, optional for Seurat objects)
ident = "seurat_clusters" # Column name in metadata representing clusters
# Backup column name (stores original cluster labels)
backup_col = "seurat_clusters_id" # Default: "seurat_clusters_id"
# New column name for annotated cell types
# If specified, original identity is kept; otherwise, it's replaced
newcol = "" # Default: empty (overwrite identity)
# Merge clusters with same predicted cell types
merge = false # Default: false; suffixes (.1, .2) added for duplicate labels
# Output file type
outtype = "input" # Options: "input", "rds", "qs", "qs2", "h5ad"
[CellTypeAnnotation.envs]
tool = "direct"
# Cell type assignments (one per cluster, in order)
# Use "-" or "" to keep original cluster name
# Use "NA" to remove cluster from downstream analysis (only without newcol)
cell_types = ["CD4+ T cells", "CD8+ T cells", "-", "B cells"] # Default: []
# Additional annotations (multiple cell type columns)
more_cell_types = { # Dict: {new_column: [cell_types]}
cell_type_broad = ["T cells", "T cells", "NK cells", "B cells"],
cell_type_detailed = ["CD4+ naive", "CD8+ effector", "NK", "B naive"]
}
[CellTypeAnnotation.envs]
tool = "sctype"
# Tissue type (must match tissueType column in database)
sctype_tissue = "Immune system" # Required for sctype
# Database file path (Excel format compatible with ScType)
sctype_db = "/path/to/ScTypeDB_full.xlsx" # Optional: uses default if not specified
[CellTypeAnnotation.envs]
tool = "hitype"
# Tissue type (must match tissueType column in database)
hitype_tissue = "Immune system" # Required for hitype
# Database file path or built-in database name
# Built-in options: "hitypedb_short", "hitypedb_full", "hitypedb_pbmc3k"
hitype_db = "hitypedb_full" # Default: built-in database
[CellTypeAnnotation.envs]
tool = "sccatch"
[CellTypeAnnotation.envs.sccatch_args]
# Species (Human or Mouse)
species = "Human" # Required
# Tissue origin
tissue = "Blood" # Required
# Cancer type (if cancer tissue)
cancer = "Normal" # Default: "Normal"
# Custom marker genes (RDS file or list)
marker = "" # Optional
# Use custom marker instead of database
if_use_custom_marker = false # Default: false
# Additional scCATCH::findmarkergene() arguments
# See: https://rdrr.io/cran/scCATCH/man/findmarkergene.html
[CellTypeAnnotation.envs]
tool = "celltypist"
[CellTypeAnnotation.envs.celltypist_args]
# Model file path (download from https://celltypist.cog.sanger.ac.uk/models/models.json)
model = "Immune_All_Low.pkl" # Required
# Python interpreter where celltypist is installed
python = "python" # Default: "python"
# Majority voting refinement for local subclusters
majority_voting = true # Default: true
# Over-clustering column (for majority voting)
# Set to false to disable over-clustering
over_clustering = "seurat_clusters" # Auto: identity for Seurat, false for h5ad
# Assay for Seurat-to-AnnData conversion
assay = "" # Auto: RNA for h5seurat, default assay for Seurat
Assigns cell types manually to each cluster. Best when you have well-defined marker genes or want complete control over annotations.
Pros:
Cons:
Use cases:
Uses pre-defined cell type markers from ScType database. Annotates based on enrichment of known marker genes in each cluster.
Databases:
Pros:
Cons:
Reference: https://github.com/IanevskiAleksandr/sc-type
Use cases:
Flexible annotation tool compatible with ScType database format. Supports both file-based and built-in databases.
Built-in databases:
hitypedb_short: Compact marker sethitypedb_full: Comprehensive marker sethitypedb_pbmc3k: PBMC-specific markers (from 10X PBMC3k dataset)Pros:
Cons:
Reference: https://github.com/pwwang/hitype
Use cases:
hitypedb_pbmc3k)Identifies cell types by matching cluster marker genes to cell type-specific marker database.
Workflow:
Parameters:
species: Human or Mousetissue: Tissue origin (required)cancer: Cancer type (if applicable)Pros:
Cons:
Reference: https://github.com/ZJUFanLab/scCATCH
Use cases:
Machine learning-based annotation using pre-trained models. Requires Python environment and celltypist2 package.
Models:
Key features:
majority_voting: Refines annotations within local subclustersover_clustering: Over-cluster first, then merge by majority votePros:
Cons:
Reference: https://celltypist.org/
Use cases:
[CellTypeAnnotation]
[CellTypeAnnotation.in]
sobjfile = ["SeuratClustering"]
Result: Tool defaults to "direct" with empty cell_types. Original cluster names are preserved.
[CellTypeAnnotation]
[CellTypeAnnotation.in]
sobjfile = ["SeuratClustering"]
[CellTypeAnnotation.envs]
tool = "direct"
cell_types = ["CD4+ naive", "CD4+ memory", "CD8+ naive", "CD8+ effector", "-", "Regulatory T"]
Result: Clusters 0-3 and 5 get specified labels. Cluster 4 keeps original name (placeholder "-").
[CellTypeAnnotation]
[CellTypeAnnotation.in]
sobjfile = ["SeuratClustering"]
[CellTypeAnnotation.envs]
tool = "sctype"
sctype_tissue = "Immune system"
sctype_db = "/data/databases/ScTypeDB_full.xlsx"
merge = true # Merge clusters with same annotation
Result: Uses full ScType database for immune tissue. Merges clusters with identical annotations.
[CellTypeAnnotation]
[CellTypeAnnotation.in]
sobjfile = ["SeuratClustering"]
[CellTypeAnnotation.envs]
tool = "hitype"
hitype_tissue = "Blood"
hitype_db = "hitypedb_pbmc3k" # Built-in PBMC database
merge = true
Result: Fast PBMC annotation using built-in database optimized for 10X PBMC data.
[CellTypeAnnotation]
[CellTypeAnnotation.in]
sobjfile = ["SeuratClustering"]
[CellTypeAnnotation.envs]
tool = "sccatch"
[CellTypeAnnotation.envs.sccatch_args]
species = "Human"
tissue = "Lung"
cancer = "Lung adenocarcinoma"
Result: Annotates lung adenocarcinoma dataset with cancer-specific cell types.
[CellTypeAnnotation]
[CellTypeAnnotation.in]
sobjfile = ["SeuratClustering"]
[CellTypeAnnotation.envs]
tool = "celltypist"
[CellTypeAnnotation.envs.celltypist_args]
model = "/data/models/Immune_All_Low.pkl"
majority_voting = true
over_clustering = "seurat_clusters" # Use clusters for majority voting
python = "/usr/bin/python3" # Specify Python interpreter
Result: Uses ML model with majority voting refinement for robust annotation.
[CellTypeAnnotation]
[CellTypeAnnotation.in]
sobjfile = ["SeuratClustering"]
[CellTypeAnnotation.envs]
tool = "sctype"
sctype_tissue = "Immune system"
newcol = "celltype_sctype" # Create new column, keep original
Result: Annotated cell types saved in celltype_sctype column. Original seurat_clusters unchanged.
[CellTypeAnnotation]
[CellTypeAnnotation.in]
sobjfile = ["SeuratClustering"]
[CellTypeAnnotation.envs]
tool = "direct"
cell_types = ["CD4+ T", "CD8+ T", "NK", "B", "Monocyte"]
more_cell_types = {
"celltype_broad": ["T cells", "T cells", "NK cells", "B cells", "Monocytes"],
"celltype_subset": ["CD4+ naive", "CD8+ effector", "NK", "B naive", "CD14+ Mono"]
}
Result: Creates three metadata columns: celltype (from cell_types), celltype_broad, celltype_subset.
[CellTypeAnnotation]
[CellTypeAnnotation.in]
sobjfile = ["SeuratClustering"]
[CellTypeAnnotation.envs]
tool = "direct"
cell_types = ["CD4+ T", "CD8+ T", "NA", "B cells"]
Result: Cluster 2 is removed from downstream analysis (NA excludes cluster). Note: Only works without newcol.
[CellTypeAnnotation]
[CellTypeAnnotation.in]
sobjfile = ["seurat_clustering.h5ad"] # H5AD file
[CellTypeAnnotation.envs]
tool = "celltypist"
ident = "clusters" # Required for H5AD: cluster column name
[CellTypeAnnotation.envs.celltypist_args]
model = "Immune_All_Low.pkl"
majority_voting = true
Result: Annotates H5AD file. ident specifies which metadata column contains clusters.
# Step 1: Cluster T cells
[SeuratClusteringOfAllCells]
[TOrBCellSelection]
[SeuratClustering] # Clustering on T cells only
# Step 2: Annotate T cell subsets
[CellTypeAnnotation]
[CellTypeAnnotation.in]
sobjfile = ["SeuratClustering"]
[CellTypeAnnotation.envs]
tool = "direct"
cell_types = ["Naive CD4+", "Memory CD4+", "Effector CD8+", "Tregs", "Progenitor"]
# Use hitype for annotation, keep original clusters
[CellTypeAnnotation]
[CellTypeAnnotation.in]
sobjfile = ["SeuratClustering"]
[CellTypeAnnotation.envs]
tool = "hitype"
hitype_tissue = "Blood"
hitype_db = "hitypedb_pbmc3k"
newcol = "celltype_hitype" # Keep original seurat_clusters
merge = true
# First annotation: ScType
[CellTypeAnnotation]
[CellTypeAnnotation.envs]
tool = "sctype"
sctype_tissue = "Immune system"
newcol = "celltype_sctype"
# Second annotation: CellTypist for comparison
[CellTypeAnnotation2]
# Note: Must define separate process for second annotation
# See immunopipe-config.md for multi-process setup
[CellTypeAnnotation]
[CellTypeAnnotation.in]
sobjfile = ["SeuratClustering"]
[CellTypeAnnotation.envs]
tool = "celltypist"
[CellTypeAnnotation.envs.celltypist_args]
model = "Immune_All_Low.pkl"
majority_voting = true
over_clustering = "seurat_clusters" # Use clustering result
python = "python"
[CellTypeAnnotation]
[CellTypeAnnotation.in]
sobjfile = ["SeuratClustering"]
[CellTypeAnnotation.envs]
tool = "sctype"
sctype_tissue = "Brain" # Brain-specific annotation
sctype_db = "/data/brain_markers.xlsx" # Custom brain marker database
merge = true
SeuratClustering (or process that produces Seurat object with clusters)SeuratClusteringOfAllCells (if using T/B cell selection)SeuratMap2Ref (can combine multiple annotation methods)TOrBCellSelection (T/B-specific annotation)sctype R packagehitype Python packagescCATCH R packagecelltypist2 Python package and Python interpreterScType:
sctype_tissue must be specified (or empty string to use all tissues)sctype_db must be a valid Excel file path (or empty for default)tissueType, cellType, and gene_short columnshitype:
hitype_tissue must be specified (or empty string to use all tissues)hitype_db must be valid file path or built-in namehitypedb_short, hitypedb_full, hitypedb_pbmc3kscCATCH:
species must be "Human" or "Mouse"tissue must be specifiedCellTypist:
model must be a valid .pkl file pathpython must be valid Python interpreter pathDirect:
cell_types list length should match number of clusters (shorter OK, longer not)newcol)ident parameter (cluster column name)cluster2celltype.tsv generated for ScType/hitype/scCATCH/CellTypistouttype specificationCause: sctype_tissue or hitype_tissue doesn't match tissueType column in database.
Solutions:
tissueType column"" to use all rows in databaseCause: scCATCH requires at least 2 clusters.
Solutions:
SeuratClusteringCause: CellTypist requires Python environment with celltypist2 installed.
Solutions:
celltypist_args.python = "/usr/bin/python3"pip install celltypist2python -c "import celltypist; print(celltypist.__version__)"Cause: Model path is incorrect or model not downloaded.
Solutions:
celltypist_args.modelCause: Invalid tool value specified.
Solutions:
direct, sctype, hitype, sccatch, celltypistCause: Multiple annotation processes write to same metadata column.
Solutions:
newcol parameter to create separate columns:[CellTypeAnnotation.envs]
newcol = "celltype_method1"
backup_col to preserve original:backup_col = "original_clusters_id"
Cause: Clusters have similar marker expression patterns.
Solutions:
merge = false to keep cluster-specific labelsCause: Clusters removed by "NA" placeholder or filtering.
Solutions:
cell_types list for "NA" entriesnewcol is not set (NA removal only works without newcol)Cause: ident parameter not specified for H5AD files.
Solutions:
ident = "clusters" (or your cluster column name)Cause: cell_types list length doesn't match cluster count.
Solutions:
cell_types list has correct number of entriesAfter annotation, verify:
Check output file:
# View cluster to cell type mapping
cat .pipen/Immunopipe/CellTypeAnnotation/0/output/cluster2celltype.tsv
Check Seurat object metadata:
library(Seurat)
obj <- readRDS(".pipen/Immunopipe/CellTypeAnnotation/0/output/annotated.rds")
head(obj@meta.data)
# Look for cell type column (seurat_clusters or newcol name)
Validate annotation quality:
# Check distribution of cell types
table(Idents(obj))
# Visualize UMAP with cell types
DimPlot(obj, group.by = "celltype_hitype", label = TRUE, repel = TRUE)
Compare multiple methods:
# Compare ScType vs hitype annotations
table(obj$celltype_sctype, obj$celltype_hitype)
cluster2celltype.tsv)newcol or backup_colSeuratClustering: Clustering before annotationSeuratMap2Ref: Reference-based annotation (alternative)ClusterMarkers: Find markers for each cell typeSeuratClusterStats: Visualize annotated clusters