<p>Ok I have figured it out and I am sharing this in case anyone can get help. I used</p>
<pre><code>sce &lt;-addPerCellQC(sce)
</code></pre>
<p>which calculated the QC for all the altexps also and adds them to the colData.</p>

CC BY-SA 4.0
2020-07-24T18:33:03.087Z
2020-07-24T18:33:03.087Z
Abhay
<p>It would be helpful if you can provide the error message.
Guessing from your codes, it's possible that the alternative experiments weren't set correctly. My suggestion:</p>

<pre><code>altExp(sce, "spike-in") &lt;- SummarizedExperiment(assays=list(counts=as.matrix(SpikeIn)))
altExp(sce, "MTgenes") &lt;- SummarizedExperiment(assays=list(counts=as.matrix(MTgenes)))
</code></pre>

<p>If you're using altExp, the subsets argument in perCellQCMetrics is unnecessary in this case.</p>

<pre><code>perCellQCMetrics(sce,
exprs_values="counts",
use_altexps=TRUE)
</code></pre>

CC BY-SA 4.0
2020-06-03T17:05:08.840Z
2020-06-03T17:17:06.060Z
2020-06-03T17:17:06.060Z
mattcwh
<p>I am trying to follow a tutorial from Sanger institute (from May 2019) on analysis of single cell RNA Seq data. They use calculateQCMetric function to calculate the quality metrics, but I am getting an error message that calculateQCMetric is a deprecated (isSpike function is also deprecated). I want to calculate the quality metrics. Can anyone provide code for getting QCMetric step? I attached the previous defunct code below:</p>

<pre><code>umi &lt;- calculateQCMetrics(
   umi,
   feature_controls = list(
       ERCC = isSpike(umi, "ERCC"), 
        MT = isSpike(umi, "MT")
   )
</code></pre>

<p>And I use StupidWolf's code from this question <a href="https://bioinformatics.stackexchange.com/questions/13295/isspike-function-in-singlecellexperiment-package-is-deprecated">isSpike function in SingleCellExperiment package is deprecated?</a> to instead isSpike function. I also attached below:</p>

<pre><code>Spikein_names = grep("^ERCC-",rownames(molecules),value=TRUE)
SpikeIn = molecules[Spikein_names,]

g = genes(EnsDb.Hsapiens.v86)
MTgene_names = g[seqnames(g)=="MT"]$gene_id
MTgenes = molecules[rownames(molecules) %in% MTgene_names,]
Have a vector of genes to keep:

keep = setdiff(rownames(molecules),c(SpikeIn,MTgenes))
Then make the single cell object:

sce &lt;- SingleCellExperiment(
assays=list(counts=as.matrix(molecules[keep,])),colData=annotation)
Use altExp to slot in the stuff:

altExp(sce, "spike-in") &lt;- SummarizedExperiment(SpikeIn)
altExp(sce, "MTgenes") &lt;- SummarizedExperiment(MTgenes)
</code></pre>

<p>I try the below code, which did not work.</p>

<pre><code>&gt; perCellQCMetrics(sce,
 subsets = list(Spikein_names,MTgene_names),
 flatten = TRUE,
 exprs_values = "counts"，
 use_altexps = TRUE)
</code></pre>

<p>Thanks in advance. </p>

CC BY-SA 4.0
2020-07-06T11:30:55.140Z
I'm also following the Sanger tutorial. I've tried the code suggested by mattcwh but get the following error: ```
Error in assay(altExp(x, use_altexps[i]), exprs_values) : 'assay(<SummarizedExperiment>, i="character", ...)' invalid subscript 'i'
'counts' not in names(assays(<SummarizedExperiment>))
``` It might have something to do with ```logcounts```, at least based on this post (?) : https://github.com/LTLA/scater/issues/3
Nereus
<r><scrnaseq><bioconductor>
calculateQCMetrics defunct, how to calculate the quality metrics by perCellQCMetrics
# calculateQCMetrics defunct, how to calculate the quality metrics by perCellQCMetrics

(Asked by: username_0 on 2020-05-24)

I am trying to follow a tutorial from Sanger institute (from May 2019) on analysis of single cell RNA Seq data. They use calculateQCMetric function to calculate the quality metrics, but I am getting an error message that calculateQCMetric is a deprecated (isSpike function is also deprecated). I want to calculate the quality metrics. Can anyone provide code for getting QCMetric step? I attached the previous defunct code below:
umi <- calculateQCMetrics(
   umi,
   feature_controls = list(
       ERCC = isSpike(umi, "ERCC"), 
        MT = isSpike(umi, "MT")
   )

And I use StupidWolf's code from this question isSpike function in SingleCellExperiment package is deprecated? to instead isSpike function. I also attached below:
Spikein_names = grep("^ERCC-",rownames(molecules),value=TRUE)
SpikeIn = molecules[Spikein_names,]

g = genes(EnsDb.Hsapiens.v86)
MTgene_names = g[seqnames(g)=="MT"]$gene_id
MTgenes = molecules[rownames(molecules) %in% MTgene_names,]
Have a vector of genes to keep:

keep = setdiff(rownames(molecules),c(SpikeIn,MTgenes))
Then make the single cell object:

sce <- SingleCellExperiment(
assays=list(counts=as.matrix(molecules[keep,])),colData=annotation)
Use altExp to slot in the stuff:

altExp(sce, "spike-in") <- SummarizedExperiment(SpikeIn)
altExp(sce, "MTgenes") <- SummarizedExperiment(MTgenes)

I try the below code, which did not work.
> perCellQCMetrics(sce,
 subsets = list(Spikein_names,MTgene_names),
 flatten = TRUE,
 exprs_values = "counts"，
 use_altexps = TRUE)

Thanks in advance.

**Tags:** r, scrnaseq, bioconductor
> **Comments:**
> **username_1**: I'm also following the Sanger tutorial. I've tried the code suggested by mattcwh but get the following error: ``` Error in assay(altExp(x, use_altexps[i]), exprs_values) : 'assay(<SummarizedExperiment>, i="character", ...)' invalid subscript 'i' 'counts' not in names(assays(<SummarizedExperiment>)) ``` It might have something to do with ```logcounts```, at least based on this post (?) : https://github.com/LTLA/scater/issues/3  

---

## 2 answers

### Answer by username_2 on 2020-07-24. Score: 1

Ok I have figured it out and I am sharing this in case anyone can get help. I used
sce <-addPerCellQC(sce)

which calculated the QC for all the altexps also and adds them to the colData.


---

### Answer by username_3 on 2020-06-03. Score: 0

It would be helpful if you can provide the error message.
Guessing from your codes, it's possible that the alternative experiments weren't set correctly. My suggestion:
altExp(sce, "spike-in") <- SummarizedExperiment(assays=list(counts=as.matrix(SpikeIn)))
altExp(sce, "MTgenes") <- SummarizedExperiment(assays=list(counts=as.matrix(MTgenes)))

If you're using altExp, the subsets argument in perCellQCMetrics is unnecessary in this case.
perCellQCMetrics(sce,
exprs_values="counts",
use_altexps=TRUE)


---

