### Install scop and Set Up Python Environment Source: https://context7.com/mengxu98/scop/llms.txt Installs the scop R package from GitHub using 'pak' and sets up the necessary Python environment for Python-backed functions. Optionally configure conda manager and pip mirror. ```r if (!require("pak", quietly = TRUE)) install.packages("pak") pak::pak("mengxu98/scop") # Set up the Python environment (required for SCVELO, PAGA, CellRank, etc.) scop::PrepareEnv() ``` ```r # Use a specific conda manager or mirror scop::PrepareEnv( conda = "mamba", miniconda_repo = "https://mirrors.bfsu.edu.cn/anaconda/miniconda", pip_options = "-i https://pypi.tuna.tsinghua.edu.cn/simple" ) ``` -------------------------------- ### Configure Network Mirrors for Environment Setup Source: https://github.com/mengxu98/scop/blob/main/README.md Specify custom repositories for miniconda and PyPI mirrors to speed up downloads, especially in regions with slow network access. ```r scop::PrepareEnv( miniconda_repo = "https://mirrors.bfsu.edu.cn/anaconda/miniconda", pip_options = "-i https://pypi.tuna.tsinghua.edu.cn/simple" ) ``` -------------------------------- ### Install scop R Package with pak Source: https://github.com/mengxu98/scop/blob/main/README.md Installs the scop R package from GitHub using the 'pak' package manager. Ensure 'pak' is installed first. ```r if (!require("pak", quietly = TRUE)) { install.packages("pak") } pak::pak("mengxu98/scop") ``` -------------------------------- ### PrepareEnv() Source: https://context7.com/mengxu98/scop/llms.txt Installs and configures a conda-compatible Python environment with all dependencies required by Python-backed functions. Automatically downloads Miniconda if no compatible manager is found. Supports `conda`, `mamba`, and `micromamba`. ```APIDOC ## PrepareEnv() — Set up Python environment Installs and configures a conda-compatible Python environment with all dependencies required by Python-backed functions such as `RunSCVELO()`, `RunPAGA()`, `RunPalantir()`, `RunCellRank()`, `RunCellTypist()`, and `RunCellphoneDB()`. Automatically downloads Miniconda if no compatible manager is found. Supports `conda`, `mamba`, and `micromamba`. ```r library(scop) # Default installation (Python 3.10 on macOS/Linux, 3.11 on Windows) PrepareEnv() # Install additional modules for RNA velocity + trajectory tools PrepareEnv(modules = c("scvelo", "cellrank", "palantir")) # Install CellTypist support PrepareEnv(modules = "celltypist") # Force full environment recreation with micromamba PrepareEnv(conda = "micromamba", force = TRUE) # Use a custom env name (set globally) options(scop_envname = "my_scop_env") PrepareEnv(envname = "my_scop_env") ``` ``` -------------------------------- ### Prepare Scop Python Environment Source: https://github.com/mengxu98/scop/blob/main/README.md Use this command to create the default Python environment for scop. It automatically handles miniconda installation if no compatible manager is found. ```r scop::PrepareEnv() ``` -------------------------------- ### PrepareEnv() - Set Up Python Environment for scop Source: https://context7.com/mengxu98/scop/llms.txt Configures a conda-compatible Python environment for scop's Python-dependent functions. Automatically downloads Miniconda if needed and supports various conda managers. Can install additional modules or force environment recreation. ```r library(scop) # Default installation (Python 3.10 on macOS/Linux, 3.11 on Windows) PrepareEnv() ``` ```r # Install additional modules for RNA velocity + trajectory tools PrepareEnv(modules = c("scvelo", "cellrank", "palantir")) ``` ```r # Install CellTypist support PrepareEnv(modules = "celltypist") ``` ```r # Force full environment recreation with micromamba PrepareEnv(conda = "micromamba", force = TRUE) ``` ```r # Use a custom env name (set globally) options(scop_envname = "my_scop_env") PrepareEnv(envname = "my_scop_env") ``` -------------------------------- ### Run Doublet Calling with Different Methods Source: https://context7.com/mengxu98/scop/llms.txt Detects and classifies doublets in single-cell data using various methods. Requires `scop` library and a Seurat object. Some methods like Scrublet require Python setup. ```r library(scop) data(pancreas_sub) pancreas_sub <- standard_scop(pancreas_sub) # scDblFinder (R-native, no Python required) pancreas_sub <- RunDoubletCalling( pancreas_sub, db_method = "scDblFinder", db_rate = 0.05 ) table(pancreas_sub$db.scDblFinder_class) #> singlet doublet #> 963 37 ``` ```r # Scrublet (requires Python via PrepareEnv) pancreas_sub <- RunDoubletCalling( pancreas_sub, db_method = "Scrublet" ) # Access: pancreas_sub$db.Scrublet_score, pancreas_sub$db.Scrublet_class ``` ```r # scds hybrid score pancreas_sub <- RunDoubletCalling( pancreas_sub, db_method = "scds_hybrid" ) ``` -------------------------------- ### Prepare and Run SCExplorer Source: https://github.com/mengxu98/scop/blob/main/README.md Prepares and runs the SCExplorer interactive visualization tool. The output directory can be used as a site directory for Shiny Server. ```r PrepareSCExplorer( list( mouse_pancreas = pancreas_sub, human_pancreas = panc8_sub ), base_dir = "./SCExplorer" ) app <- RunSCExplorer(base_dir = "./SCExplorer") list.files("./SCExplorer") # This directory can be used as site directory for Shiny Server. if (interactive()) { shiny::runApp(app) } ``` -------------------------------- ### RunBulk() Source: https://context7.com/mengxu98/scop/llms.txt Provides a single entry point for pseudobulk differential expression (limma-voom, edgeR QLF, DESeq2, dream), cell-type deconvolution (MuSiC, BisqueRNA, BayesPrism), and cell-type-specific DE (TOAST). Results stored in `srt@tools[["Bulk"]]`. ```APIDOC ## `RunBulk()` — Unified bulk analysis entrypoint Provides a single entry point for pseudobulk differential expression (limma-voom, edgeR QLF, DESeq2, dream), cell-type deconvolution (MuSiC, BisqueRNA, BayesPrism), and cell-type-specific DE (TOAST). Results stored in `srt@tools[["Bulk"]]`. ```r library(scop) data(pancreas_sub) # Assign sample/condition labels pancreas_sub$sample_id <- paste0( "sample_", (seq_len(ncol(pancreas_sub)) - 1L) %% 8L + 1L ) pancreas_sub$condition <- ifelse( pancreas_sub$sample_id %in% paste0("sample_", 1:4), "A", "B" ) # Pseudobulk DE with edgeR + enrichment pancreas_sub <- RunBulk( pancreas_sub, method = c("de_edgeR_qlf"), sample.by = "sample_id", condition.by = "condition", group.by = "CellType", run_enrichment = TRUE, enrichment_args = list( db = "GO_BP", species = "Mus_musculus" ) ) # Access results de_results <- pancreas_sub@tools$Bulk$results$de head(de_results) # Deconvolution (with a reference Seurat object) pancreas_sub <- RunBulk( pancreas_sub, method = "deconv_MuSiC", sample.by = "sample_id", celltype.by = "CellType" ) ``` ``` -------------------------------- ### Launch SCExplorer Shiny Application Source: https://context7.com/mengxu98/scop/llms.txt Launches the SCExplorer Shiny application for interactive single-cell data exploration. This function requires the output directory from PrepareSCExplorer. ```r library(scop) # Launch app app <- RunSCExplorer(base_dir = "./SCExplorer") if (interactive()) { shiny::runApp(app) } # The ./SCExplorer directory can also be deployed as a Shiny Server site ``` -------------------------------- ### PrepareSCExplorer() / RunSCExplorer() — Interactive Shiny visualization Source: https://context7.com/mengxu98/scop/llms.txt Exports one or more Seurat objects to a directory-based format and launches a Shiny application for interactive single-cell exploration. ```APIDOC ## PrepareSCExplorer() / RunSCExplorer() ### Description Exports one or more Seurat objects to a directory-based format and launches a Shiny application for interactive single-cell exploration, supporting dynamic UMAP coloring, gene expression queries, and metadata filtering. ### Method PrepareSCExplorer, RunSCExplorer ### Parameters for PrepareSCExplorer - **object_list** (list) - A named list of Seurat objects to export. - **base_dir** (character) - The base directory to save the exported data and Shiny app files. ### Parameters for RunSCExplorer - **base_dir** (character) - The base directory containing the exported SCExplorer data. ### Request Example ```r library(scop) data(pancreas_sub, panc8_sub) pancreas_sub <- standard_scop(pancreas_sub) panc8_sub <- integration_scop(panc8_sub, batch = "tech", integration_method = "Harmony") # Export datasets to disk PrepareSCExplorer( list( mouse_pancreas = pancreas_sub, human_pancreas = panc8_sub ), base_dir = "./SCExplorer" ) # Launch app app <- RunSCExplorer(base_dir = "./SCExplorer") if (interactive()) { shiny::runApp(app) } # The ./SCExplorer directory can also be deployed as a Shiny Server site ``` ### Response - **PrepareSCExplorer**: Creates files in the specified `base_dir`. - **RunSCExplorer**: Returns a Shiny app object that can be run. ``` -------------------------------- ### Run PAGA for graph abstraction of cell transitions Source: https://context7.com/mengxu98/scop/llms.txt Computes a high-level graph of cell population transitions using the PAGA algorithm. Requires a Python environment with scvelo/scanpy. Visualization is handled by PAGAPlot. ```r library(scop) data(pancreas_sub) pancreas_sub <- standard_scop(pancreas_sub) pancreas_sub <- RunPAGA( pancreas_sub, group.by = "SubCellType", linear_reduction = "PCA", nonlinear_reduction = "UMAP" ) PAGAPlot( pancreas_sub, reduction = "UMAP", label = TRUE, label_insitu = TRUE, label_repel = TRUE, edge_size = c(0.5, 1), edge_color = "black" ) ``` -------------------------------- ### RunPAGA() — Partition-based Graph Abstraction Source: https://context7.com/mengxu98/scop/llms.txt Computes a high-level graph of cell population transitions using the PAGA algorithm from scanpy. Requires a Python environment with `scvelo`/`scanpy`. ```APIDOC ## RunPAGA() — Partition-based Graph Abstraction Computes a high-level graph of cell population transitions using the PAGA algorithm from scanpy. Requires Python environment with `scvelo`/`scanpy`. ```r library(scop) data(pancreas_sub) pancreas_sub <- standard_scop(pancreas_sub) pancreas_sub <- RunPAGA( pancreas_sub, group.by = "SubCellType", linear_reduction = "PCA", nonlinear_reduction = "UMAP" ) PAGAPlot( pancreas_sub, reduction = "UMAP", label = TRUE, label_insitu = TRUE, label_repel = TRUE, edge_size = c(0.5, 1), edge_color = "black" ) ``` ``` -------------------------------- ### Unified Bulk Analysis with RunBulk Source: https://context7.com/mengxu98/scop/llms.txt Provides a single entry point for various bulk RNA-seq analysis methods including differential expression and cell-type deconvolution. Results are stored in the object. Ensure sample and condition labels are assigned before running. ```r library(scop) data(pancreas_sub) # Assign sample/condition labels pancreas_sub$sample_id <- paste0( "sample_", (seq_len(ncol(pancreas_sub)) - 1L) %% 8L + 1L ) pancreas_sub$condition <- ifelse( pancreas_sub$sample_id %in% paste0("sample_", 1:4), "A", "B" ) # Pseudobulk DE with edgeR + enrichment pancreas_sub <- RunBulk( pancreas_sub, method = c("de_edgeR_qlf"), sample.by = "sample_id", condition.by = "condition", group.by = "CellType", run_enrichment = TRUE, enrichment_args = list( db = "GO_BP", species = "Mus_musculus" ) ) # Access results de_results <- pancreas_sub@tools$Bulk$results$de head(de_results) # Deconvolution (with a reference Seurat object) pancreas_sub <- RunBulk( pancreas_sub, method = "deconv_MuSiC", sample.by = "sample_id", celltype.by = "CellType" ) ``` -------------------------------- ### standard_scop() Source: https://context7.com/mengxu98/scop/llms.txt Runs the full standard preprocessing pipeline on a Seurat object: normalization (LogNormalize or scran), highly variable feature (HVF) selection, optional cell-cycle regression, scaling, PCA, UMAP (2D and 3D), graph construction, and Louvain/Leiden clustering. Parameters control every step and the result is stored back into the Seurat object with named reductions. ```APIDOC ## standard_scop() — Standard single-cell preprocessing pipeline Runs the full standard preprocessing pipeline on a Seurat object: normalization (LogNormalize or scran), highly variable feature (HVF) selection, optional cell-cycle regression, scaling, PCA, UMAP (2D and 3D), graph construction, and Louvain/Leiden clustering. Parameters control every step and the result is stored back into the Seurat object with named reductions. ```r library(scop) data(pancreas_sub) # One-call standard pipeline pancreas_sub <- standard_scop(pancreas_sub) print(pancreas_sub) #> Active assay: RNA (15998 features, 2000 variable features) #> 5 dimensional reductions calculated: Standardpca, StandardpcaUMAP2D, #> StandardpcaUMAP3D, StandardUMAP2D, StandardUMAP3D # Custom pipeline: scran normalization, 3000 HVFs, 40 PCA dims pancreas_sub <- standard_scop( pancreas_sub, normalization_method = "scran", nHVF = 3000, linear_reduction = "pca", linear_reduction_dims = 40, nonlinear_reduction = "umap", nonlinear_reduction_dims = c(2, 3), cluster_resolution = 0.5 ) ``` ``` -------------------------------- ### RunCellQC() Source: https://context7.com/mengxu98/scop/llms.txt Performs multi-metric cell quality control on a Seurat object, integrating doublet detection (scDblFinder, Scrublet, DoubletDetection, scds), ambient RNA decontamination (decontX), outlier detection, and threshold-based filters for UMI counts, gene counts, mitochondrial percentage, ribosomal percentage, ribo/mito ratio, and species contamination. Results are stored as `Pass`/`Fail` columns in `srt@meta.data`. ```APIDOC ## RunCellQC() — Comprehensive cell-level quality control Performs multi-metric cell quality control on a Seurat object, integrating doublet detection (scDblFinder, Scrublet, DoubletDetection, scds), ambient RNA decontamination (decontX), outlier detection, and threshold-based filters for UMI counts, gene counts, mitochondrial percentage, ribosomal percentage, ribo/mito ratio, and species contamination. Results are stored as `Pass`/`Fail` columns in `srt@meta.data`. ```r library(scop) data(pancreas_sub) pancreas_sub <- standard_scop(pancreas_sub) # Full QC with default metrics and scDblFinder doublet detection pancreas_sub <- RunCellQC(pancreas_sub) ``` ``` -------------------------------- ### Apply Standard Scop Preprocessing Source: https://github.com/mengxu98/scop/blob/main/README.md Applies standard preprocessing steps using the standard_scop function to the Seurat object. Prints the object after processing. ```r pancreas_sub <- standard_scop(pancreas_sub) print(pancreas_sub) ``` -------------------------------- ### standard_scop() - Standard Single-Cell Preprocessing Pipeline Source: https://context7.com/mengxu98/scop/llms.txt Executes a comprehensive preprocessing pipeline on a Seurat object, including normalization, HVF selection, PCA, UMAP, and clustering. Allows customization of normalization methods, feature counts, dimensionality, and clustering resolution. ```r library(scop) data(pancreas_sub) # One-call standard pipeline pancreas_sub <- standard_scop(pancreas_sub) print(pancreas_sub) #> Active assay: RNA (15998 features, 2000 variable features) #> 5 dimensional reductions calculated: Standardpca, StandardpcaUMAP2D, #> StandardpcaUMAP3D, StandardUMAP2D, StandardUMAP3D ``` ```r # Custom pipeline: scran normalization, 3000 HVFs, 40 PCA dims pancreas_sub <- standard_scop( pancreas_sub, normalization_method = "scran", nHVF = 3000, linear_reduction = "pca", linear_reduction_dims = 40, nonlinear_reduction = "umap", nonlinear_reduction_dims = c(2, 3), cluster_resolution = 0.5 ) ``` -------------------------------- ### Project query cells onto reference UMAP with RunKNNMap Source: https://context7.com/mengxu98/scop/llms.txt Projects query cells onto a reference UMAP embedding using KNN. Requires a reference Seurat object and its UMAP embedding. Visualization is done with ProjectionPlot. ```r library(scop) data(pancreas_sub, panc8_sub) # Integration: build reference panc8_sub <- integration_scop( panc8_sub, batch = "tech", integration_method = "Harmony" ) # Project query onto reference UMAP pancreas_sub <- RunKNNMap( srt_query = pancreas_sub, srt_ref = panc8_sub, ref_umap = "HarmonyUMAP2D" ) ProjectionPlot( srt_query = pancreas_sub, srt_ref = panc8_sub, query_group = "SubCellType", ref_group = "celltype" ) ``` -------------------------------- ### List Available CellTypist Models Source: https://context7.com/mengxu98/scop/llms.txt Lists the pre-trained CellTypist models available for cell annotation. Requires the scop package and pancreas_sub dataset. ```r library(scop) data(pancreas_sub) pancreas_sub <- standard_scop(pancreas_sub) # List available models CellTypistModels() ``` -------------------------------- ### Run Dynamic Gene Detection Source: https://context7.com/mengxu98/scop/llms.txt Identifies genes with significant expression dynamics along pseudotime lineages using GAM or PreTSA fitting. ```r # Find dynamic features along lineages pancreas_sub <- RunDynamicFeatures( pancreas_sub, lineages = c("Lineage1", "Lineage2"), n_candidates = 200 ) ``` -------------------------------- ### RunCellChat() Source: https://context7.com/mengxu98/scop/llms.txt Runs CellChat analysis to identify intercellular communication networks from ligand-receptor interactions. Supports human, mouse, and zebrafish. Results stored in `srt@tools[["CellChat"]]`. ```APIDOC ## `RunCellChat()` — Cell-cell communication analysis Runs CellChat analysis to identify intercellular communication networks from ligand-receptor interactions. Supports human, mouse, and zebrafish. Results stored in `srt@tools[["CellChat"]]`. ```r library(scop) data(pancreas_sub) pancreas_sub <- standard_scop(pancreas_sub) # Run CellChat (requires CellChat package) pancreas_sub <- RunCellChat( pancreas_sub, group.by = "SubCellType", species = "mouse" ) # Visualize communication networks CCCNetworkPlot( pancreas_sub, group.by = "SubCellType", from = "CellChat" ) # Statistical summary of communication CCCStatPlot( pancreas_sub, group.by = "SubCellType", from = "CellChat" ) ``` ``` -------------------------------- ### Load and Print Mouse Pancreas Data Source: https://github.com/mengxu98/scop/blob/main/README.md Loads the subsetted mouse pancreas dataset and prints its structure. Requires the scop library. ```r library(scop) data(pancreas_sub) print(pancreas_sub) ``` -------------------------------- ### Generate Dynamic Gene Heatmap Source: https://context7.com/mengxu98/scop/llms.txt Creates a heatmap visualizing dynamic genes along lineages, with optional GO enrichment annotation and cell/feature annotations. ```r # Dynamic heatmap with GO enrichment annotation ht <- DynamicHeatmap( pancreas_sub, lineages = c("Lineage1", "Lineage2"), use_fitted = TRUE, n_split = 6, species = "Mus_musculus", db = "GO_BP", anno_terms = TRUE, heatmap_palette = "viridis", cell_annotation = "SubCellType", feature_annotation = c("TF", "CSPA"), cores = 4 ) print(ht$plot) ``` -------------------------------- ### Run Slingshot Trajectory Analysis Source: https://context7.com/mengxu98/scop/llms.txt Computes cell lineages and pseudotime using the Slingshot method, based on dimensionality reduction results. ```r library(scop) data(pancreas_sub) pancreas_sub <- standard_scop(pancreas_sub) # Run Slingshot trajectory first pancreas_sub <- RunSlingshot( pancreas_sub, group.by = "SubCellType", reduction = "UMAP", start = "Ductal", end = c("Alpha", "Beta", "Delta") ) ``` -------------------------------- ### Plot Cell Composition Statistics Source: https://context7.com/mengxu98/scop/llms.txt Generates various plots (bar, pie, rose, sankey, chord, upset) to visualize cell type composition across groups. Requires QC metrics to be computed first using `RunCellQC()`. ```r library(scop) data(pancreas_sub) pancreas_sub <- standard_scop(pancreas_sub) pancreas_sub <- RunCellQC(pancreas_sub, db_method = "scds_hybrid") # QC failure breakdown CellStatPlot( pancreas_sub, stat.by = c("db_qc", "decontX_qc", "outlier_qc", "umi_qc", "mito_qc"), plot_type = "upset", stat_level = "Fail" ) ``` -------------------------------- ### Run Cell Quality Control and Plot on UMAP Source: https://github.com/mengxu98/scop/blob/main/README.md Runs cell quality control metrics and visualizes the 'CellQC' results on a UMAP plot. Requires the Seurat object. ```r pancreas_sub <- RunCellQC(pancreas_sub) CellDimPlot( pancreas_sub, group.by = "CellQC", reduction = "UMAP" ) ``` -------------------------------- ### RunDoubletCalling Source: https://context7.com/mengxu98/scop/llms.txt Calls doublets using a specified method and stores per-cell scores and classifications in metadata. Wraps scDblFinder, Scrublet, DoubletDetection, and three scds variants behind a unified interface. ```APIDOC ## RunDoubletCalling() ### Description Calls doublets using a specified method and stores per-cell scores and classifications in metadata. Wraps scDblFinder, Scrublet, DoubletDetection, and three scds variants behind a unified interface. ### Method ```r RunDoubletCalling( srt_obj, db_method = c("scds_hybrid", "scds_bcm", "scds_hybrid_bcm", "scDblFinder", "Scrublet", "DoubletDetection"), db_rate = NULL, group.by = NULL, assay = "RNA", reduction = "UMAP", dims = 1:30, ... ) ``` ### Parameters * **srt_obj** (Seurat Object) - Input Seurat object. * **db_method** (character) - Doublet calling method to use. Options include "scds_hybrid", "scds_bcm", "scds_hybrid_bcm", "scDblFinder", "Scrublet", "DoubletDetection". * **db_rate** (numeric, optional) - Expected doublet rate. Required for some methods like scDblFinder. * **group.by** (character, optional) - Metadata column to group cells by for calling doublets within groups. * **assay** (character) - Assay to use for doublet calling. * **reduction** (character) - Reduction to use for doublet calling (e.g., PCA, ICA). * **dims** (numeric vector) - Dimensions to use for dimensionality reduction. ### Request Example ```r library(scop) data(pancreas_sub) pancreas_sub <- standard_scop(pancreas_sub) # scDblFinder (R-native, no Python required) pancreas_sub <- RunDoubletCalling( pancreas_sub, db_method = "scDblFinder", db_rate = 0.05 ) # Scrublet (requires Python via PrepareEnv) pancreas_sub <- RunDoubletCalling( pancreas_sub, db_method = "Scrublet" ) # scds hybrid score pancreas_sub <- RunDoubletCalling( pancreas_sub, db_method = "scds_hybrid" ) ``` ### Response Returns the input Seurat object with added metadata columns for doublet scores and classifications (e.g., `db.METHOD_score`, `db.METHOD_class`). ``` -------------------------------- ### Run Gene Set Enrichment Analysis (GSEA) Source: https://context7.com/mengxu98/scop/llms.txt Runs pre-ranked GSEA using differential expression fold-change statistics across cell groups. Supports the same database set as RunEnrichment(). ```r library(scop) data(pancreas_sub) pancreas_sub <- standard_scop(pancreas_sub) pancreas_sub <- RunDEtest( pancreas_sub, group.by = "CellType", only.pos = FALSE ) # GSEA with GO Biological Process pancreas_sub <- RunGSEA( pancreas_sub, group.by = "CellType", db = "GO_BP", species = "Mus_musculus", DE_threshold = "p_val_adj < 0.05", cores = 4 ) ``` -------------------------------- ### Run Differential Expression Test (limma-voom) Source: https://context7.com/mengxu98/scop/llms.txt Performs pseudobulk differential expression analysis using limma-voom, requiring sample and condition metadata. Uses counts from a specified layer. ```r pancreas_sub$sample <- paste0("S", (seq_len(ncol(pancreas_sub)) - 1) %% 4 + 1) pancreas_sub$condition <- ifelse( pancreas_sub$sample %in% c("S1", "S2"), "ctrl", "case" ) pancreas_sub <- RunDEtest( pancreas_sub, group.by = "CellType", test.use = "limma", sample_col = "sample", condition_col = "condition", fc.threshold = 1, layer = "counts", only.pos = FALSE ) ``` -------------------------------- ### Run CytoTRACE for cellular potency prediction Source: https://context7.com/mengxu98/scop/llms.txt Predicts cellular differentiation potential using CytoTRACE 2. Requires a Python environment. Outputs potency scores and categorical labels stored in Seurat metadata. Visualization is available via CytoTRACEPlot and FeatureStatPlot. ```r library(scop) data(pancreas_sub) pancreas_sub <- standard_scop(pancreas_sub) # Requires Python environment pancreas_sub <- RunCytoTRACE( pancreas_sub, species = "Mus_musculus" ) CytoTRACEPlot( pancreas_sub, group.by = "CellType" ) # Check potency distribution across cell types FeatureStatPlot( pancreas_sub, stat.by = "CytoTRACE2_Score", group.by = "CellType" ) ``` -------------------------------- ### Prepare Data for SCExplorer Source: https://context7.com/mengxu98/scop/llms.txt Exports Seurat objects to a directory-based format suitable for the SCExplorer Shiny application. This function is used to prepare datasets for interactive exploration. ```r library(scop) data(pancreas_sub, panc8_sub) pancreas_sub <- standard_scop(pancreas_sub) panc8_sub <- integration_scop(panc8_sub, batch = "tech", integration_method = "Harmony") # Export datasets to disk PrepareSCExplorer( list( mouse_pancreas = pancreas_sub, human_pancreas = panc8_sub ), base_dir = "./SCExplorer" ) ``` -------------------------------- ### RunCellTypist() — Automated cell annotation Source: https://context7.com/mengxu98/scop/llms.txt Annotates cell types using CellTypist pre-trained models. Downloads models on demand, runs Python-based classification, and transfers labels to Seurat metadata. ```APIDOC ## RunCellTypist() ### Description Annotates cell types using CellTypist pre-trained models. Downloads models on demand, runs Python-based classification, and transfers labels to Seurat metadata. ### Method RunCellTypist ### Parameters - **object** (Seurat object) - The input Seurat object. - **model** (character) - The name of the CellTypist model to use (e.g., "Immune_All_Low.pkl"). ### Request Example ```r library(scop) data(pancreas_sub) pancreas_sub <- standard_scop(pancreas_sub) # List available models CellTypistModels() # Annotate with a specific model (requires Python) pancreas_sub <- RunCellTypist( pancreas_sub, model = "Immune_All_Low.pkl" ) CellDimPlot( pancreas_sub, group.by = "CellTypist_majority_voting", reduction = "UMAP", label = TRUE ) ``` ### Response - **object** (Seurat object) - The Seurat object with added CellTypist annotations in the metadata. ``` -------------------------------- ### Plot Cells by Subtype and Phase on UMAP Source: https://github.com/mengxu98/scop/blob/main/README.md Generates a UMAP plot colored by 'SubCellType' and stratified by 'Phase'. Uses a blank theme. ```r CellDimPlot( pancreas_sub, group.by = "SubCellType", stat.by = "Phase", reduction = "UMAP", theme_use = "theme_blank", xlab = "UMAP_1", ylab = "UMAP_2" ) ``` -------------------------------- ### Visualize CellTypist Annotations Source: https://context7.com/mengxu98/scop/llms.txt Generates a UMAP plot colored by CellTypist annotations. Requires the scop package, pancreas_sub dataset, and prior cell annotation using RunCellTypist. ```r library(scop) data(pancreas_sub) pancreas_sub <- standard_scop(pancreas_sub) CellDimPlot( pancreas_sub, group.by = "CellTypist_majority_voting", reduction = "UMAP", label = TRUE ) ``` -------------------------------- ### RunCellQC() - Comprehensive Cell-Level Quality Control Source: https://context7.com/mengxu98/scop/llms.txt Performs multi-metric quality control on cells within a Seurat object. Integrates doublet detection, ambient RNA decontamination, and various threshold-based filters. Results are stored in the object's metadata. ```r library(scop) data(pancreas_sub) pancreas_sub <- standard_scop(pancreas_sub) # Full QC with default metrics and scDblFinder doublet detection pancreas_sub <- RunCellQC(pancreas_sub) ``` -------------------------------- ### Integrate Multiple Single-Cell Datasets Source: https://context7.com/mengxu98/scop/llms.txt Integrates multiple single-cell datasets split by a batch variable using various methods like Harmony, scVI, Seurat, etc. Stores the integrated embedding and UMAP back into the Seurat object. Requires `scop` library and a merged Seurat object. ```r library(scop) data(panc8_sub) # 8 human pancreas datasets merged # Harmony integration panc8_sub <- integration_scop( srt_merge = panc8_sub, batch = "tech", integration_method = "Harmony" ) # Access integrated UMAP: "HarmonyUMAP2D" ``` ```r # scVI integration (requires Python environment) panc8_sub <- integration_scop( srt_merge = panc8_sub, batch = "tech", integration_method = "scVI" ) ``` ```r # Compare batch-corrected embedding CellDimPlot( panc8_sub, group.by = c("tech", "celltype"), reduction = "HarmonyUMAP2D", theme_use = "theme_blank" ) ``` -------------------------------- ### Run Monocle3 for trajectory analysis Source: https://context7.com/mengxu98/scop/llms.txt Performs cell ordering, trajectory graph learning, and pseudotime computation using Monocle3. Results are stored in `srt@tools$Monocle3`. Trajectories and pseudotime can be visualized with CellDimPlot and FeatureDimPlot. ```r library(scop) data(pancreas_sub) pancreas_sub <- standard_scop(pancreas_sub) pancreas_sub <- RunMonocle3( pancreas_sub, group.by = "SubCellType" ) # Extract trajectory and milestone geom layers for ggplot2 trajectory <- pancreas_sub@tools$Monocle3$trajectory milestones <- pancreas_sub@tools$Monocle3$milestones CellDimPlot( pancreas_sub, group.by = "SubCellType", reduction = "UMAP", label = TRUE ) + trajectory + milestones FeatureDimPlot( pancreas_sub, features = "Monocle3_Pseudotime", reduction = "UMAP" ) + trajectory ``` -------------------------------- ### RunDecontX Source: https://context7.com/mengxu98/scop/llms.txt Estimates ambient RNA contamination per cell using the decontX algorithm and optionally stores decontaminated counts as a new assay. ```APIDOC ## RunDecontX() ### Description Estimates ambient RNA contamination per cell using the decontX algorithm and optionally stores decontaminated counts as a new assay. Contamination levels are stored in `srt@meta.data$decontX_contamination`. ### Method ```r RunDecontX( srt_obj, group.by = NULL, assay = "RNA", slot = "counts", store_assay = FALSE, assay_name = "decontXcounts", round_counts = FALSE, ... ) ``` ### Parameters * **srt_obj** (Seurat Object) - Input Seurat object. * **group.by** (character, optional) - Metadata column to use as priors for cell type information. * **assay** (character) - Assay containing the counts to use for decontamination. * **slot** (character) - Slot within the specified assay containing the counts. * **store_assay** (logical) - Whether to store the decontaminated counts as a new assay. * **assay_name** (character) - Name for the new assay if `store_assay` is TRUE. * **round_counts** (logical) - Whether to round the decontaminated counts to the nearest integer. ### Request Example ```r library(scop) data(pancreas_sub) pancreas_sub <- standard_scop(pancreas_sub) # Basic decontamination with cell type priors pancreas_sub <- RunDecontX( pancreas_sub, group.by = "CellType", # use existing labels as priors store_assay = TRUE, # save decontaminated counts as "decontXcounts" round_counts = TRUE ) ``` ### Response Returns the input Seurat object with added metadata column `decontX_contamination` and optionally a new assay containing decontaminated counts. ``` -------------------------------- ### Run scVelo for RNA velocity analysis Source: https://context7.com/mengxu98/scop/llms.txt Estimates RNA velocity using scVelo. Requires spliced and unspliced assays in the Seurat object. Outputs can be visualized with VelocityPlot. ```r library(scop) data(pancreas_sub) pancreas_sub <- standard_scop(pancreas_sub) # Run scVelo (requires PrepareEnv with "scvelo" module) pancreas_sub <- RunSCVELO( pancreas_sub, group.by = "SubCellType", linear_reduction = "PCA", nonlinear_reduction = "UMAP" ) # Arrow plot colored by cell type VelocityPlot( pancreas_sub, reduction = "UMAP", group.by = "SubCellType" ) # Stream plot of velocity field VelocityPlot( pancreas_sub, reduction = "UMAP", plot_type = "stream" ) ``` -------------------------------- ### Run Dynamic Features Analysis Source: https://github.com/mengxu98/scop/blob/main/README.md Identifies dynamic features (genes) over specified lineages and annotates them with transcription factors and surface proteins. Requires the 'pancreas_sub' object. ```r pancreas_sub <- RunDynamicFeatures( pancreas_sub, lineages = c("Lineage1", "Lineage2"), n_candidates = 200 ) # Annotate features with transcription factors and surface proteins pancreas_sub <- AnnotateFeatures( pancreas_sub, species = "Mus_musculus", db = c("TF", "CSPA") ) ht <- DynamicHeatmap( pancreas_sub, lineages = c("Lineage1", "Lineage2"), use_fitted = TRUE, n_split = 6, reverse_ht = "Lineage1", species = "Mus_musculus", db = "GO_BP", anno_terms = TRUE, anno_keys = TRUE, anno_features = TRUE, exp_legend_title = "Z-score", heatmap_palette = "viridis", cell_annotation = "SubCellType", separate_annotation = list( "SubCellType", c("Nnat", "Irx1") ), separate_annotation_palette = c("Chinese", "Set1"), feature_annotation = c("TF", "CSPA"), feature_annotation_palcolor = list( c("gold", "steelblue"), c("forestgreen") ), pseudotime_label = 25, pseudotime_label_color = "red", cores = 6, height = 5, width = 2 ) print(ht$plot) ``` -------------------------------- ### Word Cloud for Enrichment Analysis Source: https://github.com/mengxu98/scop/blob/main/README.md Generates a word cloud visualization of enriched terms from the enrichment analysis. Can display terms based on gene features. ```r EnrichmentPlot( pancreas_sub, group.by = "CellType", group_use = c("Ductal", "Endocrine"), plot_type = "wordcloud" ) ``` ```r EnrichmentPlot( pancreas_sub, group.by = "CellType", group_use = c("Ductal", "Endocrine"), plot_type = "wordcloud", word_type = "feature" ) ``` -------------------------------- ### RunSCVELO() — RNA velocity analysis Source: https://context7.com/mengxu98/scop/llms.txt Estimates RNA velocity using the scVelo Python library from spliced/unspliced count matrices. Requires both `spliced` and `unspliced` assays in the Seurat object. ```APIDOC ## RunSCVELO() — RNA velocity analysis Estimates RNA velocity using the scVelo Python library from spliced/unspliced count matrices. Requires both `spliced` and `unspliced` assays in the Seurat object (produced by velocyto or alevin-fry). ```r library(scop) data(pancreas_sub) # includes spliced and unspliced assays pancreas_sub <- standard_scop(pancreas_sub) # Run scVelo (requires PrepareEnv with "scvelo" module) pancreas_sub <- RunSCVELO( pancreas_sub, group.by = "SubCellType", linear_reduction = "PCA", nonlinear_reduction = "UMAP" ) # Arrow plot colored by cell type VelocityPlot( pancreas_sub, reduction = "UMAP", group.by = "SubCellType" ) # Stream plot of velocity field VelocityPlot( pancreas_sub, reduction = "UMAP", plot_type = "stream" ) ``` ``` -------------------------------- ### Feature Heatmap with Annotations Source: https://github.com/mengxu98/scop/blob/main/README.md Generates a feature heatmap for selected genes, with options for splitting features by group and annotating with pathway information (TF, CSPA). Requires differential gene expression results to be pre-calculated. ```r DEGs <- pancreas_sub@tools$DEtest_CellType$AllMarkers_wilcox DEGs <- DEGs[with(DEGs, avg_log2FC > 1 & p_val_adj < 0.05), ] ht <- FeatureHeatmap( pancreas_sub, group.by = "CellType", features = DEGs$gene, feature_split = DEGs$group1, exp_legend_title = "Z-score", species = "Mus_musculus", db = c("GO_BP", "KEGG", "WikiPathway"), anno_terms = TRUE, feature_annotation = c("TF", "CSPA"), feature_annotation_palcolor = list( c("gold", "steelblue"), c("forestgreen") ), cores = 6, height = 5, width = 3 ) print(ht$plot) ``` -------------------------------- ### FeatureDimPlot() Source: https://context7.com/mengxu98/scop/llms.txt Visualizes continuous features (gene expression, scores, pseudotime) on a 2D reduction. Supports multi-feature panels, side-by-side comparison, co-expression overlay, and custom color scales. ```APIDOC ## `FeatureDimPlot()` — Feature expression dimensionality plot Visualizes continuous features (gene expression, scores, pseudotime) on a 2D reduction. Supports multi-feature panels, side-by-side comparison, co-expression overlay, and custom color scales. ```r library(scop) data(pancreas_sub) pancreas_sub <- standard_scop(pancreas_sub) # Multi-gene panel FeatureDimPlot( pancreas_sub, features = c("Sox9", "Neurog3", "Fev", "Rbp4"), reduction = "UMAP", theme_use = "theme_blank" ) # Co-expression comparison (shows which cells express multiple markers) FeatureDimPlot( pancreas_sub, features = c("Ins1", "Gcg", "Sst", "Ghrl"), compare_features = TRUE, label = TRUE, label_insitu = TRUE, reduction = "UMAP" ) # Pseudotime visualization (from Slingshot) FeatureDimPlot( pancreas_sub, features = "Lineage1", reduction = "UMAP", palette = "viridis" ) ``` ``` -------------------------------- ### Run Ambient RNA Decontamination Source: https://context7.com/mengxu98/scop/llms.txt Estimates and optionally removes ambient RNA contamination from single-cell data using the decontX algorithm. Can store decontaminated counts as a new assay and uses cell type priors for improved accuracy. Requires `scop` library and a Seurat object. ```r library(scop) data(pancreas_sub) pancreas_sub <- standard_scop(pancreas_sub) # Basic decontamination with cell type priors pancreas_sub <- RunDecontX( pancreas_sub, group.by = "CellType", # use existing labels as priors store_assay = TRUE, # save decontaminated counts as "decontXcounts" round_counts = TRUE ) # Inspect contamination distribution summary(pancreas_sub$decontX_contamination) # Visualize contamination on UMAP FeatureDimPlot( pancreas_sub, features = "decontX_contamination", reduction = "UMAP" ) ``` -------------------------------- ### integration_scop Source: https://context7.com/mengxu98/scop/llms.txt Batch integration pipeline for multiple single-cell datasets. ```APIDOC ## integration_scop() ### Description Integrates multiple single-cell datasets split by a batch variable using one of many supported methods: Uncorrected, Seurat (CCA/RPCA), Harmony, scVI, fastMNN, MNN, Scanorama, BBKNN, CSS, LIGER, Conos, ComBat, Coralysis. The integrated embedding and UMAP are stored back in the Seurat object. ### Method ```r integration_scop( srt_merge, batch, integration_method = c("Uncorrected", "SeuratCCA", "SeuratRPCA", "Harmony", "scVI", "fastMNN", "MNN", "Scanorama", "BBKNN", "CSS", "LIGER", "Conos", "ComBat", "Coralysis"), assay = "RNA", dims = 1:30, ... ) ``` ### Parameters * **srt_merge** (Seurat Object) - Merged Seurat object containing multiple datasets. * **batch** (character) - Metadata column name specifying the batch or dataset for each cell. * **integration_method** (character) - Method to use for integration. Options include "Uncorrected", "SeuratCCA", "SeuratRPCA", "Harmony", "scVI", "fastMNN", "MNN", "Scanorama", "BBKNN", "CSS", "LIGER", "Conos", "ComBat", "Coralysis". * **assay** (character) - Assay to use for integration. * **dims** (numeric vector) - Dimensions to use for integration (e.g., from PCA). ### Request Example ```r library(scop) data(panc8_sub) # 8 human pancreas datasets merged # Harmony integration panc8_sub <- integration_scop( srt_merge = panc8_sub, batch = "tech", integration_method = "Harmony" ) # scVI integration (requires Python environment) panc8_sub <- integration_scop( srt_merge = panc8_sub, batch = "tech", integration_method = "scVI" ) ``` ### Response Returns the merged Seurat object with integrated embeddings (e.g., "HarmonyUMAP2D") stored. ```