This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Can't do runPCA after merging a splited Seurat object before UMAP

Hi everyone,

When I started my analysis, I merged 3 samples.

merged_seurat <- merge(x = PC9_1_raw_feature_bc_matrix, 
                           y = c(PC9_2_raw_feature_bc_matrix, PC9_3_raw_feature_bc_matrix),
                           add.cell.id = c("PC9_1", "PC9_2", "PC9_3"))

After cell filtering, I checked the cell cycle and batch effects (no batch effect, I won't do integration). I split my Seurat object to do normalization with SCTransform separately.

split_seurat <- SplitObject(seurat_phase, split.by = "Sample")

for (i in 1:length(split_seurat)) {
  split_seurat[[i]] <- SCTransform(split_seurat[[i]], vars.to.regress = c("mitoRatio"), vst.flavor = "v2")
}

Now I would like to do the umap (without integration), and then I merge the 3 split Seurat objects.

new_seurat <- merge(x = split_seurat$PC9_1, 
                    y = list(split_seurat$PC9_2, split_seurat$PC9_3), 
                    merge.data = TRUE)

When I ran runPCA,

# Run PCA
new_seurat <- RunPCA(new_seurat, verbose = FALSE)

I had this error message:

Error in PrepDR(object = object, features = features, verbose = verbose) :  Variable features haven't been set. Run FindVariableFeatures() or provide a vector of feature names.

How can I fix it?

scrna-seq seurat

1 answer

Hi,

The error message is quite clear, you need to do one of two things:

Run FindVariableFeatures()

Or

provide a vector of feature names

If you prefer to use just 2k HVG you can run:

new_seurat <- FindVariableFeatures(new_seurat)
new_seurat <- RunPCA(new_seurat, verbose = FALSE)

If you want to give all the genes instead:

new_seurat <- RunPCA(new_seurat, features = row.names(new_seurat))

I hope this helps,

Best regards,

António

Log in to answer this question.