Error with "method for 'DefaultAssay<-' applied to an object of class "GRNData"
yojetsharma opened this issue · comments
I am trying to run the scMultiome vignette, and when running pando, I am stuck with this error:
> library(Pando)
Attaching package: ‘Pando’
The following objects are masked from ‘package:Seurat’:
GetAssay, VariableFeatures
The following objects are masked from ‘package:SeuratObject’:
LayerData, VariableFeatures
>
> seurat <- initiate_grn(seurat,
+ regions=phastConsElements20Mammals.UCSC.hg38,
+ rna_assay = "RNA", peak_assay = "ATAC")
> seurat <- find_motifs(seurat,
+ pfm = Pando::motifs,
+ motif_tfs = Pando::motif2tf,
+ genome = BSgenome.Hsapiens.UCSC.hg38)
Adding TF info
Building motif matrix
Finding motif positions
Creating Motif object
Warning in CreateMotifObject(data = motif.matrix, positions = motif.positions, :
Non-unique motif names supplied, making unique
> write.csv(top_motifs_ct, file = "/home/rstudio/chromvar_motifs.csv")
> write.csv(DA_motifs_ct, file = "/home/rstudio/fulllist_chromvar_motifs.csv")
> library(doParallel)
Loading required package: foreach
Loading required package: iterators
Loading required package: parallel
> registerDoParallel(20)
> seurat <- infer_grn(seurat,
+ parallel = T,
+ tf_cor = 0.05,
+ method="glm",
+ family="gaussian",
+ scale=F,
+ verbose=T)
Loaded glmnet 4.1-8
Selecting candidate regulatory regions near genes
Preparing model input
Fitting models for 1837 target genes
Warning message:
In mclapply(argsList, FUN, mc.preschedule = preschedule, mc.set.seed = set.seed, :
scheduled cores 4, 7, 18 did not deliver results, all values of the jobs will be affected
Connected to your session in progress, last started 2024-Mar-07 07:27:46 UTC (3 hours ago)
> grn <- seurat@grn@networks$glm_network@coefs %>%
+ filter(padj < 0.01)
>
> grn
# A tibble: 11,312 × 10
tf target region term estimate std_err statistic pval padj corr
<chr> <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 DMRTA1 ANOS1 chrX-8632968-8633102 chrX_8632968… 0.0488 0.0119 4.09 4.25e- 5 4.27e- 4 0.0696
2 GLI3 ANOS1 chrX-8640010-8640030 GLI3:chrX_86… 0.0310 0.00402 7.70 1.41e-14 4.13e-13 0.224
3 HMGB1 ANOS1 chrX-8640010-8640030 chrX_8640010… -0.0223 0.00374 -5.97 2.44e- 9 4.70e- 8 -0.0944
4 ZNF148 ANOS1 chrX-8684308-8684634 chrX_8684308… 0.0255 0.00327 7.81 5.91e-15 1.77e-13 0.0584
5 ZNF438 ANOS1 chrX-8684308-8684634 chrX_8684308… 0.0481 0.00653 7.37 1.75e-13 4.78e-12 0.0680
6 SALL4 ANOS1 chrX-8684308-8684634 chrX_8684308… 0.0257 0.00737 3.49 4.87e- 4 3.75e- 3 0.0511
7 TEAD1 ANOS1 chrX-8688778-8688940 chrX_8688778… 0.0290 0.00376 7.69 1.45e-14 4.27e-13 0.0552
8 CREB5 ANOS1 chrX-8726174-8726375 chrX_8726174… 0.0270 0.00626 4.32 1.57e- 5 1.72e- 4 0.173
9 KLF7 ANOS1 chrX-8732205-8732276 chrX_8732205… -0.0289 0.00462 -6.25 4.06e-10 8.41e- 9 -0.0568
10 TRERF1 ANOS1 chrX-8732205-8732276 chrX_8732205… 0.0257 0.00551 4.65 3.29e- 6 4.10e- 5 0.0835
# ℹ 11,302 more rows
# ℹ Use `print(n = ...)` to see more rows
> write.csv(grn, file="/home/rstudio/grn_multiome.csv")
> positive_regulons <- split(grn$target[grn$estimate>0], grn$tf[grn$estimate>0])
> positive_regulons <- positive_regulons[lengths(positive_regulons) > 10]
> negative_regulons <- split(grn$target[grn$estimate<0], grn$tf[grn$estimate<0])
> negative_regulons <- negative_regulons[lengths(negative_regulons) > 10]
>
> DefaultAssay(seurat) <- "RNA"
Error in UseMethod(generic = "DefaultAssay<-", object = object) :
no applicable method for 'DefaultAssay<-' applied to an object of class "GRNData"
> mod_act_pos <- AddModuleScore(seurat,
+ features = positive_regulons,
+ name = "regulon_")@meta.data
Error in UseMethod(generic = "DefaultAssay", object = object) :
no applicable method for 'DefaultAssay' applied to an object of class "GRNData"
Hm... I've been restructuring some things to make it compatible with Seurat v5 and it's possible that some bugs slipped in. I'll look into it
Ah, I think that probably the vignette should be changed to accommodate the changes to Pando. The new Pando object is now not compatible with Seurat functions anymore, but the seurat object can be accessed with pando_obj@data
. So in the context of the vignette, this would be
mod_act_pos <- AddModuleScore(seurat@data, ...)
Ah, I think that probably the vignette should be changed to accommodate the changes to Pando. The new Pando object is now not compatible with Seurat functions anymore, but the seurat object can be accessed with
pando_obj@data
. So in the context of the vignette, this would bemod_act_pos <- AddModuleScore(seurat@data, ...)
Okay. But just before this, when I set the defaultassay to RNA it gives the same error (as shown above). So should I skip that line?
Ah yes, this should then also be
DefaultAssay(seurat@data) <- "RNA"
Alternatively, you can just introduce something like
pando_obj <- seurat
seurat <- pando_obj@data
so that seurat
is an actual seurat object again, and then run the vignette normally.
Ah yes, this should then also be
DefaultAssay(seurat@data) <- "RNA"
Alternatively, you can just introduce something like
pando_obj <- seurat seurat <- pando_obj@data
so that
seurat
is an actual seurat object again, and then run the vignette normally.
Thanks, it worked!
I had a follow-up doubt: how can we get a scale for the nodes which are colored and sized? Like the one done in your manuscript