Run scMalignantFinder malignant cell identification
Source:R/RunscMalignantFinder.R
RunscMalignantFinder.RdRun the Python package scMalignantFinder on a Seurat or AnnData object and
append malignant-cell predictions to Seurat metadata. The pretrained model
files are not bundled with scop; provide a directory containing
model.joblib and ordered_feature.tsv through pretrain_dir.
Usage
RunscMalignantFinder(
srt = NULL,
adata = NULL,
h5ad = NULL,
assay = "RNA",
layer = "counts",
cells = NULL,
pretrain_dir = NULL,
train_h5ad_path = NULL,
feature_path = NULL,
model_method = c("LogisticRegression", "RandomForest", "XGBoost"),
norm_type = NULL,
use_raw = FALSE,
n_thread = 1,
prefix = "",
return_seurat = !is.null(srt),
verbose = TRUE
)Arguments
- srt
A Seurat object.
- adata
Optional Python AnnData object.
- h5ad
Optional path to an
.h5adfile.- assay
Assay used when
srtis supplied. Default is"RNA".- layer
Layer used when
srtis supplied. Default is"counts".- cells
Optional cells to run. If supplied with
srt, results are appended to these cells and other cells receiveNA.- pretrain_dir
Directory containing pretrained
scMalignantFindermodel files:model.joblibandordered_feature.tsv.- train_h5ad_path
Optional training
.h5adfile used when training a model from scratch.- feature_path
Optional feature file used when training from scratch.
- model_method
Model used when training from scratch. One of
"LogisticRegression","RandomForest", or"XGBoost".- norm_type
Passed to
scMalignantFinder. UseTRUEfor raw counts that should be library-size normalized; useFALSEfor already normalized input. IfNULL, defaults toTRUEonly for Seurat counts input.- use_raw
Whether to use
adata.raw.Xwhen available.- n_thread
Number of threads used by
scMalignantFinder.- prefix
Optional prefix for output metadata columns. Default preserves the original
scMalignantFindercolumn names.- return_seurat
Whether to return a Seurat object when
srtis supplied. IfFALSE, returns a data frame of predictions.- verbose
Whether to print the message. Default is
TRUE.
Value
A Seurat object with scMalignantFinder_prediction and
malignancy_probability added, or a data frame when return_seurat = FALSE.
References
Yu Q, Li YY, Chen Y. scMalignantFinder distinguishes malignant cells in single-cell and spatial transcriptomics by leveraging cancer signatures. Communications Biology. 2025.
Examples
if (FALSE) {
data(pancreas_sub)
pancreas_sub <- RunscMalignantFinder(
pancreas_sub,
assay = "RNA",
layer = "counts",
pretrain_dir = "path/to/pretrained_model"
)
CellDimPlot(pancreas_sub, group.by = "malignancy_probability")
}