1 Overview

This quick start guide demonstrates the essential steps for evaluating cell type annotations using scTypeEval. For a comprehensive tutorial, see the main vignette.

library(scTypeEval)

2 Minimal Workflow

2.1 From a Count Matrix

library(Matrix)

# Generate example data
set.seed(123)
counts <- Matrix(rpois(50000, 5), nrow=500, ncol=100, sparse=TRUE)
rownames(counts) <- paste0("Gene", seq_len(500))
colnames(counts) <- paste0("Cell", seq_len(100))

metadata <- data.frame(
  celltype = rep(c("TypeA", "TypeB", "TypeC", "TypeD"), each=25),
  sample = rep(paste0("S", seq_len(5)), times=20),
  row.names = colnames(counts)
)

# Create object
sceval <- create_scTypeEval(matrix=counts, metadata=metadata)

# Process data
sceval <- run_processing_data(
  sceval,
  ident = "celltype",
  sample = "sample",
  min_samples = 3,
  min_cells = 5
)
#> # Processing data for single-cell ...
#>    Transforming and filtering count matrix...
#>    Normalizing count matrix via Log1p...
#> # Processing data for pseudobulk ...
#>    Transforming and filtering count matrix...
#>    Normalizing count matrix via Log1p...

# Identify features
sceval <- run_hvg(sceval,
                  var_method = "basic",
                  ngenes = 1000)
#> Not using black gene list
#> Computing HVG...

# Run PCA
sceval <- run_pca(sceval, ndim = 20)
#> 
#> Using HVG gene list.
#> Not using black gene list
#> # Computing PCA data for single-cell ...
#>    Filtering gene list...
#>    Filtering empty rows and cols...
#>    Computing PCA space...
#>    > Returning 20 dimensions for PCA
#> # Computing PCA data for pseudobulk ...
#>    Filtering gene list...
#>    Filtering empty rows and cols...
#>    Computing PCA space...
#>    > Returning 19 dimensions for PCA

# Compute dissimilarity
sceval <- run_dissimilarity(
  sceval,
  method = "Pseudobulk:Euclidean",
  reduction = TRUE
)
#>    Running distance for euclidean...

# Get consistency
results <- get_consistency(
  sceval,
  dissimilarity_slot = "Pseudobulk:Euclidean",
  consistency_metric = "silhouette"
)
#> Computing internal validation metrics for Pseudobulk:Euclidean ...
print(results)
#>       celltype      measure consistency_metric dissimilarity_method    ident
#> TypeA    TypeA  0.009929989         silhouette Pseudobulk:Euclidean celltype
#> TypeB    TypeB -0.011988536         silhouette Pseudobulk:Euclidean celltype
#> TypeC    TypeC -0.005448364         silhouette Pseudobulk:Euclidean celltype
#> TypeD    TypeD -0.020708784         silhouette Pseudobulk:Euclidean celltype

2.2 From a Seurat Object

library(Seurat)

# Create Seurat object with example data generated earlier
seurat_obj <- Seurat::CreateSeuratObject(
  counts = counts,
  meta.data = metadata
)

sceval_seurat <- create_scTypeEval(seurat_obj)

# Continue with standard workflow

2.3 From a SingleCellExperiment Object

library(SingleCellExperiment)

# Create SCE object with example data generated earlier
sce <- SingleCellExperiment::SingleCellExperiment(
  assays = list(counts = counts),
  colData = metadata
)

sceval_sce <- create_scTypeEval(sce)

# Continue with workflow as above

3 Common Use Cases

3.1 Compare Multiple Dissimilarity Methods

# Compute different dissimilarity methods
sceval <- run_dissimilarity(
  sceval,
  method = "Pseudobulk:Euclidean",
  reduction = TRUE
)
#>    Running distance for euclidean...
sceval <- run_dissimilarity(
  sceval,
  method = "Pseudobulk:Cosine",
  reduction = TRUE
)
#>    Running distance for cosine...
sceval <- run_dissimilarity(
  sceval,
  method = "WasserStein",
  reduction = TRUE
)
#> Splitting matrices...
#> Computing pairwise WasserStein distance...

# Compare consistency across methods
dissimilarity_methods <- c("Pseudobulk:Euclidean",
                           "Pseudobulk:Cosine",
                           "WasserStein")
results_df <- 
  get_consistency(
    sceval,
    dissimilarity_slot = dissimilarity_methods, # compute for multiple dissimilarities
    consistency_metric = "silhouette"
  )
#> Computing internal validation metrics for Pseudobulk:Euclidean ...
#> Computing internal validation metrics for Pseudobulk:Cosine ...
#> Computing internal validation metrics for WasserStein ...

results_df
#>        celltype      measure consistency_metric dissimilarity_method    ident
#> TypeA     TypeA  0.009929989         silhouette Pseudobulk:Euclidean celltype
#> TypeB     TypeB -0.011988536         silhouette Pseudobulk:Euclidean celltype
#> TypeC     TypeC -0.005448364         silhouette Pseudobulk:Euclidean celltype
#> TypeD     TypeD -0.020708784         silhouette Pseudobulk:Euclidean celltype
#> TypeA1    TypeA -0.003214443         silhouette    Pseudobulk:Cosine celltype
#> TypeB1    TypeB -0.002765134         silhouette    Pseudobulk:Cosine celltype
#> TypeC1    TypeC -0.013348235         silhouette    Pseudobulk:Cosine celltype
#> TypeD1    TypeD -0.022767009         silhouette    Pseudobulk:Cosine celltype
#> TypeA2    TypeA  0.034467516         silhouette          WasserStein celltype
#> TypeB2    TypeB -0.026486930         silhouette          WasserStein celltype
#> TypeC2    TypeC -0.026580578         silhouette          WasserStein celltype
#> TypeD2    TypeD -0.043527673         silhouette          WasserStein celltype

3.2 Evaluate Multiple Consistency Metrics

# Compute multiple consistency metrics
consistency_metrics <- c("silhouette",
                         "NeighborhoodPurity",
                         "Average_similarity")

all_metrics <- 
  get_consistency(
    sceval,
    dissimilarity_slot = "Pseudobulk:Euclidean",
    consistency_metric = consistency_metrics
  )
#> Computing internal validation metrics for Pseudobulk:Euclidean ...

all_metrics
#>        celltype      measure consistency_metric dissimilarity_method    ident
#> TypeA     TypeA  0.009929989         silhouette Pseudobulk:Euclidean celltype
#> TypeB     TypeB -0.011988536         silhouette Pseudobulk:Euclidean celltype
#> TypeC     TypeC -0.005448364         silhouette Pseudobulk:Euclidean celltype
#> TypeD     TypeD -0.020708784         silhouette Pseudobulk:Euclidean celltype
#> TypeA1    TypeA  0.320000000 NeighborhoodPurity Pseudobulk:Euclidean celltype
#> TypeB1    TypeB  0.240000000 NeighborhoodPurity Pseudobulk:Euclidean celltype
#> TypeC1    TypeC  0.240000000 NeighborhoodPurity Pseudobulk:Euclidean celltype
#> TypeD1    TypeD  0.200000000 NeighborhoodPurity Pseudobulk:Euclidean celltype
#> TypeA2    TypeA  0.504617271 Average_similarity Pseudobulk:Euclidean celltype
#> TypeB2    TypeB  0.500755570 Average_similarity Pseudobulk:Euclidean celltype
#> TypeC2    TypeC  0.501285885 Average_similarity Pseudobulk:Euclidean celltype
#> TypeD2    TypeD  0.498308342 Average_similarity Pseudobulk:Euclidean celltype

3.3 Visualize Results

# Heatmap of dissimilarities
plot_heatmap(
  sceval,
  dissimilarity_slot = "Pseudobulk:Euclidean",
  sort_consistency = "silhouette"
)
#> Computing consistency metric for silhouette.
#> Consistency computed.


# Pseudobulk PCA per sample & cell type
plot_pca(
  sceval,
  reduction_slot = "pseudobulk"
)

3.4 Using Marker Genes Instead of HVGs

# Identify cell type markers
sceval <- run_gene_markers(
  sceval,
  method = "scran.findMarkers",
  ngenes_celltype = 50
)
#> Not using black gene list
#> Computing cell type markers for celltype...

# Use markers for dissimilarity calculation
sceval <- run_dissimilarity(
  sceval,
  method = "Pseudobulk:Euclidean",
  gene_list = "scran.findMarkers", # gene list recently added
  reduction = FALSE
)
#> 
#> Using scran.findMarkers gene list.
#> Not using black gene list
#>    Filtering gene list...
#>    Filtering empty rows and cols...
#>    Running distance for euclidean...

3.5 Focus on Specific Gene Sets

# Add custom gene list
immune_genes <- c("CD3D", "CD4", "CD8A", "CD19", "CD14", "NCAM1")
sceval <- add_gene_list(
  sceval,
  gene_list = list("immune_markers" = immune_genes) # add a named list
)

# Run analysis on custom genes
sceval <- run_dissimilarity(
  sceval,
  method = "Pseudobulk:Euclidean",
  gene_list = "immune_markers" # name of the list to use
)
#>    Running distance for euclidean...

4 Interpreting Results

4.1 What Low Scores Mean

Low consistency scores may indicate:

  • Ambiguous cell type boundaries between related types
  • Heterogeneous populations needing refinement
  • Annotation inconsistencies across samples

4.2 Next Steps for Low-Scoring Cell Types

  1. Visualize using plot_heatmap() or plot_pca() to identify problematic samples
  2. Investigate biological differences (e.g., disease vs. healthy)
  3. Refine annotations by splitting or merging cell types

5 Available Methods and Metrics

5.1 Dissimilarity Methods

  • Pseudobulk:Euclidean - Euclidean distance on pseudobulk profiles
  • Pseudobulk:Cosine - Cosine distance on pseudobulk profiles
  • Pseudobulk:Pearson - Pearson correlation distance on pseudobulk profiles
  • WasserStein - Wasserstein distance between cell distributions
  • recip_classif:Match - Reciprocal classification matching
  • recip_classif:Score - Reciprocal classification scoring

5.2 Consistency Metrics

  • silhouette - Standard silhouette coefficient
  • 2label_silhouette - Two-label silhouette variant
  • NeighborhoodPurity - K-nearest neighbor purity
  • ward_PropMatch - Ward clustering proportion match
  • Orbital_medoid - Medoid-based orbital metric
  • Average_similarity - Average within-group similarity

6 Tips and Best Practices

  1. Always use multiple samples (minimum 3-5 per cell type)
  2. Compare different methods - no single method is perfect
  3. Use PCA for speed - similar results, much faster
  4. Start with HVGs - then try marker genes if needed
  5. Check sample sizes - ensure adequate cells per type per sample
  6. Interpret in context - consider biological heterogeneity

7 Getting Help

8 Session Info

sessionInfo()
#> R version 4.6.1 (2026-06-24)
#> Platform: x86_64-pc-linux-gnu
#> Running under: Ubuntu 24.04.5 LTS
#> 
#> Matrix products: default
#> BLAS:   /home/biocbuild/bbs-3.24-bioc/R/lib/libRblas.so 
#> LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.12.0  LAPACK version 3.12.0
#> 
#> locale:
#>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=en_GB              LC_COLLATE=C              
#>  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
#>  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
#>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
#> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
#> 
#> time zone: America/New_York
#> tzcode source: system (glibc)
#> 
#> attached base packages:
#> [1] stats4    stats     graphics  grDevices utils     datasets  methods  
#> [8] base     
#> 
#> other attached packages:
#>  [1] SingleCellExperiment_1.36.0 SummarizedExperiment_1.44.0
#>  [3] Biobase_2.74.0              GenomicRanges_1.66.0       
#>  [5] Seqinfo_1.4.0               IRanges_2.48.0             
#>  [7] S4Vectors_0.52.0            BiocGenerics_0.60.0        
#>  [9] generics_0.1.4              MatrixGenerics_1.26.0      
#> [11] matrixStats_1.5.0           Seurat_6.0.0               
#> [13] SeuratObject_5.4.0          sp_2.2-4                   
#> [15] Matrix_1.7-6                scTypeEval_1.2.0           
#> [17] BiocStyle_2.42.0           
#> 
#> loaded via a namespace (and not attached):
#>   [1] pbapply_1.7-5       gridExtra_2.3.1     rlang_1.3.0        
#>   [4] magrittr_2.0.5      RcppAnnoy_0.0.23    otel_0.3.0         
#>   [7] ggridges_0.5.7      compiler_4.6.1      png_0.1-9          
#>  [10] vctrs_0.7.3         reshape2_1.4.5      stringr_1.6.0      
#>  [13] pkgconfig_2.0.3     fastmap_1.2.0       magick_2.9.1       
#>  [16] XVector_0.54.0      scuttle_1.24.0      labeling_0.4.3     
#>  [19] rmarkdown_2.32      tinytex_0.61        xfun_0.62          
#>  [22] bluster_1.24.0      beachmat_2.30.0     cachem_1.1.0       
#>  [25] jsonlite_2.0.0      DelayedArray_0.40.0 BiocParallel_1.48.0
#>  [28] irlba_2.4.1         parallel_4.6.1      cluster_2.1.8.3    
#>  [31] R6_2.6.1            ica_1.0-3           bslib_0.12.0       
#>  [34] stringi_1.8.9       RColorBrewer_1.1-3  limma_4.0.0        
#>  [37] parallelly_1.50.0   jquerylib_0.1.4     scattermore_1.2    
#>  [40] Rcpp_1.1.2          bookdown_0.48       knitr_1.52         
#>  [43] future.apply_1.21.0 sctransform_0.4.3   igraph_2.3.4       
#>  [46] tidyselect_1.2.1    abind_1.4-8         dichromat_2.0-1    
#>  [49] yaml_2.3.12         codetools_0.2-20    listenv_1.1.0      
#>  [52] lattice_0.23-1      tibble_3.3.1        plyr_1.8.9         
#>  [55] withr_3.0.3         S7_1.0.0            evaluate_1.0.5     
#>  [58] Rtsne_0.17          future_1.82.0       fastDummies_1.7.6  
#>  [61] pillar_1.11.1       BiocManager_1.30.27 KernSmooth_2.23-27 
#>  [64] RcppHNSW_0.7.0      ggplot2_4.0.4       scales_1.4.0       
#>  [67] globals_0.20.0      glue_1.8.1          metapod_1.22.0     
#>  [70] tools_4.6.1         data.table_1.18.6.1 BiocNeighbors_2.8.0
#>  [73] ScaledMatrix_1.22.0 RSpectra_0.16-2     RANN_2.6.3         
#>  [76] scran_1.42.0        dotCall64_1.2       cowplot_1.2.0      
#>  [79] grid_4.6.1          edgeR_5.0.0         patchwork_1.3.2    
#>  [82] BiocSingular_1.30.0 rsvd_2.0.0          cli_3.6.6          
#>  [85] spam_2.11-4         S4Arrays_1.14.0     dplyr_1.2.1        
#>  [88] uwot_0.2.5          gtable_0.3.6        pls_2.9-0          
#>  [91] sass_0.5.0          digest_0.6.39       progressr_1.1.0    
#>  [94] dqrng_0.4.1         SparseArray_1.14.0  ggrepel_0.9.8      
#>  [97] farver_2.1.2        htmltools_0.5.9     lifecycle_1.0.5    
#> [100] httr_1.4.9          statmod_1.5.2       transport_0.15-4   
#> [103] MASS_7.3-66