Can't do runPCA after merging a splited Seurat object before UMAP
1
0
Entering edit mode
11 months ago
wanaga3166 ▴ 10

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.6k views
ADD COMMENT
3
Entering edit mode
11 months ago

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

ADD COMMENT
0
Entering edit mode

Thank you antonioggsousa for your help :-)

ADD REPLY

Login before adding your answer.

Traffic: 2799 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6