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. Defaults to the default assay of the `srt_query` object.

ref_assay

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

method

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

nfeatures

The number of top features to be selected. The default value 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. The default value is 0.5.

k

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

Examples

data("panc8_sub")
# Simply convert genes from human to mouse and preprocess the data
genenames <- make.unique(capitalize(rownames(panc8_sub), force_tolower = TRUE))
#> Error in capitalize(rownames(panc8_sub), force_tolower = TRUE): could not find function "capitalize"
panc8_sub <- RenameFeatures(panc8_sub, newnames = genenames)
#> Error: object 'genenames' not found
panc8_sub <- check_srtMerge(panc8_sub, batch = "tech")[["srtMerge"]]
#> Warning: Failed to check Seurat version compatibility: 'list' object cannot be coerced to type 'double'
#> [2025-09-08 16:17:13.510224] Spliting srtMerge into srtList by column tech... ...
#> [2025-09-08 16:17:13.690797] Checking srtList... ...
#> Warning: Failed to check Seurat version compatibility: 'list' object cannot be coerced to type 'double'
#> Warning: The following arguments are not used: drop
#> Warning: The following arguments are not used: drop
#> Error in as.vector(data): no method for coercing this S4 class to a vector

# Annotation
data("pancreas_sub")
pancreas_sub <- Standard_SCP(pancreas_sub)
#> [2025-09-08 16:17:14.912244] Start Standard_SCP
#> [2025-09-08 16:17:14.912441] Checking srtList... ...
#> Warning: Failed to check Seurat version compatibility: 'list' object cannot be coerced to type 'double'
#> Warning: The following arguments are not used: drop
#> Warning: The following arguments are not used: drop
#> Error in as.vector(data): no method for coercing this S4 class to a vector
pancreas_sub <- RunScmap(
  srt_query = pancreas_sub, srt_ref = panc8_sub,
  ref_group = "celltype", method = "scmapCluster"
)
#> Error in check_R("scmap"): could not find function "check_R"
CellDimPlot(pancreas_sub, group.by = "scmap_annotation")
#> Error in CellDimPlot(pancreas_sub, group.by = "scmap_annotation"): scmap_annotation is not in the meta.data of srt object.

pancreas_sub <- RunScmap(
  srt_query = pancreas_sub, srt_ref = panc8_sub,
  ref_group = "celltype", method = "scmapCell"
)
#> Error in check_R("scmap"): could not find function "check_R"
CellDimPlot(pancreas_sub, group.by = "scmap_annotation")
#> Error in CellDimPlot(pancreas_sub, group.by = "scmap_annotation"): scmap_annotation is not in the meta.data of srt object.