Reputation: 65
I am running Seurat V3 in RStudio and attempting to run PCA on a newly subsetted object. As part of that process, I am using the commands:
tnk.cells <- FindVariableFeatures(tnk.cells, assay = "RNA", selection.method = "vst", nfeatures = 2000)
tnk.cells <- RunPCA(tnk.cells, verbose = TRUE, npcs = 30, features = FindVariableFeatures(tnk.cells))
The first process seems to work, but I am unsure if it actually did, and if so, whether I need to specify that "features" in the second command should refer to those features. Either way, every time I attempt to run the second command, it produces this error, along with three warning messages:
Error in match(x, table, nomatch = 0L) :
'match' requires vector arguments
In addition: Warning messages:
1: In FindVariableFeatures.Assay(object = assay.data, selection.method = selection.method, :
selection.method set to 'vst' but count slot is empty; will use data slot instead
2: In eval(predvars, data, env) : NaNs produced
3: In hvf.info$variance.expected[not.const] <- 10^fit$fitted :
number of items to replace is not a multiple of replacement length
Does anyone have any idea why these errors/warnings are being produced? I have tried coercing the output of FindVariableFeatures
as a vector and a dataframe, to no avail. I also want to ask: do I need to rerun FindVariableFeatures after subsetting a new dataset from a larger one?
Upvotes: 1
Views: 4077
Reputation: 46978
The variable features are already stored in the Seurat object. You can access them using VariableFeatures()
, for example:
library(Seurat)
pbmc_small =SCTransform(pbmc_small)
pbmc_small = FindVariableFeatures(pbmc_small,nfeatures=20)
head(VariableFeatures(pbmc_small))
[1] "GNLY" "PPBP" "PF4" "S100A8" "VDAC3" "CD1C"
Then you can run it is like this, although by default, it will use the variable features stored in the object:
pbmc_small <- RunPCA(pbmc_small,features = VariableFeatures(pbmc_small))
Upvotes: 1