satijalab / seurat

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

Intergration multiple class with V5 #8134

Closed NasimAfhami closed 8 months ago

NasimAfhami commented 9 months ago

Hello, I have 5 class. first read count matrix,normalize,findvariablefeature and then use merge instruction for merge seurat object of each class. second I want Integrate different class. why do with v5. for each srobj, I add tag class. LA[["class"]]<-"LAclass" . then merge 5 srobj and add cell.ids=class. normalize, find variablefeaturtes,scaledate, RunPCA, FindNeighbors, FindClusters,RunUMAP , and at the end IntegrateLayers. IT is true? How can use at the first IntegrateLayers then use scaledate, RunPCA, FindNeighbors, FindClusters,RunUMAP . It give error when I want first integrate them. and dont use splite. thank you so much.

Gesmira commented 9 months ago

Hi @NasimAfhami , You should run split() before running IntegrateLayers(), this is detailed in our vignette here: https://satijalab.org/seurat/articles/seurat5_integration

We show the preprocessing steps before integration in the vignette to highlight what your data would look like without integration. Simply, your workflow should be split, preprocess, IntegrateLayers(). Then, you can run downstream visualizations on the data.

Please include a specific error message if you continue to run into issues.

AfhamiNasim commented 9 months ago

Hi, thank you for your help. this is my code, Please say me how split. I am very very try to split but give error. it run without split. I have five class H,TNA,TNB,LB,LA.

options(Seurat.object.assay.version = "v5") srobj1=CreateSeuratObject(countmat, min.cells = 3, min.features = 200,project = "H")

merge multiple sample of one group

H=merge(srobj1,c(srobj4,srobj2,srobj3,srobj5), add.cell.ids=c("H14369350","H14369360","H14369365","H14369370","H14369377_"),project="H") TNA=merge(srobj6,c(srobj7,srobj1,srobj2,srobj3,srobj4,srobj5,srobj8,srobj9), ...

---------------

H[["MTpercent"]]=PercentageFeatureSet(H, pattern = "^MT-") H=subset(H,nFeature_RNA>200 & nFeature_RNA<6000 & MTpercent<25) H=NormalizeData(H) H=FindVariableFeatures(H,selection.method = "vst", nfeatures = 2000) TNA[["MTpercent"]]=...

---------------integrate multiple different group

H[["class"]]<-'H' LA[["class"]]<-... srobj <- merge(TNA, y = c(LA,TNB,H,LB,BasalLike), add.cell.ids = c("TNA", "LA","TNB","H_","LB","Basal_Like"),project="single-cell") DefaultAssay(srobj)<-"RNA" srobj <- NormalizeData(srobj) srobj <- FindVariableFeatures(srobj) srobj <- ScaleData(srobj) srobj=RunPCA(srobj, features=VariableFeatures(s)) srobj=RunUMAP(srobj,dims = 1:20) srobj <- IntegrateLayers(object = srobj, method = CCAIntegration, orig.reduction = "pca", new.reduction = "integrated.cca",verbose = FALSE)

Gesmira commented 9 months ago

Hi, Can you include the code where you run split() as well as the error message that you got? When you run merge(), it already splits the object into layers based on the objects you merged. If you would like to split() again by another factor, you should run:

srobj <- JoinLayers(srobj)
srobj <- split(srobj, f = srobj$class)

But this requires already having class in your metadata. Otherwise, if youwant to Integrate by the original 5 classes, the code you ran should work.

Gesmira commented 8 months ago

Closing now due to lack of response. Feel free to reopen if you continue to run into issues.