OSCR

ScQCenrich enables multi-metric quality control for single-cell RNA sequencing.

Code ↔ Paper

13 matches between paragraphs of the paper and lines of its authors' code, computed by the harvester (lexical-v1). Click a colored paragraph or line to see its counterpart.

12 blocks of code here have a permanent identifier (oscr:b:…), listed with the matches below: citable for good, with a page of its own. Select a match and press Cite to copy it. What a block identifier is.

The 13 matches
  1. [1] § Methods › scQCenrich workflow ↔ R/wrapper.R, lines 3 to 68 · score 0.94 · enrichment_plots, report_html, run_qc_pipeline, rescue_mode, low quality cells, qc_strength · block oscr:b:VXR7YQRY6JNK6-2 · Report a mismatch
  2. [2] § Methods › QC burden scoring and removal rules ↔ R/outliers.R, lines 285 to 333 · score 0.93 · avoid double, remove_quantile, tailed deviation, MALAT1 term, nFeature, pctMT · block oscr:b:0SC0Z5R0DBXYQ-R · Report a mismatch
  3. [3] § Methods › scQCenrich workflow ↔ inst/benchmarking.R, lines 456 to 538 · score 0.92 · enrichment_plots, qc_report.html, run_qc_pipeline, rescue_mode, qc_strength, qc_outputs · block oscr:b:1Y7Q2VDQ1YVVH-M · Report a mismatch
  4. [4] § Methods › Preliminary annotation and clustering ↔ inst/benchmarking.R, lines 86 to 127 · score 0.91 · FindClusters, FindNeighbors, RunPCA, ScaleData, FindVariableFeatures, NormalizeData · block oscr:b:RJ7PHM42YXAW5-M · Report a mismatch
  5. [5] § Methods › Model-based low-quality detection ↔ R/outliers.R, lines 212 to 283 · score 0.90 · minPts, stress_score, Mclust fails, nFeature, pctMT, QC scoring · block oscr:b:P1NGNDJX93VQH-M · Report a mismatch
  6. [6] § Methods › Preliminary annotation and clustering ↔ R/enrichment.R, lines 82 to 126 · score 0.90 · FindClusters, FindNeighbors, RunPCA, ScaleData, FindVariableFeatures, NormalizeData · block oscr:b:C3VTVQ3N4MCSA-L · Report a mismatch
  7. [7] § Methods › Coherence-based rescue ↔ R/rescue.R, lines 103 to 146 · score 0.90 · available metric gates, Intronic gating, median intronic, rescue score, pass fraction, healthy · block oscr:b:EQXKRSEVRRYYM-V · Report a mismatch
  8. [8] § Methods › QC burden scoring and removal rules ↔ R/filter.R, lines 46 to 99 · score 0.89 · remove_quantile, qc_strength, nFeature, pctMT, stress score, intronic fraction · block oscr:b:4GPZ29VYW5MQB-7 · Report a mismatch
  9. [9] § Methods › QC metrics calculation ↔ scripts/build_figure6_report_sources.R, lines 593 to 654 · score 0.81 · unspliced fraction, MALAT1 fraction, intronic fraction, stress score, detected genes, heat · block oscr:b:0WQ1F1847DT6C-N · Report a mismatch
  10. [10] § Methods › QC metrics calculation ↔ R/plots.R, lines 242 to 312 · score 0.80 · unspliced fraction, MALAT1 fraction, intronic fraction, stress score, detected genes, ratio · block oscr:b:7CQ7PJRKSS2N6-3 · Report a mismatch
  11. [11] § Methods › Default safeguards and final QC states ↔ R/filter.R, lines 397 to 481 · score 0.68 · pre rescue, Borderline cells, removed cell, demoted, cap, extreme · block oscr:b:H3G5C2MVNWF50-O · Report a mismatch
  12. [12] § Methods › Automated reporting ↔ scripts/build_figure6_report_sources.R, lines 593 to 654 · score 0.67 · MALAT1 fraction, intronic fraction, stress score, detected genes, GO, mt · block oscr:b:0WQ1F1847DT6C-N · Report a mismatch
  13. [13] § Methods › Splice-aware input generation and comparator methods ↔ inst/benchmarking.R, lines 349 to 410 · score 0.63 · DropletQC, nuclear fraction, baselines, tuned, intact, unspliced · block oscr:b:6F1S7BY8BSDMV-D · Report a mismatch

Paper

Loaded from Europe PMC by your browser; OSCR does not store it: doi.org · Europe PMC

The paper is loaded when this pane is shown.

The authors' code

R · 538 lines · 19 KB · other · 3 matches

  1. # install if missing ------------------------------------------------------
  2. # 1. Increase timeout for large Bioconductor/GitHub downloads
  3. options(timeout = 600)
  4. # 2. Define the packages by source
  5. cran_pkgs <- c("Seurat", "Matrix", "dplyr", "tidyr", "ggplot2", "cluster", "lme4", "remotes")
  6. bioc_pkgs <- c("scater", "SingleCellExperiment", "scuttle", "miQC", "scDblFinder",
  7. "celda", "SingleR", "celldex")
  8. github_pkgs <- c("DropletQC" = "powellgenomicslab/DropletQC")
  9. # 3. Ensure BiocManager and remotes are installed first
  10. if (!requireNamespace("BiocManager", quietly = TRUE)) install.packages("BiocManager")
  11. if (!requireNamespace("remotes", quietly = TRUE)) install.packages("remotes")
  12. # 4. Install missing CRAN packages
  13. missing_cran <- cran_pkgs[!(cran_pkgs %in% installed.packages()[, "Package"])]
  14. if (length(missing_cran)) install.packages(missing_cran)
  15. # 5. Install missing Bioconductor packages
  16. missing_bioc <- bioc_pkgs[!(bioc_pkgs %in% installed.packages()[, "Package"])]
  17. if (length(missing_bioc)) BiocManager::install(missing_bioc, ask = FALSE)
  18. # 6. Install missing GitHub packages (specifically DropletQC)
  19. if (!requireNamespace("DropletQC", quietly = TRUE)) {
  20. remotes::install_github(github_pkgs["DropletQC"])
  21. }
  22. # 7. Load all libraries
  23. all_pkgs <- c(cran_pkgs, bioc_pkgs, names(github_pkgs))
  24. lapply(all_pkgs, library, character.only = TRUE)
  25. # load lib ----------------------------------------------------------------
  26. library(scater) # addPerCellQCMetrics
  27. library(Seurat)
  28. library(SingleCellExperiment)
  29. library(scuttle)
  30. library(miQC) # mixtureModel, filterCells
  31. library(scDblFinder) # doublets
  32. library(celda) # DecontX
  33. library(SingleR)
  34. library(celldex) # biology annotation
  35. library(Matrix)
  36. library(dplyr)
  37. library(tidyr)
  38. library(ggplot2)
  39. library(cluster) # silhouette
  40. library(lme4) # mixed model
  41. library(DropletQC) # dropletqc
  42. options(timeout = 600)
  43. # Data path-----
  44. raw_counts_dir <- "path/to/filtered_feature_bc_matrix/"
  45. spliced_rds <- "path/to/testloom.rds"
  46. # human or mouse
  47. organism <- "human"
  48. organ <- c("Lung", "Blood")
  49. # preprocessing -------------------------------------------------------
  50. seurat_std <- CreateSeuratObject(counts = Read10X(raw_counts_dir), project = "QC_compare")
  51. seurat_sp <- readRDS(spliced_rds)
  52. # Helper: normalize cell barcodes to a comparable format
  53. .normalize_cells <- function(cells) {
  54. # drop sample prefix if present
  55. cells <- sub(".*:", "", cells)
  56. # drop trailing x if present
  57. cells <- sub("x$", "", cells)
  58. # drop trailing -1 if present
  59. cells <- sub("-1$", "", cells)
  60. cells
  61. }
  62. # Suppose you have:
  63. # seurat_std = your "standard" Seurat object (RNA assay)
  64. # seurat_sp = your velocity-style Seurat object (spliced/unspliced)
  65. # Normalize cell IDs
  66. std_ids <- .normalize_cells(colnames(seurat_std))
  67. sp_ids <- .normalize_cells(colnames(seurat_sp))
  68. # Find intersection
  69. common <- intersect(std_ids, sp_ids)
  70. message("Found ", length(common), " overlapping cells.")
  71. # Sample cells if needed (or fewer if less available)
  72. set.seed(123) # for reproducibility
  73. keep_ids <- sample(common, min(50000, length(common)))
  74. # Map back to original names in each object
  75. std_keep <- colnames(seurat_std)[.normalize_cells(colnames(seurat_std)) %in% keep_ids]
  76. sp_keep <- colnames(seurat_sp)[.normalize_cells(colnames(seurat_sp)) %in% keep_ids]
  77. # Subset
  78. seurat_std_small <- subset(seurat_std, cells = std_keep)
  79. seurat_sp_small <- subset(seurat_sp, cells = sp_keep)
  80. # Check dimensions
  81. dim(seurat_std_small) # genes x 500 (or fewer)
  82. dim(seurat_sp_small)
  83. seurat_std_small <- NormalizeData(seurat_std_small)
  84. seurat_std_small <- FindVariableFeatures(seurat_std_small)
  85. seurat_std_small <- ScaleData(seurat_std_small)
  86. seurat_std_small <- RunPCA(seurat_std_small)
  87. seurat_std_small <- RunUMAP(seurat_std_small, dims = 1:20, verbose = FALSE, seed.use = 1337)
  88. seurat_std_small <- FindNeighbors(seurat_std_small)
  89. seurat_std_small <- FindClusters(seurat_std_small, resolution = 0.4)
  90. # metric functions --------------------------------------------------------
  91. # ===========================
  92. # Helpers (species-agnostic mito detection)
  93. # ===========================
  94. .mito_patterns_default <- c("^MT-", "^mt-", "^Mt-") # human, mouse, mixed
  95. .mito_regex <- function(patterns) paste0("(", paste(patterns, collapse = "|"), ")")
  96. .get_mito_features <- function(seu, mito_patterns = NULL) {
  97. if (is.null(mito_patterns)) mito_patterns <- .mito_patterns_default
  98. genes <- rownames(seu)
  99. if (is.null(genes)) {
  100. return(character(0))
  101. }
  102. genes[grepl(.mito_regex(mito_patterns), genes)]
  103. }
  104. .get_mito_index_sce <- function(sce, mito_patterns = NULL) {
  105. if (is.null(mito_patterns)) mito_patterns <- .mito_patterns_default
  106. rn <- rownames(sce)
  107. if (is.null(rn)) {
  108. return(rep(FALSE, nrow(sce)))
  109. }
  110. grepl(.mito_regex(mito_patterns), rn)
  111. }
  112. # ===========================
  113. # 1) Utility: safe add meta by barcode (unchanged)
  114. # ===========================
  115. add_meta <- function(seu, df, suffix = NULL) {
  116. stopifnot(all(rownames(df) %in% colnames(seu)))
  117. if (!is.null(suffix)) colnames(df) <- paste0(colnames(df), "_", suffix)
  118. df <- df[colnames(seu), , drop = FALSE]
  119. Seurat::AddMetaData(seu, df)
  120. }
  121. # ---- META-ONLY MERGE (donor -> target) (minor namespace tighten; no behavior change) ----
  122. merge_meta_only <- function(target, donor, cols = NULL, suffix = "_donor",
  123. normalizer = .normalize_cells, verbose = TRUE) {
  124. stopifnot(inherits(target, "Seurat"), inherits(donor, "Seurat"))
  125. # maps of original -> normalized IDs
  126. map <- function(obj) {
  127. data.frame(
  128. orig = colnames(obj),
  129. norm = normalizer(colnames(obj)),
  130. stringsAsFactors = FALSE
  131. )
  132. }
  133. mT <- map(target)
  134. mD <- map(donor)
  135. # if normalization creates duplicate IDs, fall back to exact IDs
  136. if (any(duplicated(mT$norm)) || any(duplicated(mD$norm))) {
  137. if (verbose) message("Duplicates after normalization; falling back to exact barcode match.")
  138. mT$norm <- mT$orig
  139. mD$norm <- mD$orig
  140. }
  141. # intersection and index vectors
  142. common <- intersect(mT$norm, mD$norm)
  143. if (!length(common)) stop("No overlapping cells between target and donor after alignment.")
  144. idxT <- match(common, mT$norm)
  145. idxD <- match(common, mD$norm)
  146. # donor metadata (optionally subset columns)
  147. donor_meta <- [email hidden]
  148. if (!is.null(cols)) {
  149. missing_cols <- setdiff(cols, colnames(donor_meta))
  150. if (length(missing_cols)) warning("Skipping missing donor columns: ", paste(missing_cols, collapse = ", "))
  151. cols <- intersect(cols, colnames(donor_meta))
  152. donor_meta <- donor_meta[, cols, drop = FALSE]
  153. }
  154. # align rows to target’s order; fill NA where target has non-overlapping cells
  155. aligned <- donor_meta[mD$orig[idxD], , drop = FALSE]
  156. rownames(aligned) <- mT$orig[idxT]
  157. out <- matrix(NA,
  158. nrow = ncol(target), ncol = ncol(aligned),
  159. dimnames = list(colnames(target), colnames(aligned))
  160. )
  161. out[rownames(aligned), ] <- as.matrix(aligned)
  162. out <- as.data.frame(out, check.names = FALSE)
  163. # handle name collisions
  164. collide <- intersect(colnames([email hidden]), colnames(out))
  165. if (length(collide)) colnames(out)[match(collide, colnames(out))] <- paste0(collide, suffix)
  166. # add to target meta (by barcode rownames)
  167. target <- Seurat::AddMetaData(target, out)
  168. if (verbose) {
  169. message("Merged ", ncol(out), " column(s) onto target for ", length(common), " overlapping cells.")
  170. }
  171. return(target)
  172. }
  173. # ===========================
  174. # 2) Baseline: Seurat thresholds (species-agnostic via features list)
  175. # ===========================
  176. baseline_seurat <- function(seu, min_genes = 200, max_genes = 10000, max_mito = 10, mito_patterns = NULL) {
  177. mito_features <- .get_mito_features(seu, mito_patterns)
  178. if (length(mito_features)) {
  179. seu[["percent.mt"]] <- Seurat::PercentageFeatureSet(seu, features = mito_features)
  180. } else {
  181. warning("No mitochondrial features matched; setting percent.mt to NA.")
  182. seu[["percent.mt"]] <- NA_real_
  183. }
  184. keep <- with(
  185. [email hidden],
  186. nFeature_RNA > min_genes & nFeature_RNA < max_genes &
  187. (is.na(percent.mt) | percent.mt < max_mito)
  188. )
  189. add_meta(seu, data.frame(keep_seurat = keep, row.names = colnames(seu)))
  190. }
  191. # ===========================
  192. # 3) Baseline: scater/scuttle outlier rules (species-agnostic)
  193. # ===========================
  194. baseline_scater <- function(seu, mito_patterns = NULL) {
  195. sce <- as.SingleCellExperiment(seu)
  196. is_mito <- .get_mito_index_sce(sce, mito_patterns)
  197. sce <- scuttle::addPerCellQCMetrics(sce, subsets = list(mito = is_mito))
  198. low_lib <- scuttle::isOutlier(SummarizedExperiment::colData(sce)$sum, nmads = 3, type = "lower", log = TRUE)
  199. low_feat <- scuttle::isOutlier(SummarizedExperiment::colData(sce)$detected, nmads = 3, type = "lower", log = TRUE)
  200. high_mito <- scuttle::isOutlier(SummarizedExperiment::colData(sce)$subsets_mito_percent, nmads = 3, type = "higher")
  201. keep <- !(low_lib | low_feat | high_mito)
  202. add_meta(seu, data.frame(
  203. keep_scater = keep,
  204. subsets_mito_percent = SummarizedExperiment::colData(sce)$subsets_mito_percent,
  205. row.names = colnames(seu)
  206. ))
  207. }
  208. # ===========================
  209. # 4) Baseline: miQC (robust + species-agnostic; defaults unchanged)
  210. # ===========================
  211. baseline_miQC <- function(seu, mito_patterns = NULL, debug = TRUE) {
  212. stopifnot(inherits(seu, "Seurat"))
  213. sce <- as.SingleCellExperiment(seu)
  214. # ensure counts exist
  215. if (is.null(SummarizedExperiment::assay(sce, "counts"))) {
  216. SummarizedExperiment::assay(sce, "counts") <- Seurat::GetAssayData(seu, layer = "counts")
  217. }
  218. # Prepare required metrics (detected & subsets_mito_percent) in a species-agnostic way
  219. is_mito <- .get_mito_index_sce(sce, mito_patterns)
  220. sce <- scater::addPerCellQC(sce, subsets = list(mito = rownames(sce)[is_mito])) # adds 'detected' & 'subsets_mito_percent'
  221. det <- as.numeric(SummarizedExperiment::colData(sce)$detected)
  222. mito_pct <- as.numeric(SummarizedExperiment::colData(sce)$subsets_mito_percent) # 0–100
  223. # Guard against non-finite/degenerate inputs to flexmix
  224. bad <- !is.finite(det) | !is.finite(mito_pct)
  225. if (any(bad)) {
  226. if (isTRUE(debug)) message(sprintf("[miQC] dropping %d cells with non-finite QC metrics before fit", sum(bad)))
  227. sce <- sce[, !bad, drop = FALSE]
  228. }
  229. mito_now <- as.numeric(SummarizedExperiment::colData(sce)$subsets_mito_percent)
  230. if (length(unique(mito_now)) <= 1L) {
  231. # Avoid zero-variance crashes; if still degenerate, skip miQC gracefully
  232. if (isTRUE(debug)) message("[miQC] degenerate mitochondrial metric; skipping model and keeping all cells.")
  233. seu$miQC_prob <- NA_real_
  234. seu$keep_miQC <- TRUE
  235. return(seu)
  236. }
  237. # Fit miQC (linear → spline → 1D)
  238. mmod <- try(miQC::mixtureModel(sce, model_type = "linear"), silent = TRUE)
  239. if (inherits(mmod, "try-error")) {
  240. mmod <- try(miQC::mixtureModel(sce, model_type = "spline"), silent = TRUE)
  241. }
  242. if (inherits(mmod, "try-error")) {
  243. mmod <- try(miQC::mixtureModel(sce, model_type = "one_dimensional"), silent = TRUE)
  244. }
  245. if (inherits(mmod, "try-error")) {
  246. warning("miQC::mixtureModel failed after all model types; keeping all cells.")
  247. seu$miQC_prob <- NA_real_
  248. seu$keep_miQC <- TRUE
  249. return(seu)
  250. }
  251. # Posterior & choose “compromised” component (higher mito at median detected)
  252. post_mat <- flexmix::posterior(mmod)
  253. coef_mat <- flexmix::parameters(mmod)
  254. det_med <- stats::median(SummarizedExperiment::colData(sce)$detected, na.rm = TRUE)
  255. pick_comp <- function(coefs, det_med) {
  256. if (is.null(dim(coefs))) {
  257. return(2L)
  258. } # one_dimensional
  259. if (all(c("(Intercept)", "detected") %in% rownames(coefs))) {
  260. pred <- coefs["(Intercept)", ] + det_med * coefs["detected", ]
  261. return(which.max(pred)) # higher predicted mito% = compromised
  262. } else {
  263. return(2L)
  264. }
  265. }
  266. comp_k <- pick_comp(coef_mat, det_med)
  267. post_comp <- post_mat[, comp_k, drop = TRUE]
  268. names(post_comp) <- if (!is.null(rownames(post_mat))) rownames(post_mat) else colnames(sce)
  269. # Align back to Seurat barcodes
  270. seu$miQC_prob <- post_comp[match(colnames(seu), names(post_comp))]
  271. # Keep criterion: keep cells with posterior < 0.75 (miQC default)
  272. seu$keep_miQC <- seu$miQC_prob < 0.75
  273. if (isTRUE(debug)) {
  274. dir.create("qc_outputs", showWarnings = FALSE, recursive = TRUE)
  275. df <- data.frame(
  276. barcode = colnames(sce),
  277. detected = SummarizedExperiment::colData(sce)$detected,
  278. subsets_mito_percent = SummarizedExperiment::colData(sce)$subsets_mito_percent,
  279. miQC_prob = seu$miQC_prob[match(colnames(sce), colnames(seu))],
  280. keep_miQC = seu$keep_miQC[match(colnames(sce), colnames(seu))],
  281. stringsAsFactors = FALSE
  282. )
  283. utils::write.csv(df, file = "qc_outputs/miqc_input_metrics.csv", row.names = FALSE)
  284. }
  285. return(seu)
  286. }
  287. # ===========================
  288. # 7) Baseline: DropletQC damaged-only (requires nuclear_fraction + umi)
  289. # ===========================
  290. baseline_dropletqc <- function(seu, seurat_sp) {
  291. ## 1) Grab counts for spliced/unspliced and compute per-cell totals
  292. spliced <- GetAssayData(seurat_sp, assay = "spliced", layer = "counts")
  293. unspliced <- GetAssayData(seurat_sp, assay = "unspliced", layer = "counts")
  294. # Sanity: same cells in same order
  295. stopifnot(identical(colnames(spliced), colnames(unspliced)))
  296. exon_sum <- Matrix::colSums(spliced) # exonic counts
  297. intron_sum <- Matrix::colSums(unspliced) # intronic counts
  298. # DropletQC nuclear fraction = intronic / (intronic + exonic)
  299. nf <- intron_sum / (intron_sum + exon_sum + 1e-12)
  300. umi <- intron_sum + exon_sum # UMI for nf/umi plane (do NOT include ambiguous here)
  301. ## 2) Add to Seurat metadata
  302. seurat_sp$nuclear_fraction <- as.numeric(nf[colnames(seurat_sp)])
  303. seurat_sp$umi_nf_plane <- as.numeric(umi[colnames(seurat_sp)])
  304. # 1) Build the data frame for identify_empty_drops
  305. nf_umi <- data.frame(
  306. nf = as.numeric(seurat_sp$nuclear_fraction),
  307. umi = as.numeric(seurat_sp$umi_nf_plane),
  308. row.names = colnames(seurat_sp)
  309. )
  310. # Optional: drop any rows with NA (NF/UMI)
  311. nf_umi <- nf_umi[complete.cases(nf_umi[, 1:2]), ]
  312. # 2) Run identify_empty_drops
  313. ed <- identify_empty_drops(nf_umi = nf_umi, include_plot = FALSE)
  314. # 3) Add cell_type for identify_damaged_cells using the standard object's clusters
  315. # Use .normalize_cells internally if names dont perfectly match, but here they should due to subset alignment
  316. ed$cell_type <- seu$seurat_clusters[match(.normalize_cells(rownames(ed)), .normalize_cells(colnames(seu)))]
  317. # Drop any cell types that mapped to NA before pushing into identify_damaged_cells, else EM will crash
  318. ed <- ed[!is.na(ed$cell_type), ]
  319. # 4) Run DropletQC’s damaged-cell classifier
  320. dc <- identify_damaged_cells(
  321. ed, # min NF separation between intact vs damaged (tune if needed)
  322. verbose = TRUE,
  323. output_plots = T
  324. )
  325. dc$plots
  326. table(dc[[1]]$cell_status)
  327. # 5) Save calls back to Seurat metadata
  328. calls <- dc[[1]] # first list element = annotated table
  329. seurat_sp$DropletQC_status <- calls$cell_status[match(colnames(seurat_sp), rownames(calls))]
  330. seurat_sp$DropletQC_status[is.na(seurat_sp$DropletQC_status)] <- "unknown_NA"
  331. # labels can be "cell", "empty_droplet", or "damaged_cell"
  332. kept_dq <- seurat_sp$DropletQC_status == "cell"
  333. kept_dq[is.na(kept_dq)] <- FALSE
  334. seurat_sp$keep_dropletqc <- kept_dq
  335. want <- c("nuclear_fraction", "umi_nf_plane", "DropletQC_status", "keep_dropletqc")
  336. seu_merged_meta <- merge_meta_only(seu, seurat_sp, cols = want, suffix = "")
  337. return(seu_merged_meta)
  338. }
  339. ## qc plot -----------------------------------------------------------------
  340. seurat_std_small <- baseline_seurat(seurat_std_small)
  341. table(seurat_std_small$keep_seurat)
  342. p <- DimPlot(seurat_std_small, group.by = "keep_seurat", cols = c("red", "gray"), pt.size = 0.5, alpha = 0.5) +
  343. ggtitle("Seurat") +
  344. NoLegend()
  345. ggsave("keep_seurat.png", p, width = 4, height = 4)
  346. seurat_std_small <- baseline_scater(seurat_std_small)
  347. table(seurat_std_small$keep_scater)
  348. p <- DimPlot(seurat_std_small, group.by = "keep_scater", cols = c("red", "gray"), pt.size = 0.5, alpha = 0.5) +
  349. ggtitle("scater") +
  350. NoLegend()
  351. ggsave("keep_scater.png", p, width = 4, height = 4)
  352. seurat_std_small <- baseline_miQC(seurat_std_small)
  353. if (table(seurat_std_small$keep_miQC)[1] > table(seurat_std_small$keep_miQC)[2]) {
  354. seurat_std_small$keep_miQC <- !seurat_std_small$keep_miQC
  355. }
  356. table(seurat_std_small$keep_miQC)
  357. p <- DimPlot(seurat_std_small, group.by = "keep_miQC", cols = c("red", "gray"), pt.size = 0.5, alpha = 0.5) +
  358. ggtitle("miQC") +
  359. NoLegend()
  360. p
  361. ggsave("keep_miqc.png", p, width = 4, height = 4)
  362. table(seurat_std_small$keep_miQC)
  363. seurat_std_small <- baseline_dropletqc(seurat_std_small, seurat_sp_small)
  364. table(seurat_std_small$keep_dropletqc)
  365. p <- DimPlot(seurat_std_small, group.by = "keep_dropletqc", cols = c("red", "gray"), pt.size = 0.5, alpha = 0.5) +
  366. ggtitle("DropletQC") +
  367. NoLegend()
  368. p
  369. ggsave("keep_dq.png", p, width = 4, height = 4)
  370. # run scqc ----------------------------------------------------------------
  371. library(scQCenrich)
  372. res <- run_qc_pipeline(
  373. obj = seurat_std_small, # normal Seurat for baseline QC
  374. species = organism,
  375. assay = "RNA",
  376. method = "gmm",
  377. # external splicing sources:
  378. spliced_obj = seurat_sp_small,
  379. spliced_assay = "spliced",
  380. spliced_layer = "counts",
  381. unspliced_obj = seurat_sp_small,
  382. unspliced_assay = "unspliced",
  383. unspliced_layer = "counts",
  384. report_html = T,
  385. report_file = "qc_outputs/qc_report.html",
  386. debug = TRUE,
  387. annot_method = "marker_score",
  388. tissue = organ,
  389. marker_method = "findmarkers",
  390. doublets = "none",
  391. enrichment_plots = T
  392. # qc_strength = "strict"
  393. )
  394. if (!is.null(res$report)) browseURL(res$report)
  395. seu <- res$obj_all
  396. seu$keep_enrich <- seu$qc_status != "remove"
  397. seurat_std_small$keep_enrich <- seu$keep_enrich[match(colnames(seurat_std_small), colnames(seu))]
  398. p <- DimPlot(seu, group.by = "keep_enrich", cols = c("red", "gray"), pt.size = 0.5, alpha = 0.5) +
  399. ggtitle("scQCenrich") +
  400. NoLegend()
  401. p
  402. ggsave("keep_enrich.png", p, width = 4, height = 4)
  403. # ---- scQCenrich WITHOUT splice data -------------------------
  404. cat("\n--- Running scQCenrich without splice data (MALAT1 proxy) ---\n")
  405. met_nosplice <- calcQCmetrics(
  406. obj = seurat_std_small,
  407. species = organism,
  408. assay = "RNA",
  409. add_to_meta = FALSE
  410. # spliced_obj intentionally omitted -> MALAT1 proxy activates
  411. )
  412. cat(
  413. "intronic_frac all-NA (confirming no splice used):",
  414. all(is.na(met_nosplice$intronic_frac)), "\n"
  415. )
  416. cat("MALAT1_frac range:", round(range(met_nosplice$MALAT1_frac, na.rm = TRUE), 4), "\n")
  417. res_nosplice <- flagLowQuality(
  418. metrics = met_nosplice,
  419. method = "gmm",
  420. qc_strength = "auto",
  421. rescue_mode = "lenient"
  422. )
  423. # Align barcodes back to seurat_std_small (metrics rownames == colnames(seu))
  424. seurat_std_small$keep_enrich_nosplice <- res_nosplice$qc_status[
  425. match(colnames(seurat_std_small), rownames(res_nosplice))
  426. ] != "remove"
  427. cat("kept (no splice):", sum(seurat_std_small$keep_enrich_nosplice, na.rm = TRUE), "\n")
  428. cat("removed (no splice):", sum(!seurat_std_small$keep_enrich_nosplice, na.rm = TRUE), "\n")
  429. p_nosplice <- DimPlot(
  430. seurat_std_small,
  431. group.by = "keep_enrich_nosplice",
  432. cols = c("red", "gray"), pt.size = 0.5, alpha = 0.5
  433. ) +
  434. ggtitle("scQCenrich (no splice)") +
  435. NoLegend()
  436. p_nosplice
  437. ggsave("keep_enrich_nosplice.png", p_nosplice, width = 4, height = 4)

benchmarking.R at commit fa00b9c, under other · at the source

Overview

Authors: Yuanyuan Liu1,2, Cheng Yang3, Chenghui Wang4, Mingwang Zhang5, Kai Luo6, Lihua Wu6, Xiufeng Xie6
ORCID iDs: Yuanyuan Liu
  1. The Seventh Medical Center of Chinese PLA General Hospital, Beijing, China
  2. PLA Medical School, Beijing, China
  3. Reahealth Inc, Beijing, China
  4. Bioinformatics Center of AMMS, Beijing, China
  5. Department of Dermatology, Southwest Hospital, Army Medical University, Chongqing, China
  6. Biological Therapy Center, Seventh Medical Center of Chinese PLA General Hospital, Beijing, China
Journal: Communications biology, volume 9, issue 1, article 864
Dates: received 13 January 2026; accepted 21 May 2026; published online 24 June 2026
Type: Research article · Language: English
License: CC BY-NC-ND
Identifiers: DOI 10.1038/s42003-026-10382-x · PMID 42342867 · PMCID PMC13315592 · OpenAlex W7165783598
Open access: gold, a free copy (OpenAlex)
Status: code verified (how the code is found and verified)
Categories: genetics / omics (modality), human (organism), mouse (organism), cellular / molecular (subfield)
Methods: Statistics, Smoothing, state filtering, decompositions, Connectivity, Preprocessing
Keywords: Data processing, RNA sequencing
MeSH: Sequence Analysis, RNA*, Single-Cell Analysis*, Animals, Humans, Mice, Quality Control, Single-Cell Gene Expression Analysis (* major topic)
Topic: Single-cell and spatial transcriptomics (Molecular Biology, Biochemistry, Genetics and Molecular Biology), according to OpenAlex
Citations: cited by 1 paper (Europe PMC); 26 references in the paper

Abstract

The abstract is not reproduced here: the paper's license (CC BY-NC-ND) does not allow it. Read it in the paper, at the publisher or on Europe PMC.

Repositories

Its files are read in the Code ↔ Paper reader above, with 13 matches between paragraphs and lines of code.

lemonlyy755/scQCenrich

License: other
State: the link answers, verified on 27 September 2026
Evidence: files inventoried
Commit: fa00b9c0126bdaa5ba36a6b90a28c734d5397a6b, 7 May 2026
Languages: R (28)
Size: 75 files, 28 scripts
Software Heritage: not archived
Found in: “Code availability”
Holds: README, license file, CITATION.cff, environment (DESCRIPTION), tests, continuous integration, documentation, 3 notebooks
Tools: Seurat (17 files), ggplot2 (7 files), tidyverse (5 files), clusterProfiler (3 files), SingleCellExperiment (3 files), patchwork (2 files), circlize (1 file), ComplexHeatmap (1 file), lme4 (1 file), reshape2 (1 file)
Availability: 1 check, the latest on 27 September 2026: the link answers
  • 27 September 2026: the link answers
31 files

Zenodo 20050798

License: CC-BY-4.0
State: the link answers, verified on 27 September 2026
Evidence: files inventoried
Size: 1 file
Software Heritage: not checked
Found in: the references
Not found: README, license file, CITATION.cff, environment file, tests, continuous integration, documentation
Tools: Seurat (17 files), ggplot2 (7 files), tidyverse (5 files), clusterProfiler (3 files), SingleCellExperiment (3 files), patchwork (2 files), circlize (1 file), ComplexHeatmap (1 file), lme4 (1 file), reshape2 (1 file)
Availability: 1 check, the latest on 27 September 2026: the link answers (HTTP 200)
  • 27 September 2026: the link answers (HTTP 200)
31 files
At the source:

Code availability statement

The paper has a code availability statement. Its license (CC BY-NC-ND) does not allow reproducing it here; in short, from what the harvester recognized in it:

Read it in the paper: doi.org/10.1038/s42003-026-10382-x.

Tracing map

Proposed by the machine: these links were found in the paper and verified at the source, without human review. The map will receive a Zenodo DOI once one of the paper's authors has validated it with their ORCID.

What the map holds:

  • 2 repositories of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
  • 56 scripts, each with its path and the digest of its content;
  • 13 matches between paragraphs of the paper and lines of the code (method lexical-v1);
  • neither the text of the paper nor the code itself.

Its JSON (tracing-map.json) is deposited on Zenodo with its DOI once the map is validated.

Data

Datasets cited

Data availability statement

The paper has a data availability statement. Its license (CC BY-NC-ND) does not allow reproducing it here; in short, from what the harvester recognized in it:

Read it in the paper: doi.org/10.1038/s42003-026-10382-x.

Versions

The history of this record: each version stored by the harvester or made by a correction of its authors or of the maintainers of its code, and what changed in its facts. The texts of the paper (its abstract, its availability statements) are not part of it; versions that changed only those are not listed.

Version 1, 27 September 2026: the first record

Recorded: type, language, journal, volume, issue, pages, dates, 7 authors, 2 keywords, 7 MeSH terms, 22 references.

Cite

This paper

Liu, Y., Yang, C., Wang, C., Zhang, M., Luo, K., Wu, L., & Xie, X. (2026). ScQCenrich enables multi-metric quality control for single-cell RNA sequencing. Communications biology, 9(1), 864. https://doi.org/10.1038/s42003-026-10382-x

BibTeX

@article{liu2026scqcenrich,
author = {Liu, Yuanyuan and Yang, Cheng and Wang, Chenghui and Zhang, Mingwang and Luo, Kai and Wu, Lihua and Xie, Xiufeng},
title = {{ScQCenrich enables multi-metric quality control for single-cell RNA sequencing}},
journal = {Communications biology},
year = {2026},
month = jun,
volume = {9},
number = {1},
pages = {864},
publisher = {Nature Publishing Group},
issn = {2399-3642},
doi = {10.1038/s42003-026-10382-x},
url = {https://doi.org/10.1038/s42003-026-10382-x},
pmid = {42342867},
pmcid = {PMC13315592}
}

RIS

TY - JOUR
AU - Liu, Yuanyuan
AU - Yang, Cheng
AU - Wang, Chenghui
AU - Zhang, Mingwang
AU - Luo, Kai
AU - Wu, Lihua
AU - Xie, Xiufeng
TI - ScQCenrich enables multi-metric quality control for single-cell RNA sequencing
T2 - Communications biology
J2 - Commun Biol
PY - 2026
DA - 2026/06/24
VL - 9
IS - 1
SP - 864
SN - 2399-3642
PB - Nature Publishing Group
DO - 10.1038/s42003-026-10382-x
UR - https://doi.org/10.1038/s42003-026-10382-x
LA - en
ER -

CSL-JSON

{
"id": "10.1038/s42003-026-10382-x",
"type": "article-journal",
"title": "ScQCenrich enables multi-metric quality control for single-cell RNA sequencing",
"container-title": "Communications biology",
"author": [
{
"family": "Liu",
"given": "Yuanyuan"
},
{
"family": "Yang",
"given": "Cheng"
},
{
"family": "Wang",
"given": "Chenghui"
},
{
"family": "Zhang",
"given": "Mingwang"
},
{
"family": "Luo",
"given": "Kai"
},
{
"family": "Wu",
"given": "Lihua"
},
{
"family": "Xie",
"given": "Xiufeng"
}
],
"container-title-short": "Commun Biol",
"volume": "9",
"issue": "1",
"page": "864",
"DOI": "10.1038/s42003-026-10382-x",
"PMID": "42342867",
"PMCID": "PMC13315592",
"ISSN": "2399-3642",
"publisher": "Nature Publishing Group",
"URL": "https://doi.org/10.1038/s42003-026-10382-x",
"language": "en",
"issued": {
"date-parts": [
[
2026,
6,
24
]
]
}
}

The tracing map gets a citation of its own once an author has validated it and it has a DOI.

Similar papers

The papers with a page that share the most with this one: the tools found in their code, their categories, datasets, cited references and authors, the rarest counting most.

[1] doi:10.1016/j.crmeth.2026.101337 [code]
Comparative analysis of nuclei isolation methods for brain single-nucleus RNA sequencing.
Journal: Cell reports methods
In common: circlize, ComplexHeatmap, Seurat, 3 other tools, genetics / omics, mouse, cellular / molecular, 7 references
[2] doi:10.1084/jem.20232357 [code]
Microglia and CD8+ T cell activation precede neuronal loss in a murine model of spastic paraplegia 15.
Journal: The Journal of experimental medicine
In common: SingleCellExperiment, circlize, clusterProfiler, 6 other tools, mouse, cellular / molecular, 5 references
[3] doi:10.1038/s41467-024-45165-7 [code]
Single nuclei transcriptomics in human and non-human primate striatum in opioid use disorder.
Journal: Nature communications
In common: SingleCellExperiment, circlize, ComplexHeatmap, 5 other tools, genetics / omics, cellular / molecular, 3 references
[4] doi:10.1186/s40478-023-01568-z [code]
Brain matters: unveiling the distinct contributions of region, age, and sex to glia diversity and CNS function.
Journal: Acta neuropathologica communications
In common: SingleCellExperiment, clusterProfiler, Seurat, 5 other tools, mouse, cellular / molecular, 4 references
[5] doi:10.1186/s12964-024-01686-8 [code]
Altered glia-neuron communication in Alzheimer's Disease affects WNT, p53, and NFkB Signaling determined by snRNA-seq.
Journal: Cell communication and signaling : CCS
In common: SingleCellExperiment, circlize, ComplexHeatmap, 5 other tools, genetics / omics, cellular / molecular, 3 references
[6] doi:10.1016/j.xops.2023.100335 [code]
Comparative Analysis of Single-cell and Single-nucleus RNA-sequencing in a Rabbit Model of Retinal Detachment-related Proliferative Vitreoretinopathy.
Journal: Ophthalmology science
In common: SingleCellExperiment, circlize, clusterProfiler, 5 other tools, genetics / omics, cellular / molecular, 3 references
[7] doi:10.1007/s00401-025-02913-3 [code]
Single-cell transcriptomic landscape of the neuroimmune compartment in amyotrophic lateral sclerosis brain and spinal cord.
Journal: Acta neuropathologica
In common: circlize, clusterProfiler, ComplexHeatmap, 5 other tools, genetics / omics, cellular / molecular, 3 references
[8] doi:10.1038/s41467-026-76232-w [code]
Th17 effector cytokines induce shared and distinct microglial and endothelial cell responses in a mouse model for post-streptococcal encephalitis.
Journal: Nature communications
In common: SingleCellExperiment, circlize, clusterProfiler, 6 other tools, genetics / omics, mouse, cellular / molecular, 1 reference
[9] doi:10.15252/embr.202256233 [code]
DOT1L activity affects neural stem cell division mode and reduces differentiation and ASNS expression.
Journal: EMBO reports
In common: SingleCellExperiment, circlize, clusterProfiler, 6 other tools, 2 references
[10] doi:10.1016/j.jcmgh.2025.101590 [code]
Single Cell Profiling in the Sox10&lt;sup&gt;Dom&lt;/sup&gt; Hirschsprung Mouse Implicates Hox Genes in Enteric Neuron Trajectory Allocation.
Journal: Cellular and molecular gastroenterology and hepatology
In common: clusterProfiler, ComplexHeatmap, Seurat, 5 other tools, genetics / omics, mouse, cellular / molecular, 3 references

Contribute

The authors of this paper can claim it, correct its record and validate its tracing map, and the maintainers of its code (its owner, or a public member of its organization) correct what it says of their repository; anyone signed in can ask for its removal. Every request goes to OSCR's own machine, which answers it; your account page follows them.

Sign in with ORCID to claim this paper as one of its authors, correct its record or validate its tracing map: when the paper's metadata lists your ORCID iD, you are recognized at once. Maintainers of its code: sign in with GitHub, then claim the repository on your account page.

Add the badge to the code's README

OSCR: the badge of this paper

If you are an author or a maintainer of this paper's code, you can add this badge. It says what OSCR knows of the paper (its code, its validated tracing map) and links the code to this page. Paste one of these snippets under the README's title. Keep the two marks around it, so that the badge can be replaced in place and is never added twice. OSCR changes nothing in your repository.

Markdown
<!-- oscr-badge:start -->
[![OSCR](https://openscicode.org/badge/doi/10.1038/s42003-026-10382-x.svg)](https://openscicode.org/badge/doi/10.1038/s42003-026-10382-x)
<!-- oscr-badge:end -->
reStructuredText
.. oscr-badge:start

.. image:: https://openscicode.org/badge/doi/10.1038/s42003-026-10382-x.svg
   :target: https://openscicode.org/badge/doi/10.1038/s42003-026-10382-x
   :alt: OSCR

.. oscr-badge:end
HTML
<!-- oscr-badge:start -->
<a href="https://openscicode.org/badge/doi/10.1038/s42003-026-10382-x"><img src="https://openscicode.org/badge/doi/10.1038/s42003-026-10382-x.svg" alt="OSCR"></a>
<!-- oscr-badge:end -->

On GitHub, open the README, choose Edit (the pencil), paste the snippet under the title, then "Commit changes".

If you choose to, you can have the badge kept up to date for you, with oscr badge --write from the command line or with the GitHub Action in your repository's workflows. Every other form and option (a card, AsciiDoc, LaTeX, shields.io) is on the badge page.

Request its removal

To ask OSCR to remove this record, the copies of its authors' scripts or its tracing map, use the removal request page: signed in, you say who you are, what to remove and why, then review and confirm the request. Published rules decide every request (how).

Discussion, reproductions, activity

Discussion: code errors and mismatches between the code and the paper about this paper and its code, from readers and its authors, beside the paper and its tracing map.

Report a mismatch between the code and the paper · Report a code error (signed in)

Reproductions: reports from readers who ran the authors' code and did not get the paper's result, what they ran, with which environment, commit and data.

Report a reproduction failure (signed in)

Versions of its code: the releases of its code tied to a version of this paper (the preprint, the accepted manuscript, the version of record…), each with the tracing map versioned with it.

Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.