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

plotCoregulationProfileSpatial for Seurat5 object with layers #163

Open
csmoreno opened this issue Nov 6, 2024 · 4 comments
Open

plotCoregulationProfileSpatial for Seurat5 object with layers #163

csmoreno opened this issue Nov 6, 2024 · 4 comments

Comments

@csmoreno
Copy link

csmoreno commented Nov 6, 2024

When I run this code
ps <- plotCoregulationProfileSpatial(pathways[topPathways], CM01.object, title=titles)

or this code
ps <- plotCoregulationProfileSpatial(pathways[topPathways], CM01.object, title=titles, assay = "Spatial.016um")

on a Seurat5 Object that has scaled data in it under
CM01.object@assays$Spatial.016um$scale.data

I get this error:
Error in addGesecaScores(list(pathway = pathway), object, assay = assay, :
no slot of name "scale.data" for this object of class "Assay5"

I think it might have to do with the use of layers in Seurat5. Any idea how to fix this?

Thanks

@vdsukhov
Copy link
Member

vdsukhov commented Nov 7, 2024

Hey @csmoreno,

Could you please share the Seurat object you're working with (you can send it to me via email in case you don't want to make it publicly available: [email protected]) and some minimal code snippet example which causes an error so I can try to reproduce the error on my end? It would also be great if you could include the output of sessionInfo() from your R session.

@csmoreno
Copy link
Author

csmoreno commented Nov 7, 2024

Hi Vladimir,
The object is too big to upload, but I can email you a link to download it.

Here is the code:

library(tidyverse)
library(purrr)
library("fgsea")
library(RColorBrewer)
library(Seurat)
library(SeuratObject)
library(SeuratData)
library(ggplot2)
library(patchwork)
library(dplyr)
library(Rfast)
library(Rfast2)
library(sctransform)
library(SeuratWrappers)
library(Banksy)
library(spacexr)
library(msigdbr)

CM01.object = readRDS('./rds_objects/CM01.object.16um.rds')
Assays(CM01.object)
DefaultAssay(CM01.object) <- "Spatial.016um"

fGSEA analysis

Hallmark_pathwaysDF <- msigdbr("human", category="H")
Hallmark_pathways <- split(Hallmark_pathwaysDF$gene_symbol, Hallmark_pathwaysDF$gs_name)

run spatial fgsea

set.seed(1)
E <- CM01.object@reductions$[email protected]
geseca_HALLMARK_Res <- geseca(Hallmark_pathways, E, minSize = 15, maxSize = 500, center = FALSE)
head(geseca_HALLMARK_Res, 10)

###plot top four Hallmark pathways
topPathways <- geseca_HALLMARK_Res[, pathway] |> head(4)
titles <- sub("HALLMARK_", "", topPathways)

ps <- plotCoregulationProfileSpatial(Hallmark_pathways[topPathways], CM01.object, title=titles)

cowplot::plot_grid(plotlist=ps, ncol=2)

sessionInfo()

And here is the sessionInfo:

R version 4.4.1 (2024-06-14)
Platform: x86_64-apple-darwin20
Running under: macOS Sonoma 14.6.1

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.4-x86_64/Resources/lib/libRlapack.dylib; LAPACK version 3.12.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/New_York
tzcode source: internal

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] msigdbr_7.5.1 spacexr_2.2.1 Banksy_1.1.0
[4] SeuratWrappers_0.3.5 sctransform_0.4.1 Rfast2_0.1.5.2
[7] Rfast_2.1.0 RcppParallel_5.1.9 RcppZiggurat_0.1.6
[10] Rcpp_1.0.13-1 patchwork_1.3.0 stxBrain.SeuratData_0.1.2
[13] SeuratData_0.2.2.9001 Seurat_5.1.0 SeuratObject_5.0.2
[16] sp_2.1-4 RColorBrewer_1.1-3 fgsea_1.30.0
[19] lubridate_1.9.3 forcats_1.0.0 stringr_1.5.1
[22] dplyr_1.1.4 purrr_1.0.2 readr_2.1.5
[25] tidyr_1.3.1 tibble_3.2.1 ggplot2_3.5.1
[28] tidyverse_2.0.0

loaded via a namespace (and not attached):
[1] RcppHungarian_0.3 RcppAnnoy_0.0.22 splines_4.4.1
[4] later_1.3.2 R.oo_1.27.0 polyclip_1.10-7
[7] fastDummies_1.7.4 lifecycle_1.0.4 aricode_1.0.3
[10] doParallel_1.0.17 globals_0.16.3 Rnanoflann_0.0.3
[13] lattice_0.22-6 MASS_7.3-61 magrittr_2.0.3
[16] plotly_4.10.4 remotes_2.5.0 httpuv_1.6.15
[19] glmGamPoi_1.16.0 spam_2.11-0 sessioninfo_1.2.2
[22] pkgbuild_1.4.5 spatstat.sparse_3.1-0 reticulate_1.39.0
[25] cowplot_1.1.3 pbapply_1.7-2 zlibbioc_1.50.0
[28] abind_1.4-8 pkgload_1.4.0 GenomicRanges_1.56.2
[31] Rtsne_0.17 R.utils_2.12.3 BiocGenerics_0.50.0
[34] rappdirs_0.3.3 GenomeInfoDbData_1.2.12 IRanges_2.38.1
[37] S4Vectors_0.42.1 ggrepel_0.9.6 irlba_2.3.5.1
[40] listenv_0.9.1 spatstat.utils_3.1-1 goftest_1.2-3
[43] RSpectra_0.16-2 spatstat.random_3.3-2 fitdistrplus_1.2-1
[46] parallelly_1.38.0 DelayedMatrixStats_1.26.0 DelayedArray_0.30.1
[49] leiden_0.4.3.1 codetools_0.2-20 tidyselect_1.2.1
[52] UCSC.utils_1.0.0 farver_2.1.2 matrixStats_1.4.1
[55] stats4_4.4.1 spatstat.explore_3.3-3 jsonlite_1.8.9
[58] ellipsis_0.3.2 progressr_0.15.0 iterators_1.0.14
[61] ggridges_0.5.6 survival_3.7-0 foreach_1.5.2
[64] dbscan_1.2-0 tools_4.4.1 ica_1.0-3
[67] glue_1.8.0 SparseArray_1.4.8 gridExtra_2.3
[70] MatrixGenerics_1.16.0 usethis_3.0.0 GenomeInfoDb_1.40.1
[73] withr_3.0.2 BiocManager_1.30.25 fastmap_1.2.0
[76] fansi_1.0.6 digest_0.6.37 rsvd_1.0.5
[79] timechange_0.3.0 R6_2.5.1 mime_0.12
[82] colorspace_2.1-1 scattermore_1.2 sccore_1.0.5
[85] tensor_1.5 spatstat.data_3.1-2 R.methodsS3_1.8.2
[88] utf8_1.2.4 generics_0.1.3 data.table_1.16.2
[91] S4Arrays_1.4.1 httr_1.4.7 htmlwidgets_1.6.4
[94] uwot_0.2.2 pkgconfig_2.0.3 gtable_0.3.6
[97] lmtest_0.9-40 XVector_0.44.0 SingleCellExperiment_1.26.0
[100] htmltools_0.5.8.1 profvis_0.4.0 dotCall64_1.2
[103] Biobase_2.64.0 scales_1.3.0 png_0.1-8
[106] SpatialExperiment_1.14.0 spatstat.univar_3.1-1 rstudioapi_0.17.1
[109] rjson_0.2.23 tzdb_0.4.0 reshape2_1.4.4
[112] nlme_3.1-166 cachem_1.1.0 zoo_1.8-12
[115] KernSmooth_2.23-24 parallel_4.4.1 miniUI_0.1.1.1
[118] pillar_1.9.0 grid_4.4.1 vctrs_0.6.5
[121] RANN_2.6.2 urlchecker_1.0.1 promises_1.3.0
[124] xtable_1.8-4 cluster_2.1.6 magick_2.8.5
[127] cli_3.6.3 compiler_4.4.1 rlang_1.1.4
[130] crayon_1.5.3 future.apply_1.11.3 mclust_6.1.1
[133] plyr_1.8.9 fs_1.6.5 stringi_1.8.4
[136] viridisLite_0.4.2 deldir_2.0-4 BiocParallel_1.38.0
[139] babelgene_22.9 munsell_0.5.1 lazyeval_0.2.2
[142] devtools_2.4.5 spatstat.geom_3.3-3 Matrix_1.7-1
[145] RcppHNSW_0.6.0 hms_1.1.3 sparseMatrixStats_1.16.0
[148] future_1.34.0 shiny_1.9.1 SummarizedExperiment_1.34.0
[151] ROCR_1.0-11 leidenAlg_1.1.4 igraph_2.1.1
[154] memoise_2.0.1 fastmatch_1.1-4

@vdsukhov
Copy link
Member

vdsukhov commented Nov 8, 2024

@csmoreno yep it would be great if you could provide a link to the object. You can send the link to one of these email addresses: [email protected] or [email protected] (in case if it's google drive)

@csmoreno
Copy link
Author

csmoreno commented Nov 9, 2024

I found a workaround by converting from an Assay5 to an Assay class.

convert a v5 assay to a v3 assay

CM01.object[["Spatial"]] <- as(object = CM01.object[["Spatial.016um"]], Class = "Assay")

ps <- plotCoregulationProfileSpatial(Hallmark_pathways[topPathways], CM01.object, assay = "Spatial",
title=titles)

cowplot::plot_grid(plotlist=ps, ncol=2)

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

2 participants