satijalab / seurat

R toolkit for single cell genomics
http://www.satijalab.org/seurat
Other
2.27k stars 910 forks source link

Seurat object missing after running PCA #8219

Closed FionaMoon closed 3 months ago

FionaMoon commented 10 months ago

Hi all, I've just updated my Seurat from V4 to V5 and found that my Seurat object was missing after RunPCA.

Here's my object before running PCA:

> obj
Assay (v5) data with 20204 features for 685 cells
Top 10 variable features:
 HBG2, HBG1, MPO, LYZ, HBB, S100A8, S100A9, PF4V1, RETN, CXCL8 
Layers:
 counts.sgRNA, counts.Control, data.sgRNA, data.Control, scale.data 

After running this code, my obj disappear.

 > obj <- RunPCA(obj, features = VariableFeatures(object = obj))
> obj
 A dimensional reduction object with key PC_ 
 Number of dimensions: 50 
 Number of cells: 685 
 Projected dimensional reduction calculated:  FALSE 
 Jackstraw run: FALSE 
 Computed using assay: RNA 

If I tried to run FindNeighbors & FindClusters, I'd get the error like this Error: Not an S4 object.

samuel-marsh commented 10 months ago

Hi,

Jot member of dev team but hopefully can be helpful. So your input to RunPCA isn’t a Seurat object but an assay object. So it appears somewhere before this there was issue.

Can you post full code you ran?

Best, Sam

redtorrentCN commented 9 months ago

**Hi, friends

I have the same problem. this is my code:**

`install.packages('Seurat')

library(Seurat) library(SeuratData) library(patchwork) library(dplyr) library(ggplot2)

ifnb.inte <- LoadData("ifnb") ifnb <- split(ifnb.inte[["RNA"]], f = ifnb.inte$stim) ifnb

ifnb <- NormalizeData(ifnb) ifnb <- FindVariableFeatures(ifnb) ifnb <- ScaleData(ifnb) ifnb <- RunPCA(ifnb)'**

this is my object before running PCA:

image

this is object after running:

image

in addition, this is data structure of ifnb.inte:

image

it's changed when I split by "stim", something like active.ident is gone, I don't know Whether it is normal:

image

p.s. I also maintain Seurat V4 in a different library. Above. thanks. @samuel-marsh

FionaMoon commented 9 months ago

Hi, My code almost seems like yours @redtorrentCN and I finally figured out what's wrong with this.

If I use obj <- split(obj, f = obj$Method) instead of obj[["RNA"]] <- split(obj[["RNA"]], f = obj$Method), then everything goes on well!

redtorrentCN commented 9 months ago

thanks, @FionaMoon , I believe this is useful, but I have solved this issue with reinstalling!
by the way, Have you encountered any of the following problems when runed scvi integration: obj<- IntegrateLayers( object = obj, method = scVIIntegration, new.reduction = "integrated.scvi", conda_env = "./anaconda3/envs/scvi-env", verbose = FALSE )

Error in object[][features, ] : incorrect number of dimensions In addition: Warning message: In LayerData.Assay5(object, layers = "counts") : multiple layers are identified by data.Smart-seq2 data.CEL-Seq2 data.10x_Chromium_v2_A data.10x_Chromium_v2_B data.10x_Chromium_v3 data.Drop-seq data.Seq-Well data.inDrops data.10x_Chromium_v2 only the first layer is used

Above. thanks for your answers.

FionaMoon commented 9 months ago

I'm afraid I can't answer this question. I run Seurat on Windows system which doesn't have conda environment.

---- Replied Message ---- | From | @.> | | Date | 01/03/2024 18:45 | | To | @.> | | Cc | @.>@.> | | Subject | Re: [satijalab/seurat] Seurat object missing after running PCA (Issue #8219) |

thanks, @FionaMoon , I believe this is useful, but I have solved this issue with reinstalling! by the way, Have you encountered any of the following problems when runed scvi integration: obj<- IntegrateLayers( object = obj, method = scVIIntegration, new.reduction = "integrated.scvi", conda_env = "./anaconda3/envs/scvi-env", verbose = FALSE )

Error in object[][features, ] : incorrect number of dimensions In addition: Warning message: In LayerData.Assay5(object, layers = "counts") : multiple layers are identified by data.Smart-seq2 data.CEL-Seq2 data.10x_Chromium_v2_A data.10x_Chromium_v2_B data.10x_Chromium_v3 data.Drop-seq data.Seq-Well data.inDrops data.10x_Chromium_v2 only the first layer is used

Above. thanks for your answers.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

redtorrentCN commented 9 months ago

Fine, also thank you, bro.

Gesmira commented 3 months ago

Hi, Looks like the issue has been resolved in the comments. Closing now, but please feel free to reopen if the issue persists. Thanks!