# PCA plot did not work in single cell RNA-seq

I run plotPCA for single cell RNA-seq data, while I get error message (I use R 4.0). I attached the code and error message here. Did anyone know the reason and how to deal with it. Thanks!

library(pcaMethods)
library(SC3)
library(scater)
library(SingleCellExperiment)
library(pheatmap)
library(mclust)
set.seed(1234567)
plotPCA(deng, colour_by = "cell_type2")

Error in value[[3L]](cond) : invalid subscript 'type' in 'reducedDimNames(<SingleCellExperiment>)'
'PCA' not in 'reducedDimNames(<SingleCellExperiment>)'


I also get error message when I run the code as below:

colData(deng)$tSNE_kmeans <- as.character(kmeans(deng@reducedDims$TSNE, centers = 8)\$clust)

# Error in array(x, c(length(x), 1L), if (!is.null(names(x))) list(names(x), : 'data' must be of a vector type, was 'NULL'

• I solve the first error for PCA, while have no idea about the second one. Does anyone have any suggestion?
– Yach
May 25 '20 at 9:22

The error is pretty obvious. There is no PCA data in the respective slot of the SingleCellExperiment that plotPCA could use, at least it is not called PCA which by default is expected. Use runPCA first, please read the manuals of scater and scran first, they have step-by-step code.