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

FindIntegrationAnchors() returns "no applicable method for 'Assays' applied to an object of class "NULL"" #8789

Open
lucas-vicuna opened this issue Apr 18, 2024 · 2 comments

Comments

@lucas-vicuna
Copy link

lucas-vicuna commented Apr 18, 2024

Hello,
I have a list of seurat objects that I read into a list. Then I merge them, split them by experimental condition, perform standard steps but when running the function FindIntegrationAnchors(), I get:

Error in UseMethod(generic = "Assays", object = object) :
no applicable method for 'Assays' applied to an object of class "NULL"

However, I see that the class of the merged object is "RNA", so I don't get why I get class NULL afterwards.

Please help, I have been stacked in this issue for several days.

Below you can see the script

Thank you very much !

library(Seurat)
library(dplyr)
library(ggplot2)
library(SeuratObject)
library(future.apply)

workDir <- "/project/lbarreiro/USERS/lucas/czi/data/scrna/seurat/human_iav_tcruzi"
setwd(workDir)

# Read first 4 files:

file_paths <- list.files(workDir, pattern = "^seuratObj4_[1-4]\.rds$", full.names = TRUE)

# Initialize an empty list to store Seurat objects

seurat_list <- future_lapply(file_paths, readRDS)

# Merge the Seurat objects concurrently

merged_obj <- Reduce(merge, seurat_list) # Takes ~20 min

# class(merged_obj) # Seurat

slotNames(merged_obj)

#[1] "assays"       "meta.data"    "active.assay" "active.ident" "graphs"      
#[6] "neighbors"    "reductions"   "images"       "project.name" "misc"        
#[11] "version"      "commands"     "tools" 

# > Assays(merged_obj)
# [1] "RNA"


# split the dataset into a list of four seurat objects (C1, C2, C3, C4)

ifnb.list <- SplitObject(merged_obj, split.by = "expCond1") # very fast

# class(ifnb.list) # list

# normalize and identify variable features for each dataset independently

ifnb.list <- lapply(X = ifnb.list, FUN = function(x) {
x <- NormalizeData(x)
x <- FindVariableFeatures(x, selection.method = "vst", nfeatures = 2000)
})

# class(ifnb.list) # list

# select features that are repeatedly variable across datasets for integration run PCA on each
# dataset using these features

features <- SelectIntegrationFeatures(object.list = ifnb.list)
# class(features) # "character"

ifnb.list <- lapply(X = ifnb.list, FUN = function(x) {
x <- ScaleData(x, features = features, verbose = FALSE)
x <- RunPCA(x, features = features, verbose = FALSE)
})
# class(ifnb.list) # list

# Active assays:

assayNames(ifnb.list)

immune.anchors <- FindIntegrationAnchors(object.list = ifnb.list, anchor.features = features, reduction = "rpca", assay = "RNA", normalization.method = "LogNormalize")

Error in UseMethod(generic = "Assays", object = object) :
no applicable method for 'Assays' applied to an object of class "NULL"

@kevinrue
Copy link

kevinrue commented Apr 26, 2024

Having a similar issue with the following:

> obj <- IntegrateLayers(
+   object = obj,
+   method = RPCAIntegration,
+   normalization.method = "SCT",
+   verbose = F
+ )
  |++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=00s  
  |                                                  | 0 % ~calculating  Error in UseMethod(generic = "Assays", object = object) : 
  no applicable method for 'Assays' applied to an object of class "NULL"

Based on tutorial https://satijalab.org/seurat/articles/seurat5_integration#perform-streamlined-one-line-integrative-analysis

I don't want to hijack this issue. I'm not expecting a reply to my own issue here. I mainly post here to be notified of replies to the issue reported above, but I thought that maybe the maintainers might be interested in knowing that the issue might affect more than one use case.

Version of Seurat packages

 P Seurat               * 5.0.3      2024-03-18 [?] CRAN (R 4.3.1)
 P SeuratData           * 0.2.2.9001 2024-04-19 [?] Github (satijalab/seurat-data@4dc08e0)
   SeuratObject         * 5.0.1      2023-11-17 [1] CRAN (R 4.3.1)
 P SeuratWrappers       * 0.3.5      2024-04-19 [?] Github (satijalab/seurat-wrappers@8d46d6c)

@zskylarli
Copy link
Contributor

Hi - to the original issue, do you run into the same issue when running the vignette with the ifnb dataset, and/or would you be able to create a reproducible example? Could you check the class() of the individual assays before running FindIntegrationAnchors by running class(ifnb.list[1] etc.?

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

3 participants