From 59740458e4b817fbbc2c641796519e43dc5ca42a Mon Sep 17 00:00:00 2001 From: Maksim Kholmatov Date: Wed, 19 Nov 2025 15:51:08 +0100 Subject: [PATCH 1/3] Correct mitochondrial gene identification. --- inst/book/quality-control.Rmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/book/quality-control.Rmd b/inst/book/quality-control.Rmd index e236406..d072bf5 100644 --- a/inst/book/quality-control.Rmd +++ b/inst/book/quality-control.Rmd @@ -72,7 +72,7 @@ Finally, the `altexps_ERCC_percent` column contains the percentage of reads mapp library(SingleCellExperiment) # Identifying the mitochondrial transcripts in our SingleCellExperiment. location <- rowRanges(sce.416b) -is.mito <- any(seqnames(location)=="MT") +is.mito <- as.character(seqnames(location))=="MT" library(scuttle) df <- perCellQCMetrics(sce.416b, subsets=list(Mito=is.mito)) From c7ae896775f9830f89e6a1a5b773f1fbe5e26281 Mon Sep 17 00:00:00 2001 From: Maksim Kholmatov Date: Sun, 23 Nov 2025 21:17:23 +0100 Subject: [PATCH 2/3] Switch to gene names This should work for both GRanges object and a GRangesList object, if the latter doesn't actually have any hierarchical structure --- inst/book/quality-control.Rmd | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/inst/book/quality-control.Rmd b/inst/book/quality-control.Rmd index d072bf5..703f1eb 100644 --- a/inst/book/quality-control.Rmd +++ b/inst/book/quality-control.Rmd @@ -73,9 +73,10 @@ library(SingleCellExperiment) # Identifying the mitochondrial transcripts in our SingleCellExperiment. location <- rowRanges(sce.416b) is.mito <- as.character(seqnames(location))=="MT" +mito.genes <- rownames(sce.416b)[which(is.mito)] library(scuttle) -df <- perCellQCMetrics(sce.416b, subsets=list(Mito=is.mito)) +df <- perCellQCMetrics(sce.416b, subsets=list(Mito=mito.genes)) summary(df$sum) summary(df$detected) summary(df$subsets_Mito_percent) @@ -87,7 +88,7 @@ This computes and appends the per-cell QC statistics to the `colData` of the `Si allowing us to retain all relevant information in a single object for later manipulation. ```{r} -sce.416b <- addPerCellQCMetrics(sce.416b, subsets=list(Mito=is.mito)) +sce.416b <- addPerCellQCMetrics(sce.416b, subsets=list(Mito=mito.genes)) colnames(colData(sce.416b)) ``` From e2b112dc12c1e99345b4889e6aaca8bed622547c Mon Sep 17 00:00:00 2001 From: Maksim Kholmatov Date: Mon, 24 Nov 2025 12:24:49 +0100 Subject: [PATCH 3/3] Use sapply to handle both object types Revert "Switch to gene names" This reverts commit c7ae896775f9830f89e6a1a5b773f1fbe5e26281. --- inst/book/quality-control.Rmd | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/inst/book/quality-control.Rmd b/inst/book/quality-control.Rmd index 703f1eb..ccbee9c 100644 --- a/inst/book/quality-control.Rmd +++ b/inst/book/quality-control.Rmd @@ -72,11 +72,10 @@ Finally, the `altexps_ERCC_percent` column contains the percentage of reads mapp library(SingleCellExperiment) # Identifying the mitochondrial transcripts in our SingleCellExperiment. location <- rowRanges(sce.416b) -is.mito <- as.character(seqnames(location))=="MT" -mito.genes <- rownames(sce.416b)[which(is.mito)] +is.mito <- sapply(seqnames(location)=="MT", any) library(scuttle) -df <- perCellQCMetrics(sce.416b, subsets=list(Mito=mito.genes)) +df <- perCellQCMetrics(sce.416b, subsets=list(Mito=is.mito)) summary(df$sum) summary(df$detected) summary(df$subsets_Mito_percent) @@ -88,7 +87,7 @@ This computes and appends the per-cell QC statistics to the `colData` of the `Si allowing us to retain all relevant information in a single object for later manipulation. ```{r} -sce.416b <- addPerCellQCMetrics(sce.416b, subsets=list(Mito=mito.genes)) +sce.416b <- addPerCellQCMetrics(sce.416b, subsets=list(Mito=is.mito)) colnames(colData(sce.416b)) ```