scPharm is a computational framework for identifying pharmacological subpopulations of single cells in cancer research. By integrating single-cell RNA sequencing (scRNA-seq) data with pharmacogenomics profiles from the GDSC2 database, scPharm enables:
This vignette provides a quick introduction to get you started with scPharm.
For demonstration, we’ll create a simulated Seurat object with genes matching the GDSC2 database.
# Load reference gene annotations
data(bulkdata, package = "scPharm")
data(copykat_full.anno.hg20, package = "scPharm")
# Get real gene names
real_genes <- intersect(rownames(bulkdata), copykat_full.anno.hg20$hgnc_symbol)
# Create simulated data
set.seed(42)
genes <- sample(real_genes, 3000)
n_cells <- 200
# Simulate count matrix
counts <- matrix(rpois(length(genes) * n_cells, lambda = 10),
nrow = length(genes), ncol = n_cells)
rownames(counts) <- genes
colnames(counts) <- paste0("Cell_", seq_len(n_cells))
# Add variation
high_var_genes <- sample(length(genes), 300)
counts[high_var_genes, ] <- counts[high_var_genes, ] +
rpois(300 * n_cells, lambda = 25)
# Create Seurat object
seurat_obj <- CreateSeuratObject(counts = counts,
min.cells = 3,
min.features = 200)
seurat_obj <- NormalizeData(seurat_obj, verbose = FALSE)
print(seurat_obj)
#> An object of class Seurat
#> 3000 features across 200 samples within 1 assay
#> Active assay: RNA (3000 features, 0 variable features)
#> 2 layers present: counts, dataThe core function scPharmIdentify() classifies cells
based on their drug response profiles.
# For cell line data (no CNV detection needed)
result <- scPharmIdentify(
seurat_obj,
type = "cellline", # or "tissue" for patient samples
cancer = "BRCA", # TCGA cancer type
drug = "Docetaxel", # Drug name or "all"
nmcs = 30, # Number of MCA components
nfeatures = 150, # Features for cell signatures
cores = 4 # Parallel cores
)For tissue samples with tumor/normal cell mixtures:
# Automatic tumor detection via CNV analysis
result <- scPharmIdentify(
seurat_obj,
type = "tissue",
cancer = "LUAD"
)
# Or provide known tumor cell barcodes
tumor_cells <- c("Cell_1", "Cell_2", "Cell_3", ...)
result <- scPharmIdentify(
seurat_obj,
type = "tissue",
cancer = "LUAD",
tumor.cells = tumor_cells
)Rank drugs by their effectiveness on tumor cells:
For tissue samples, estimate potential toxicity on non-malignant cells:
After running scPharmIdentify(), the Seurat object
contains new metadata columns:
| Column | Description |
|---|---|
cell.label |
Cell type: “tumor” or “adjacent” |
scPharm_label_<drug> |
Drug response: “sensitive”, “resistant”, or “other” |
scPharm_nes_<drug> |
Normalized Enrichment Score (NES) |
The Dr score integrates:
Lower Dr = Better drug candidate
The Dse score measures potential toxicity:
| Parameter | Recommended Range | Notes |
|---|---|---|
nmcs |
30-50 | Higher for complex datasets |
nfeatures |
100-200 | Balance between specificity and coverage |
threshold.s |
Default or from scPharmGenNullDist() |
Sensitive threshold |
threshold.r |
Default or from scPharmGenNullDist() |
Resistant threshold |
cores |
1-8 | Parallel processing |
scPharm supports all major TCGA cancer types:
#> BRCA, LUAD, LUSC, COAD, STAD, LIHC, KIRC, OV, PAAD, GBM, SKCM, HNSC, BLCA, PRAD, UCEC, ESCA, THCA, pan
Use cancer = "pan" for pan-cancer analysis.
sessionInfo()
#> R version 4.6.2 (2026-10-29)
#> Platform: x86_64-pc-linux-gnu
#> Running under: Ubuntu 26.04.1 LTS
#>
#> Matrix products: default
#> BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
#> LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.32.so; LAPACK version 3.12.0
#>
#> locale:
#> [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
#> [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
#> [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
#> [7] LC_PAPER=en_US.UTF-8 LC_NAME=C
#> [9] LC_ADDRESS=C LC_TELEPHONE=C
#> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
#>
#> time zone: Etc/UTC
#> tzcode source: system (glibc)
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] scPharm_1.0.6 Seurat_6.0.0 SeuratObject_5.4.0 sp_2.2-4
#> [5] dplyr_1.2.1 ggplot2_4.0.3 rmarkdown_2.32
#>
#> loaded via a namespace (and not attached):
#> [1] pbapply_1.7-5 gridExtra_2.3.1 rlang_1.3.0
#> [4] magrittr_2.0.5 RcppAnnoy_0.0.23 otel_0.3.0
#> [7] matrixStats_1.5.0 ggridges_0.5.7 compiler_4.6.2
#> [10] png_0.1-9 vctrs_0.7.3 reshape2_1.4.5
#> [13] stringr_1.6.0 pkgconfig_2.0.3 fastmap_1.2.0
#> [16] labeling_0.4.3 purrr_1.2.2 xfun_0.62
#> [19] cachem_1.1.0 jsonlite_2.0.0 BiocParallel_1.47.0
#> [22] irlba_2.4.1 parallel_4.6.2 cluster_2.1.8.3
#> [25] R6_2.6.1 ica_1.0-3 bslib_0.12.0
#> [28] stringi_1.8.9 RColorBrewer_1.1-3 parallelly_1.50.0
#> [31] jquerylib_0.1.4 scattermore_1.2 Rcpp_1.1.2
#> [34] knitr_1.52 future.apply_1.21.0 mixtools_2.0.0.1
#> [37] sctransform_0.4.3 Matrix_1.7-6 splines_4.6.2
#> [40] igraph_2.3.4 tidyselect_1.2.1 yaml_2.3.12
#> [43] codetools_0.2-20 listenv_1.1.0 lattice_0.23-1
#> [46] tibble_3.3.1 plyr_1.8.9 withr_3.0.3
#> [49] S7_0.2.2 evaluate_1.0.5 Rtsne_0.17
#> [52] future_1.82.0 fastDummies_1.7.6 survival_3.8-12
#> [55] kernlab_0.9-33 pillar_1.11.1 MatrixGenerics_1.25.0
#> [58] KernSmooth_2.23-27 plotly_4.12.1 generics_0.1.4
#> [61] RcppHNSW_0.7.0 sparseMatrixStats_1.25.0 scales_1.4.0
#> [64] globals_0.20.0 glue_1.8.1 maketools_1.3.2
#> [67] tools_4.6.2 sys_3.4.3 data.table_1.18.6.1
#> [70] RSpectra_0.16-2 fgsea_1.39.2 RANN_2.6.3
#> [73] buildtools_1.0.0 dotCall64_1.2 fastmatch_1.1-8
#> [76] cowplot_1.2.0 grid_4.6.2 tidyr_1.3.2
#> [79] nlme_3.1-172 patchwork_1.3.2 cli_3.6.6
#> [82] spam_2.11-4 segmented_2.2-2 viridisLite_0.4.3
#> [85] uwot_0.2.5 gtable_0.3.6 pls_2.9-0
#> [88] sass_0.4.10 digest_0.6.39 progressr_1.1.0
#> [91] ggrepel_0.9.8 htmlwidgets_1.6.4 farver_2.1.2
#> [94] htmltools_0.5.9 lifecycle_1.0.5 httr_1.4.9
#> [97] MASS_7.3-66