Skip to contents

Annotate single cells using scmap.

Usage

RunScmap(
  srt_query,
  srt_ref,
  ref_group = NULL,
  query_assay = "RNA",
  ref_assay = "RNA",
  method = "scmapCluster",
  nfeatures = 500,
  threshold = 0.5,
  k = 10
)

Arguments

srt_query

An object of class Seurat to be annotated with cell types.

srt_ref

An object of class Seurat storing the reference cells.

ref_group

A character vector specifying the column name in the srt_ref metadata that represents the cell grouping.

query_assay

A character vector specifying the assay to be used for the query data. Default is the default assay of the srt_query object.

ref_assay

A character vector specifying the assay to be used for the reference data. Default is the default assay of the srt_ref object.

method

The method to be used for scmap analysis. Can be any of "scmapCluster" or "scmapCell". Default is "scmapCluster".

nfeatures

The number of top features to be selected. Default is 500.

threshold

The threshold value on similarity to determine if a cell is assigned to a cluster. This should be a value between 0 and 1. Default is 0.5.

k

Number of clusters per group for k-means clustering when method is "scmapCell". Default is 10.

Examples

data(panc8_sub)
panc8_sub <- standard_scop(panc8_sub)
#>  [2026-03-20 09:39:29] Start standard scop workflow...
#>  [2026-03-20 09:39:29] Checking a list of <Seurat>...
#> ! [2026-03-20 09:39:29] Data 1/1 of the `srt_list` is "unknown"
#>  [2026-03-20 09:39:29] Perform `NormalizeData()` with `normalization.method = 'LogNormalize'` on 1/1 of `srt_list`...
#>  [2026-03-20 09:39:32] Perform `Seurat::FindVariableFeatures()` on 1/1 of `srt_list`...
#>  [2026-03-20 09:39:33] Use the separate HVF from `srt_list`
#>  [2026-03-20 09:39:33] Number of available HVF: 2000
#>  [2026-03-20 09:39:33] Finished check
#>  [2026-03-20 09:39:33] Perform `Seurat::ScaleData()`
#>  [2026-03-20 09:39:34] Perform pca linear dimension reduction
#>  [2026-03-20 09:39:35] Perform `Seurat::FindClusters()` with `cluster_algorithm = 'louvain'` and `cluster_resolution = 0.6`
#>  [2026-03-20 09:39:35] Reorder clusters...
#>  [2026-03-20 09:39:35] Perform umap nonlinear dimension reduction
#>  [2026-03-20 09:39:35] Perform umap nonlinear dimension reduction using Standardpca (1:50)
#>  [2026-03-20 09:39:40] Perform umap nonlinear dimension reduction using Standardpca (1:50)
#>  [2026-03-20 09:39:46] Run scop standard workflow completed

genenames <- make.unique(
  thisutils::capitalize(
    rownames(panc8_sub),
    force_tolower = TRUE
  )
)
names(genenames) <- rownames(panc8_sub)
panc8_sub <- RenameFeatures(
  panc8_sub,
  newnames = genenames
)
#>  [2026-03-20 09:39:46] Rename features for the assay: RNA
panc8_sub <- CheckDataMerge(
  panc8_sub,
  batch = "tech"
)[["srt_merge"]]
#>  [2026-03-20 09:39:46] Split `srt_merge` into `srt_list` by "tech"
#>  [2026-03-20 09:39:47] Checking a list of <Seurat>...
#>  [2026-03-20 09:39:47] Data 1/5 of the `srt_list` has been log-normalized
#>  [2026-03-20 09:39:47] Perform `Seurat::FindVariableFeatures()` on 1/5 of `srt_list`...
#>  [2026-03-20 09:39:48] Data 2/5 of the `srt_list` has been log-normalized
#>  [2026-03-20 09:39:48] Perform `Seurat::FindVariableFeatures()` on 2/5 of `srt_list`...
#>  [2026-03-20 09:39:48] Data 3/5 of the `srt_list` has been log-normalized
#>  [2026-03-20 09:39:48] Perform `Seurat::FindVariableFeatures()` on 3/5 of `srt_list`...
#>  [2026-03-20 09:39:49] Data 4/5 of the `srt_list` has been log-normalized
#>  [2026-03-20 09:39:49] Perform `Seurat::FindVariableFeatures()` on 4/5 of `srt_list`...
#>  [2026-03-20 09:39:49] Data 5/5 of the `srt_list` has been log-normalized
#>  [2026-03-20 09:39:50] Perform `Seurat::FindVariableFeatures()` on 5/5 of `srt_list`...
#>  [2026-03-20 09:39:50] Use the separate HVF from `srt_list`
#>  [2026-03-20 09:39:50] Number of available HVF: 2000
#>  [2026-03-20 09:39:51] Finished check

data(pancreas_sub)
pancreas_sub <- standard_scop(pancreas_sub)
#>  [2026-03-20 09:39:53] Start standard scop workflow...
#>  [2026-03-20 09:39:54] Checking a list of <Seurat>...
#> ! [2026-03-20 09:39:54] Data 1/1 of the `srt_list` is "unknown"
#>  [2026-03-20 09:39:54] Perform `NormalizeData()` with `normalization.method = 'LogNormalize'` on 1/1 of `srt_list`...
#>  [2026-03-20 09:39:56] Perform `Seurat::FindVariableFeatures()` on 1/1 of `srt_list`...
#>  [2026-03-20 09:39:56] Use the separate HVF from `srt_list`
#>  [2026-03-20 09:39:56] Number of available HVF: 2000
#>  [2026-03-20 09:39:57] Finished check
#>  [2026-03-20 09:39:57] Perform `Seurat::ScaleData()`
#>  [2026-03-20 09:39:57] Perform pca linear dimension reduction
#>  [2026-03-20 09:39:58] Perform `Seurat::FindClusters()` with `cluster_algorithm = 'louvain'` and `cluster_resolution = 0.6`
#>  [2026-03-20 09:39:58] Reorder clusters...
#>  [2026-03-20 09:39:58] Perform umap nonlinear dimension reduction
#>  [2026-03-20 09:39:58] Perform umap nonlinear dimension reduction using Standardpca (1:50)
#>  [2026-03-20 09:40:03] Perform umap nonlinear dimension reduction using Standardpca (1:50)
#>  [2026-03-20 09:40:08] Run scop standard workflow completed
pancreas_sub <- RunScmap(
  srt_query = pancreas_sub,
  srt_ref = panc8_sub,
  ref_group = "celltype",
  method = "scmapCluster"
)
#>  [2026-03-20 09:40:36] Data type is log-normalized
#>  [2026-03-20 09:40:36] Detected `srt_query` data type: "log_normalized_counts"
#>  [2026-03-20 09:40:38] Data type is log-normalized
#>  [2026-03-20 09:40:38] Detected `srt_ref` data type: "log_normalized_counts"
#>  [2026-03-20 09:40:40] Perform selectFeatures
#>  [2026-03-20 09:40:40] Perform indexCluster
#>  [2026-03-20 09:40:40] Perform scmapCluster
CellDimPlot(
  pancreas_sub,
  group.by = "scmap_annotation"
)


pancreas_sub <- RunScmap(
  srt_query = pancreas_sub,
  srt_ref = panc8_sub,
  ref_group = "celltype",
  method = "scmapCell"
)
#>  [2026-03-20 09:40:41] Data type is log-normalized
#>  [2026-03-20 09:40:41] Detected `srt_query` data type: "log_normalized_counts"
#>  [2026-03-20 09:40:43] Data type is log-normalized
#>  [2026-03-20 09:40:43] Detected `srt_ref` data type: "log_normalized_counts"
#>  [2026-03-20 09:40:45] Perform selectFeatures
#>  [2026-03-20 09:40:45] Perform indexCell
#>  [2026-03-20 09:40:46] Perform scmapCell
#>  [2026-03-20 09:40:47] Perform scmapCell2Cluster
CellDimPlot(
  pancreas_sub,
  group.by = "scmap_annotation"
)