Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with IntegrateLayers #9366

Open
JoyOtten opened this issue Oct 5, 2024 · 6 comments
Open

Error with IntegrateLayers #9366

JoyOtten opened this issue Oct 5, 2024 · 6 comments

Comments

@JoyOtten
Copy link

JoyOtten commented Oct 5, 2024

Hi,

It seems that I can't use the IntegrateLayers function. I have two layers in my object however I'm getting the following error codes:

test <- IntegrateLayers(
object = seurat_soup_doublet_remove_mito, method = CCAIntegration,
orig.reduction = "pca", new.reduction = "integrated.cca", assay = "SCT",
verbose = FALSE
)
| 0 % ~calculating Error in UseMethod(generic = "Assays", object = object) :
no applicable method for 'Assays' applied to an object of class "NULL"

seurat_soup_doublet_remove_mito <- IntegrateLayers(
object = seurat_soup_doublet_remove_mito, method = HarmonyIntegration,
orig.reduction = "pca", new.reduction = "harmony",
verbose = FALSE)

Error in validObject(object = x) :
invalid class “Seurat” object: 1: all cells in assays must be in the same order as the Seurat object
invalid class “Seurat” object: 2: all cells in assays must be in the same order as the Seurat object
invalid class “Seurat” object: 3: all cells in reductions must be in the same order as the Seurat object
invalid class “Seurat” object: 4: all cells in reductions must be in the same order as the Seurat object
invalid class “Seurat” object: 5: all cells in graphs must be in the same order as the Seurat object (offending: SCT_nn)
invalid class “Seurat” object: 6: all cells in graphs must be in the same order as the Seurat object (offending: SCT_snn)
In addition: Warning messages:
1: In harmony::HarmonyMatrix(data_mat = Embeddings(object = orig), :
HarmonyMatrix is deprecated and will be removed in the future from the API in the future
2: Quick-TRANSfer stage steps exceeded maximum (= 4536250)

In all honesty, I have no idea what goes wrong over here. I will attach an image on how my seurat object looks like.
Before integration, I filtered the data, SCTransform, RunPCA, RunUMAP, FindNeighbors, FindClusters.

Screenshot 2024-10-05 at 17 46 08
@wangbenwang123
Copy link

If you need to perform IntegrateLayers, you must create a new assay split by sample or treatment before running SCTransform. The code is as follows:

sc[['Integrated']] <- split(sc[['RNA']], f = sc$sample) # Split based on sample type in the metadata

DefaultAssay(sc) <- 'Integrated'

sc <- SCTransform(sc, assay = 'Integrated') # SCTransform defaults to using 'RNA' if the assay is not specified, so you need to set 'Integrated' here.
DefaultAssay(sc) # After SCTransform, the default assay is set to 'SCT', so I recommend explicitly specifying the assay in all function parameters if you're unsure about the default behavior.

DefaultAssay(sc) <- 'SCT'

sc <- RunPCA(sc, npcs = 30, verbose = F, assay = 'SCT')
options(future.globals.maxSize = 3e+09) # Adjust based on your actual needs
sc <- IntegrateLayers(

  object = sc,

  method = RPCAIntegration, # Or you can use CCA or Harmony as the method

  normalization.method = "SCT",

  verbose = F,

  assay = 'SCT'
)

I hope this helps resolve your issue.

@JoyOtten
Copy link
Author

JoyOtten commented Oct 8, 2024

Hi,

I already tried that the problem is that my layers are already split.
! The following layers are already split: 'counts.1', 'counts.2' Please join before splitting
Run rlang::last_trace() to see where the error occurred.

From the start I had two seurat objects since they are two independent replicates from one another.

@wangbenwang123
Copy link

你好

我已经尝试过了,问题是我的图层已经被分割了。 !以下图层已被拆分: 'counts.1', 'counts.2' 请在拆分 Run 之前加入以查看错误发生的位置。rlang::last_trace()

从一开始,我就有两个 seurat 对象,因为它们是两个彼此独立的复制品。

Please follow my code order and parameters strictly as instructed.

@JoyOtten
Copy link
Author

JoyOtten commented Oct 8, 2024

I can't read chinese characters and the code above I can't follow since my Seurat object is from the start already split.

@maggietsui
Copy link

Having the same no applicable method for 'Assays' applied to an object of class "NULL" error using RPCA, although I am using standard log normalization and not SCT.

@mhkowalski
Copy link
Contributor

mhkowalski commented Oct 11, 2024

Hi,

It seems like there is something going wrong with the structure of your object, as I haven't encountered this issue before. Could you please provide the code on how you're constructing seurat_soup_doublet_remove_mito from your two individual seurat objects?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants