Introduction
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:
- Classification of cells into drug-sensitive and drug-resistant subpopulations
- Prioritization of therapeutic agents based on tumor cell sensitivity
- Prediction of drug side effects on non-malignant cells
- Identification of synergistic drug combinations
This vignette provides a quick introduction to get you started with scPharm.
Installation
# From R-universe (recommended)
install.packages("scPharm", repos = "https://zaoqu-liu.r-universe.dev")
# From GitHub
remotes::install_github("Zaoqu-Liu/scPharm")Prepare Example Data
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)Basic Workflow
Step 1: Identify Pharmacological Subpopulations
The 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
)Step 3: Predict Drug Side Effects
For tissue samples, estimate potential toxicity on non-malignant cells:
# Compute drug side effect scores
dse_scores <- scPharmDse(result)
# View results
head(dse_scores)Step 4: Identify Drug Combinations
Find synergistic drug pairs targeting complementary resistant populations:
# Identify combinations for top 5 drugs
combos <- scPharmCombo(result, dr_scores, topN = 5)
# View combination results
names(combos)Understanding Output
Cell Labels
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) |
Parameter Guidelines
| 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 |
Supported Cancer Types
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.
Next Steps
- See the Algorithm Details vignette for methodology
- See the Visualization Guide for plotting
- See the Advanced Usage for complex analyses
Session Info
sessionInfo()
#> R version 4.4.0 (2024-04-24)
#> Platform: aarch64-apple-darwin20
#> Running under: macOS 15.6.1
#>
#> Matrix products: default
#> BLAS: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRblas.0.dylib
#> LAPACK: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.12.0
#>
#> locale:
#> [1] C
#>
#> time zone: Asia/Shanghai
#> tzcode source: internal
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] ggplot2_4.0.1 scPharm_1.0.5 SeuratObject_4.1.4 Seurat_4.4.0
#>
#> loaded via a namespace (and not attached):
#> [1] RcppAnnoy_0.0.23 splines_4.4.0
#> [3] later_1.4.5 tibble_3.3.1
#> [5] polyclip_1.10-7 lifecycle_1.0.5
#> [7] globals_0.18.0 lattice_0.22-7
#> [9] MASS_7.3-65 magrittr_2.0.4
#> [11] plotly_4.11.0 sass_0.4.10
#> [13] rmarkdown_2.30 jquerylib_0.1.4
#> [15] yaml_2.3.12 httpuv_1.6.16
#> [17] otel_0.2.0 sctransform_0.4.3
#> [19] askpass_1.2.1 spam_2.11-3
#> [21] sp_2.2-0 spatstat.sparse_3.1-0
#> [23] reticulate_1.44.1 cowplot_1.2.0
#> [25] pbapply_1.7-4 RColorBrewer_1.1-3
#> [27] abind_1.4-8 zlibbioc_1.52.0
#> [29] Rtsne_0.17 GenomicRanges_1.58.0
#> [31] mixtools_2.0.0.1 purrr_1.2.1
#> [33] BiocGenerics_0.52.0 GenomeInfoDbData_1.2.13
#> [35] IRanges_2.40.1 S4Vectors_0.44.0
#> [37] ggrepel_0.9.6 irlba_2.3.5.1
#> [39] listenv_0.10.0 spatstat.utils_3.2-1
#> [41] umap_0.2.10.0 goftest_1.2-3
#> [43] RSpectra_0.16-2 spatstat.random_3.4-4
#> [45] fitdistrplus_1.2-5 parallelly_1.46.1
#> [47] pkgdown_2.1.3 leiden_0.4.3.1
#> [49] codetools_0.2-20 DelayedArray_0.32.0
#> [51] scuttle_1.16.0 tidyselect_1.2.1
#> [53] UCSC.utils_1.2.0 farver_2.1.2
#> [55] ScaledMatrix_1.14.0 viridis_0.6.5
#> [57] matrixStats_1.5.0 stats4_4.4.0
#> [59] spatstat.explore_3.7-0 jsonlite_2.0.0
#> [61] BiocNeighbors_2.0.1 progressr_0.18.0
#> [63] ggridges_0.5.7 survival_3.8-3
#> [65] scater_1.34.1 systemfonts_1.3.1
#> [67] tictoc_1.2.1 segmented_2.1-4
#> [69] tools_4.4.0 ragg_1.5.0
#> [71] ica_1.0-3 Rcpp_1.1.1
#> [73] glue_1.8.0 gridExtra_2.3
#> [75] SparseArray_1.6.2 xfun_0.56
#> [77] MatrixGenerics_1.18.1 GenomeInfoDb_1.42.3
#> [79] dplyr_1.1.4 withr_3.0.2
#> [81] fastmap_1.2.0 openssl_2.3.4
#> [83] digest_0.6.39 rsvd_1.0.5
#> [85] R6_2.6.1 mime_0.13
#> [87] textshaping_1.0.4 scattermore_1.2
#> [89] tensor_1.5.1 dichromat_2.0-0.1
#> [91] spatstat.data_3.1-9 tidyr_1.3.2
#> [93] generics_0.1.4 data.table_1.18.0
#> [95] httr_1.4.7 htmlwidgets_1.6.4
#> [97] S4Arrays_1.6.0 uwot_0.2.4
#> [99] pkgconfig_2.0.3 gtable_0.3.6
#> [101] lmtest_0.9-40 S7_0.2.1
#> [103] SingleCellExperiment_1.28.1 XVector_0.46.0
#> [105] htmltools_0.5.9 dotCall64_1.2
#> [107] fgsea_1.32.4 scales_1.4.0
#> [109] Biobase_2.66.0 png_0.1-8
#> [111] spatstat.univar_3.1-6 knitr_1.51
#> [113] reshape2_1.4.5 nlme_3.1-168
#> [115] cachem_1.1.0 zoo_1.8-15
#> [117] stringr_1.6.0 KernSmooth_2.23-26
#> [119] parallel_4.4.0 miniUI_0.1.2
#> [121] vipor_0.4.7 desc_1.4.3
#> [123] pillar_1.11.1 grid_4.4.0
#> [125] vctrs_0.7.1 RANN_2.6.2
#> [127] promises_1.5.0 BiocSingular_1.22.0
#> [129] beachmat_2.22.0 xtable_1.8-4
#> [131] cluster_2.1.8.1 beeswarm_0.4.0
#> [133] CelliD_1.14.0 evaluate_1.0.5
#> [135] cli_3.6.5 compiler_4.4.0
#> [137] rlang_1.1.7 crayon_1.5.3
#> [139] future.apply_1.20.1 RcppArmadillo_15.2.3-1
#> [141] plyr_1.8.9 fs_1.6.6
#> [143] ggbeeswarm_0.7.3 stringi_1.8.7
#> [145] viridisLite_0.4.2 deldir_2.0-4
#> [147] BiocParallel_1.40.2 lazyeval_0.2.2
#> [149] spatstat.geom_3.7-0 Matrix_1.7-4
#> [151] patchwork_1.3.2 sparseMatrixStats_1.18.0
#> [153] future_1.69.0 shiny_1.12.1
#> [155] SummarizedExperiment_1.36.0 kernlab_0.9-33
#> [157] ROCR_1.0-12 igraph_2.2.1
#> [159] bslib_0.9.0 fastmatch_1.1-8