This function performs cell scoring on a Seurat object. It calculates scores for a given set of features and adds the scores as metadata to the Seurat object.
Usage
CellScoring(
srt,
features = NULL,
layer = "data",
assay = NULL,
split.by = NULL,
IDtype = "symbol",
species = "Homo_sapiens",
db = "GO_BP",
termnames = NULL,
db_update = FALSE,
db_version = "latest",
convert_species = TRUE,
Ensembl_version = 103,
mirror = NULL,
minGSSize = 10,
maxGSSize = 500,
method = "Seurat",
classification = TRUE,
name = "",
new_assay = FALSE,
BPPARAM = BiocParallel::bpparam(),
seed = 11,
...
)
Arguments
- srt
A Seurat object
- features
A named list of feature lists for scoring. If NULLL,
db
will be used to create features sets.- layer
The layer of the Seurat object to use for scoring. Defaults to "data".
- assay
The assay of the Seurat object to use for scoring. Defaults to NULL, in which case the default assay of the object is used.
- split.by
A cell metadata variable used for splitting the Seurat object into subsets and performing scoring on each subset. Defaults to NULL.
- IDtype
A character vector specifying the type of gene IDs in the
srt
object orgeneID
argument. This argument is used to convert the gene IDs to a different type ifIDtype
is different fromresult_IDtype
.- species
A character vector specifying the species for which the analysis is performed.
- db
A character vector specifying the name of the database to be used for enrichment analysis.
- termnames
A vector of term names to be used from the database. Defaults to NULL, in which case all features from the database are used.
- db_update
A logical value indicating whether the gene annotation databases should be forcefully updated. If set to FALSE, the function will attempt to load the cached databases instead. Default is FALSE.
- db_version
A character vector specifying the version of the database to be used. This argument is ignored if
db_update
isTRUE
. Default is "latest".- convert_species
A logical value indicating whether to use a species-converted database when the annotation is missing for the specified species. The default value is TRUE.
- Ensembl_version
Ensembl database version. If NULL, use the current release version.
- mirror
Specify an Ensembl mirror to connect to. The valid options here are 'www', 'uswest', 'useast', 'asia'.
- minGSSize
A numeric value specifying the minimum size of a gene set to be considered in the enrichment analysis.
- maxGSSize
A numeric value specifying the maximum size of a gene set to be considered in the enrichment analysis.
- method
The method to use for scoring. Can be "Seurat", "AUCell", or "UCell". Defaults to "Seurat".
- classification
Whether to perform classification based on the scores. Defaults to TRUE.
- name
The name of the assay to store the scores in. Only used if new_assay is TRUE. Defaults to an empty string.
- new_assay
Whether to create a new assay for storing the scores. Defaults to FALSE.
- BPPARAM
The BiocParallel parameter object. Defaults to
BiocParallel::bpparam()
.- seed
The random seed for reproducibility. Defaults to 11.
- ...
Additional arguments to be passed to the scoring methods.
Examples
data(pancreas_sub)
ccgenes <- CC_GenePrefetch("Mus_musculus")
#> ℹ [2025-07-26 06:33:14] Prefetching cell cycle genes forMus_musculus...
#> ℹ [2025-07-26 06:33:14] Connect to the Ensembl archives...
#> ℹ [2025-07-26 06:33:14] Using the 103 version of biomart...
#> ℹ [2025-07-26 06:33:14] Connecting to the biomart...
#> ℹ [2025-07-26 06:34:14] Error in `req_perform()`:
#> ℹ [2025-07-26 06:34:14] ! Failed to perform HTTP request.
#> ℹ [2025-07-26 06:34:14] Caused by error in `curl::curl_fetch_memory()`:
#> ℹ [2025-07-26 06:34:14] ! Timeout was reached [feb2021.archive.ensembl.org]:
#> ℹ [2025-07-26 06:34:14] Operation timed out after 60002 milliseconds with 0 bytes received
#> ℹ [2025-07-26 06:34:14]
#> ℹ [2025-07-26 06:34:14] Get errors when connecting with ensembl mart...
#> ℹ [2025-07-26 06:34:15] Retrying...
#> ℹ [2025-07-26 06:35:15] Error in `req_perform()`:
#> ℹ [2025-07-26 06:35:15] ! Failed to perform HTTP request.
#> ℹ [2025-07-26 06:35:15] Caused by error in `curl::curl_fetch_memory()`:
#> ℹ [2025-07-26 06:35:15] ! Timeout was reached [feb2021.archive.ensembl.org]:
#> ℹ [2025-07-26 06:35:15] Operation timed out after 60002 milliseconds with 0 bytes received
#> ℹ [2025-07-26 06:35:15]
#> ℹ [2025-07-26 06:35:15] Get errors when connecting with ensembl mart...
#> ℹ [2025-07-26 06:35:16] Retrying...
#> ℹ [2025-07-26 06:36:16] Error in `req_perform()`:
#> ℹ [2025-07-26 06:36:16] ! Failed to perform HTTP request.
#> ℹ [2025-07-26 06:36:16] Caused by error in `curl::curl_fetch_memory()`:
#> ℹ [2025-07-26 06:36:16] ! Timeout was reached [feb2021.archive.ensembl.org]:
#> ℹ [2025-07-26 06:36:16] Operation timed out after 60002 milliseconds with 0 bytes received
#> ℹ [2025-07-26 06:36:16]
#> ℹ [2025-07-26 06:36:16] Get errors when connecting with ensembl mart...
#> ℹ [2025-07-26 06:36:17] Retrying...
#> ℹ [2025-07-26 06:37:17] Error in `req_perform()`:
#> ℹ [2025-07-26 06:37:17] ! Failed to perform HTTP request.
#> ℹ [2025-07-26 06:37:17] Caused by error in `curl::curl_fetch_memory()`:
#> ℹ [2025-07-26 06:37:17] ! Timeout was reached [feb2021.archive.ensembl.org]:
#> ℹ [2025-07-26 06:37:17] Operation timed out after 60001 milliseconds with 0 bytes received
#> ℹ [2025-07-26 06:37:17]
#> ℹ [2025-07-26 06:37:17] Get errors when connecting with ensembl mart...
#> ℹ [2025-07-26 06:37:18] Retrying...
#> ℹ [2025-07-26 06:37:19] Error: Your query has been redirected to http://status.ensembl.org indicating this Ensembl service is currently unavailable.
#> ℹ [2025-07-26 06:37:19] Look at ?useEnsembl for details on how to try a mirror site.
#> ℹ [2025-07-26 06:37:19]
#> ℹ [2025-07-26 06:37:19] Get errors when connecting with ensembl mart...
#> Error in log_message(out, message_type = "error"): Error: Your query has been redirected to http://status.ensembl.org
#> indicating this Ensembl service is currently unavailable. Look at ?useEnsembl
#> for details on how to try a mirror site.
pancreas_sub <- CellScoring(
srt = pancreas_sub,
features = list(S = ccgenes$S, G2M = ccgenes$G2M),
method = "Seurat",
name = "CC"
)
#> Error: object 'ccgenes' not found
CellDimPlot(pancreas_sub, "CC_classification")
#> Error in log_message(paste0(i, " is not in the meta.data of srt object."), message_type = "error"): CC_classification is not in the meta.data of srt object.
FeatureDimPlot(pancreas_sub, "CC_G2M")
#> ! [2025-07-26 06:37:25] CC_G2M are not in the features of srt.
#> Error in log_message("There are no valid features present.", message_type = "error"): There are no valid features present.
if (FALSE) { # \dontrun{
data(panc8_sub)
panc8_sub <- integration_scop(
panc8_sub,
batch = "tech",
integration_method = "Seurat"
)
CellDimPlot(
panc8_sub,
group.by = c("tech", "celltype")
)
panc8_sub <- CellScoring(
srt = panc8_sub,
layer = "data",
assay = "RNA",
db = "GO_BP",
species = "Homo_sapiens",
minGSSize = 10,
maxGSSize = 100,
method = "Seurat",
name = "GO",
new_assay = TRUE
)
panc8_sub <- integration_scop(
panc8_sub,
assay = "GO",
batch = "tech",
integration_method = "Seurat"
)
CellDimPlot(
panc8_sub,
group.by = c("tech", "celltype")
)
pancreas_sub <- CellScoring(
srt = pancreas_sub,
layer = "data",
assay = "RNA",
db = "GO_BP",
species = "Mus_musculus",
termnames = panc8_sub[["GO"]]@meta.features[, "termnames"],
method = "Seurat",
name = "GO",
new_assay = TRUE
)
pancreas_sub <- standard_scop(
pancreas_sub,
assay = "GO"
)
CellDimPlot(pancreas_sub, "SubCellType")
pancreas_sub[["tech"]] <- "Mouse"
panc_merge <- integration_scop(
srt_list = list(panc8_sub, pancreas_sub),
assay = "GO",
batch = "tech", integration_method = "Seurat"
)
CellDimPlot(
srt = panc_merge,
group.by = c("tech", "celltype", "SubCellType", "Phase")
)
genenames <- make.unique(
thisutils::capitalize(
rownames(panc8_sub[["RNA"]])
),
force_tolower = TRUE
)
names(genenames) <- rownames(panc8_sub)
panc8_sub <- RenameFeatures(
srt = panc8_sub,
newnames = genenames,
assay = "RNA"
)
head(rownames(panc8_sub))
panc_merge <- integration_scop(
srt_list = list(panc8_sub, pancreas_sub),
assay = "RNA",
batch = "tech", integration_method = "Seurat"
)
CellDimPlot(
srt = panc_merge,
group.by = c("tech", "celltype", "SubCellType", "Phase")
)
} # }