carmonalab / STACAS

R package for semi-supervised single-cell data integration
GNU General Public License v3.0
75 stars 9 forks source link

working with Seurat v5 layers? #30

Open dpearton opened 11 months ago

dpearton commented 11 months ago

Hello,

I am working with Seurat v5 with my samples in different layers to test the different integration methods. Unfortunately the version of STACAS I am working with does not work with V5 layers. I get the following error when I try run FindAnchors.STACAS


stacas_anchors <- FindAnchors.STACAS(obj.list, 
+                                      anchor.features = nfeatures,
+                                      dims = 1:ndim)
Computing 2000 integration features
Error in `GetAssayData()`:
! GetAssayData doesn't work for multiple layers in v5 assay.
Run `rlang::last_trace()` to see where the error occurred.

`

rlang::last_trace()`


<error/ You can run 'object <- JoinLayers(object = object, layers = layer)'.>
Error in `GetAssayData()`:
! GetAssayData doesn't work for multiple layers in v5 assay.
---
Backtrace:
▆
1. ├─... %>% RunUMAP(dims = 1:ndim)
2. ├─Seurat::RunUMAP(., dims = 1:ndim)
3. └─STACAS::Run.STACAS(., dims = 1:ndim, anchor.features = nfeatures)
4.   └─STACAS::FindAnchors.STACAS(...)
5.     └─base::lapply(...)
6.       └─STACAS (local) FUN(X[[i]], ...)
7.         └─STACAS::FindVariableFeatures.STACAS(x, nfeat = n.this, genesBlockList = genesBlockList)
8.           ├─base::apply(...)
9.           ├─SeuratObject::GetAssayData(obj, assay = assay, slot = "data")
10.           └─SeuratObject:::GetAssayData.Seurat(obj, assay = assay, slot = "data")
11.             ├─SeuratObject::GetAssayData(object = object[[assay]], layer = layer)
12.             └─SeuratObject:::GetAssayData.StdAssay(object = object[[assay]], layer = layer)
Run rlang::last_trace(drop = FALSE) to see 1 hidden frame.

Is there any chance of adding support for layers in STACAS?

Thank you
mass-a commented 11 months ago

Hello! STACAS is made to work on a list of objects, where each object contains one sample. It should be sufficient to split out your object by sample (maybe after merging the layers, if your samples are organized in layers). For example:

pbmcsca.integrated <- NormalizeData(pbmcsca) |>
    SplitObject(split.by = "Method")|>
    Run.STACAS()

I understand that Seurat have changed their integration methods to use single objects in a layer structure, but you will need a list of objects in STACAS - at least for now.

dpearton commented 11 months ago

Hi,

Thank you for the very prompt reply.

The issue appears to be that I was trying to run STACAS based on combined samples (i.e. trying to integrate two different sequencing runs each comprised of multiple samples) rather than individual samples.

If I split by sample (orig.ident) it works.

I am getting an error when I FindAnchors.STACAS (for each sample).

Warning: Different features in new layer data than already exists for scale.data

Will this be an issue? - the integration does proceed after these warnings.

Thanks again for your time.

Yours, David


From: Massimo Andreatta @.> Sent: 08 December 2023 10:33 To: carmonalab/STACAS @.> Cc: David Pearton @.>; Author @.> Subject: Re: [carmonalab/STACAS] working with Seurat v5 layers? (Issue #30)

You don't often get email from @.*** Learn why this is importanthttps://aka.ms/LearnAboutSenderIdentification

Hello! STACAS is made to work on a list of objects, where each object contains one sample. It should be sufficient to split out your object by sample (maybe after merging the layers, if your samples are organized in layers). For example:

pbmcsca.integrated <- NormalizeData(pbmcsca) |> SplitObject(split.by = "Method")|> Run.STACAS()

I understand that Seurat have changed their integration methods to use single objects in a layer structure, but you will need a list of objects in STACAS - at least for now.

— Reply to this email directly, view it on GitHubhttps://github.com/carmonalab/STACAS/issues/30#issuecomment-1846932627, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BCYA63N2JBMKOHYSZVCK5EDYILUI7AVCNFSM6AAAAABAMNGQBWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNBWHEZTENRSG4. You are receiving this because you authored the thread.Message ID: @.***>

mass-a commented 11 months ago

Good that you got it to work. As for the warning you posted, it's probably safe to ignore it. My guess is that there is already a scale.data layer in the object, and it's being overwritten by using a different set of features (i.e. the highly variable genes calculated by STACAS).