quadbio/Pando

Error in find_motifs with invalid version slot in SeuratPlus object

jsacco1 opened this issue · 5 comments

Hi, I am using Seurat version '4.3.0' and SeuratObject '5.0.1' to run Pando, but I get an error when I run find_motifs:

Error in validObject(.Object) : 
  invalid class "SeuratPlus" object: invalid object for slot "version" in class "SeuratPlus": got class "S4", should be or extend class "package_version"

But I checked the versions I'm using:

print(packageVersion("Seurat"))
print(packageVersion("SeuratObject"))
[1] ‘4.3.0’
[1] ‘5.0.1’

And my SeuratObject verion:

seurat_object@version
[1] ‘4.1.3’

Here is the workflow I'm using:

suppressPackageStartupMessages({
  library(tidyverse)
  library(BSgenome.Hsapiens.UCSC.hg38)
  library(EnsDb.Hsapiens.v86)
  library(doParallel)
  library(devtools)
  library(Signac)
  library(Seurat)
  library(bayestestR)
  library(Pando)
})

registerDoParallel(cores=8)

options(Seurat.object.assay.version = "v4")
print(packageVersion("Seurat"))
print(packageVersion("SeuratObject"))

rename <- dplyr::rename
filter <- dplyr::filter

data(motifs)
data(phastConsElements20Mammals.UCSC.hg38)
data(SCREEN.ccRE.UCSC.hg38)
data(motif2tf)

seurat_object <- readRDS(path/to/file.rds)
seurat object

An object of class Seurat 
410776 features across 17257 samples within 3 assays 
Active assay: SCT (28570 features, 3000 variable features)
 3 layers present: counts, data, scale.data
 2 other assays present: ATAC, RNA
 9 dimensional reductions calculated: pca, lsi, umap.atac, umap.rna, harmony.sct, umap.harmony.sct, harmony.atac, umap.harmony.atac, wnn.umap
tfs_use <- c(...............) # a character vector

motif2tf_use <- motif2tf %>%
    filter(tf%in%tfs_use) %>%
    rename('mot'=motif)


seurat_object <- find_motifs(
    seurat_object,
    pfm = motif2tf_use,
    genome = BSgenome.Hsapiens.UCSC.hg38
)

Adding TF info
Error in validObject(.Object) : 
  invalid class "SeuratPlus" object: invalid object for slot "version" in class "SeuratPlus": got class "S4", should be or extend class "package_version"
Calls: find_motifs ... callNextMethod -> eval -> eval -> .nextMethod -> validObject
Execution halted
sessionInfo()
R version 4.2.3 (2023-03-15)
Platform: x86_64-conda-linux-gnu (64-bit)
Running under: Ubuntu 22.04.3 LTS

Matrix products: default
BLAS/LAPACK: /home/james/anaconda3/envs/r43/lib/libopenblasp-r0.3.25.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
 [1] bayestestR_0.13.1                 SeuratObject_5.0.1               
 [3] Seurat_4.3.0                      Signac_1.12.0                    
 [5] devtools_2.4.5                    usethis_2.2.2                    
 [7] doParallel_1.0.17                 iterators_1.0.14                 
 [9] foreach_1.5.2                     EnsDb.Hsapiens.v86_2.99.0        
[11] ensembldb_2.22.0                  AnnotationFilter_1.22.0          
[13] GenomicFeatures_1.50.4            AnnotationDbi_1.60.2             
[15] Biobase_2.58.0                    BSgenome.Hsapiens.UCSC.hg38_1.4.5
[17] BSgenome_1.66.3                   rtracklayer_1.58.0               
[19] Biostrings_2.66.0                 XVector_0.38.0                   
[21] GenomicRanges_1.50.2              GenomeInfoDb_1.34.9              
[23] IRanges_2.32.0                    S4Vectors_0.36.2                 
[25] BiocGenerics_0.44.0               lubridate_1.9.3                  
[27] forcats_1.0.0                     stringr_1.5.1                    
[29] dplyr_1.1.4                       purrr_1.0.2                      
[31] readr_2.1.4                       tidyr_1.3.0                      
[33] tibble_3.2.1                      ggplot2_3.4.4                    
[35] tidyverse_2.0.0                   Pando_1.0.5                      

loaded via a namespace (and not attached):
  [1] utf8_1.2.4                  spatstat.explore_3.2-5     
  [3] reticulate_1.34.0           tidyselect_1.2.0           
  [5] RSQLite_2.3.4               htmlwidgets_1.6.4          
  [7] grid_4.2.3                  BiocParallel_1.32.6        
  [9] Rtsne_0.17                  munsell_0.5.0              
 [11] codetools_0.2-19            ica_1.0-3                  
 [13] future_1.33.1               miniUI_0.1.1.1             
 [15] withr_2.5.2                 spatstat.random_3.2-2      
 [17] colorspace_2.1-0            progressr_0.14.0           
 [19] filelock_1.0.3              ROCR_1.0-11                
 [21] tensor_1.5                  listenv_0.9.0              
 [23] MatrixGenerics_1.10.0       GenomeInfoDbData_1.2.9     
 [25] polyclip_1.10-6             bit64_4.0.5                
 [27] farver_2.1.1                parallelly_1.36.0          
 [29] vctrs_0.6.5                 generics_0.1.3             
 [31] BiocFileCache_2.6.1         timechange_0.2.0           
 [33] R6_2.5.1                    graphlayouts_1.0.2         
 [35] pals_1.8                    bitops_1.0-7               
 [37] spatstat.utils_3.0-4        cachem_1.0.8               
 [39] DelayedArray_0.24.0         promises_1.2.1             
 [41] BiocIO_1.8.0                scales_1.3.0               
 [43] ggraph_2.1.0                gtable_0.3.4               
 [45] globals_0.16.2              goftest_1.2-3              
 [47] spam_2.10-0                 tidygraph_1.3.0            
 [49] rlang_1.1.2                 RcppRoll_0.3.0             
 [51] splines_4.2.3               lazyeval_0.2.2             
 [53] dichromat_2.0-0.1           spatstat.geom_3.2-7        
 [55] yaml_2.3.8                  reshape2_1.4.4             
 [57] abind_1.4-5                 httpuv_1.6.13              
 [59] tools_4.2.3                 ellipsis_0.3.2             
 [61] RColorBrewer_1.1-3          sessioninfo_1.2.2          
 [63] ggridges_0.5.5              Rcpp_1.0.11                
 [65] plyr_1.8.9                  progress_1.2.3             
 [67] sparseMatrixStats_1.10.0    zlibbioc_1.44.0            
 [69] RCurl_1.98-1.13             prettyunits_1.2.0          
 [71] deldir_2.0-2                pbapply_1.7-2              
 [73] viridis_0.6.4               urlchecker_1.0.1           
 [75] cowplot_1.1.2               zoo_1.8-12                 
 [77] SummarizedExperiment_1.28.0 ggrepel_0.9.4              
 [79] cluster_2.1.6               fs_1.6.3                   
 [81] magrittr_2.0.3              data.table_1.14.10         
 [83] scattermore_1.2             lmtest_0.9-40              
 [85] RANN_2.6.1                  ProtGenerics_1.30.0        
 [87] fitdistrplus_1.1-11         matrixStats_1.2.0          
 [89] pkgload_1.3.3               hms_1.1.3                  
 [91] patchwork_1.1.3             mime_0.12                  
 [93] xtable_1.8-4                XML_3.99-0.16              
 [95] gridExtra_2.3               compiler_4.2.3             
 [97] biomaRt_2.54.1              maps_3.4.2                 
 [99] KernSmooth_2.23-22          crayon_1.5.2               
[101] ggpointdensity_0.1.0        htmltools_0.5.7            
[103] later_1.3.2                 tzdb_0.4.0                 
[105] DBI_1.2.0                   tweenr_2.0.2               
[107] dbplyr_2.4.0                rappdirs_0.3.3             
[109] MASS_7.3-60                 Matrix_1.6-4               
[111] cli_3.6.2                   insight_0.19.7             
[113] dotCall64_1.1-1             igraph_1.6.0               
[115] pkgconfig_2.0.3             GenomicAlignments_1.34.1   
[117] sp_2.1-2                    plotly_4.10.3              
[119] spatstat.sparse_3.0-3       xml2_1.3.6                 
[121] digest_0.6.33               sctransform_0.4.1          
[123] RcppAnnoy_0.0.21            spatstat.data_3.0-3        
[125] leiden_0.4.3.1              fastmatch_1.1-4            
[127] uwot_0.1.16                 curl_5.2.0                 
[129] restfulr_0.0.15             shiny_1.8.0                
[131] Rsamtools_2.14.0            rjson_0.2.21               
[133] lifecycle_1.0.4             nlme_3.1-164               
[135] jsonlite_1.8.8              mapproj_1.2.11             
[137] viridisLite_0.4.2           fansi_1.0.6                
[139] pillar_1.9.0                lattice_0.22-5             
[141] pkgbuild_1.4.3              KEGGREST_1.38.0            
[143] fastmap_1.1.1               httr_1.4.7                 
[145] survival_3.5-7              remotes_2.4.2.1            
[147] glue_1.6.2                  png_0.1-8                  
[149] bit_4.0.5                   profvis_0.3.8              
[151] ggforce_0.4.1               stringi_1.8.3              
[153] blob_1.2.4                  memoise_2.0.1              
[155] irlba_2.3.5.1               future.apply_1.11.1  

I had a similar issue (find_motifs() ran indefinitely) and ended up installing a previous version of SeuratObject that works better with Seurat v4. Here's what I did:

conda create -n pando -c conda-forge python=3.8 mamba
conda activate pando
mamba install -c conda-forge jupyter 
mamba install -c conda-forge r-base=4.3.1 
mamba install -c conda-forge r-curl 
mamba install -c conda-forge r-ragg 

R
install.packages("devtools")
devtools::install_version("SeuratObject", version = "4.1.4", repos = "http://cran.us.r-project.org")
devtools::install_version("Seurat", version = "4.3.0", repos = "http://cran.us.r-project.org") #choose 3 to not update SeuratObject
install.packages("BiocManager")
devtools::install_version("Signac", version = "1.9.0", repos = "http://cran.us.r-project.org") #3 again
devtools::install_github('quadbiolab/Pando') #3 again
# install any other packages you need, like genome annotations, motifs, etc
q()

mamba install -c conda-forge r-hdf5r* -y
mamba install -c conda-forge  r-irkernel -y

When building the environment I had to try installing packages multiple times in different orders, so there's a chance the above code won't work, but hopefully it's a good starting place!

Also, I tried to figure out exactly what was causing my problem and I think it's a compatibility issue with Pando's SeuratPlus object and SeuratObject v5. When you have SeuratObject v5, running GetAssay() and GetAssayData() on a SeuratPlus object also hangs. They made some changes to SeuratObject functions in v5 so this probably causes previous SeuratPlus code to not work. For example, they changed slots to layers in SeuratObject v5.

Thank you for the quick reply. I got it to work.

As you noticed @jsacco1, Pando is unfortunately not compatible with recent versions of SeuratObject. I'm not sure how much time I will have to fix this in the near future, but PRs are welcome.

Man....why man whyyy...spent the last few hours trying to figure out why Pando won't accept the updated sueratobject format, of course after I figured it out I came across this post.....anyway for those in RStudio, no need to re-install R just do the following:

# Pando not supported with Seurat v5 (v4.9.9 and above), this means object interaction as well
# Remove existing structure
library(utils)
remove.packages(c("Seurat", "Signac", "SeuratObject"))

# Reinstall Pando compatible versions, pre-existing packages can be seen in sessionInfo output
remotes::install_version(package = 'Seurat', version = package_version('4.3.0'))
devtools::install_version("SeuratObject", version = "4.1.4", repos = "http://cran.us.r-project.org")
devtools::install_version("Signac", version = "1.11.0", repos = "http://cran.us.r-project.org")

Edit: there an error that I troubleshoot-ed and missed mentioning is the following error gets thrown up if you downgrade and you get the following error:

object 'CRsparse_colSums' not found

The solution and reasoning is described here. But the tl;dr version is performing the following fix:

# Re-install TFBSTools to bypass object 'CRsparse_colSums' not found error
BiocManager::install("TFBSTools", type = "source", force = TRUE)
sessionInfo()
R version 4.3.2 (2023-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)

Matrix products: default


locale:
[1] LC_COLLATE=English_United States.utf8  LC_CTYPE=English_United States.utf8    LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C                           LC_TIME=English_United States.utf8    

time zone: America/Chicago
tzcode source: internal

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

other attached packages:
 [1] Pando_1.0.5                       DESeq2_1.42.0                     BiocParallel_1.36.0              
 [4] cicero_1.3.9                      Gviz_1.46.1                       chromVAR_1.5.0                   
 [7] motifmatchr_1.24.0                BSgenome.Hsapiens.UCSC.hg38_1.4.5 BSgenome_1.70.1                  
[10] rtracklayer_1.62.0                BiocIO_1.12.0                     Biostrings_2.70.1                
[13] XVector_0.42.0                    TFBSTools_1.40.0                  JASPAR2020_0.99.10               
[16] qs_0.25.7                         R.utils_2.12.3                    R.oo_1.25.0                      
[19] R.methodsS3_1.8.2                 devtools_2.4.5                    usethis_2.2.2                    
[22] ggVennDiagram_1.5.0               ggvenn_0.1.10                     DropletUtils_1.22.0              
[25] Nebulosa_1.12.0                   circlize_0.4.15                   ComplexHeatmap_2.18.0            
[28] viridis_0.6.4                     viridisLite_0.4.2                 EnrichmentBrowser_2.32.0         
[31] graph_1.80.0                      escape_1.12.0                     dittoSeq_1.14.0                  
[34] DOSE_3.28.2                       clusterProfiler_4.10.0            MeSHDbi_1.38.0                   
[37] AnnotationHub_3.10.0              BiocFileCache_2.10.1              dbplyr_2.4.0                     
[40] org.Hs.eg.db_3.18.0               GOSemSim_2.28.1                   glmGamPoi_1.14.0                 
[43] EnhancedVolcano_1.20.0            DoubletFinder_2.0.4               future_1.33.1                    
[46] patchwork_1.2.0                   clustree_0.5.1                    ggraph_2.1.0                     
[49] plotly_4.10.4                     EnsDb.Hsapiens.v86_2.99.0         ensembldb_2.26.0                 
[52] AnnotationFilter_1.26.0           GenomicFeatures_1.54.1            AnnotationDbi_1.64.1             
[55] scDblFinder_1.16.0                Signac_1.11.0                     harmony_1.2.0                    
[58] monocle3_1.3.4                    SingleCellExperiment_1.24.0       SummarizedExperiment_1.32.0      
[61] GenomicRanges_1.54.1              GenomeInfoDb_1.38.5               IRanges_2.36.0                   
[64] S4Vectors_0.40.2                  MatrixGenerics_1.14.0             matrixStats_1.2.0                
[67] Biobase_2.62.0                    BiocGenerics_0.48.1               SeuratObject_4.1.4               
[70] Seurat_4.3.0                      reticulate_1.34.0                 data.table_1.14.10               
[73] lubridate_1.9.3                   forcats_1.0.0                     purrr_1.0.2                      
[76] readr_2.1.5                       tidyr_1.3.0                       tibble_3.2.1                     
[79] tidyverse_2.0.0                   dplyr_1.1.4                       ggridges_0.5.5                   
[82] Matrix_1.6-5                      cowplot_1.1.2                     Rcpp_1.0.12                      
[85] SoupX_1.6.2                       hdf5r_1.3.9                       stringr_1.5.1                    
[88] leiden_0.4.3.1                    ggrepel_0.9.5                     ggplot2_3.4.4                    

loaded via a namespace (and not attached):
  [1] igraph_1.6.0                  Formula_1.2-5                 ica_1.0-3                     scater_1.30.1                
  [5] maps_3.4.2                    zlibbioc_1.48.0               tidyselect_1.2.0              bit_4.0.5                    
  [9] doParallel_1.0.17             clue_0.3-65                   lattice_0.22-5                rjson_0.2.21                 
 [13] blob_1.2.4                    urlchecker_1.0.1              S4Arrays_1.2.0                dichromat_2.0-0.1            
 [17] parallel_4.3.2                seqLogo_1.68.0                png_0.1-8                     cli_3.6.2                    
 [21] ggplotify_0.1.2               ProtGenerics_1.34.0           goftest_1.2-3                 bluster_1.12.0               
 [25] BiocNeighbors_1.20.2          uwot_0.1.16                   shadowtext_0.1.3              curl_5.2.0                   
 [29] evaluate_0.23                 mime_0.12                     tidytree_0.4.6                stringi_1.8.3                
 [33] backports_1.4.1               XML_3.99-0.16                 httpuv_1.6.13                 magrittr_2.0.3               
 [37] rappdirs_0.3.3                splines_4.3.2                 RcppRoll_0.3.0                mclust_6.0.1                 
 [41] RApiSerialize_0.1.2           jpeg_0.1-10                   DT_0.31                       sctransform_0.4.1            
 [45] ggbeeswarm_0.7.2              sessioninfo_1.2.2             DBI_1.2.1                     terra_1.7-65                 
 [49] HDF5Array_1.30.0              withr_3.0.0                   rprojroot_2.0.4               enrichplot_1.22.0            
 [53] xgboost_1.7.6.1               lmtest_0.9-40                 GSEABase_1.64.0               tidygraph_1.3.0              
 [57] BiocManager_1.30.22           htmlwidgets_1.6.4             fs_1.6.3                      biomaRt_2.58.0               
 [61] SparseArray_1.2.3             annotate_1.80.0               VariantAnnotation_1.48.1      zoo_1.8-12                   
 [65] knitr_1.45                    TFMPvalue_0.0.9               timechange_0.3.0              foreach_1.5.2                
 [69] ggpointdensity_0.1.0          fansi_1.0.6                   caTools_1.18.2                ggtree_3.10.0                
 [73] rhdf5_2.46.1                  poweRlaw_0.70.6               irlba_2.3.5.1                 gridGraphics_0.5-1           
 [77] ellipsis_0.3.2                lazyeval_0.2.2                yaml_2.3.8                    survival_3.5-7               
 [81] scattermore_1.2               BiocVersion_3.18.1            crayon_1.5.2                  RcppAnnoy_0.0.21             
 [85] mapproj_1.2.11                RColorBrewer_1.1-3            progressr_0.14.0              tweenr_2.0.2                 
 [89] later_1.3.2                   Rgraphviz_2.46.0              base64enc_0.1-3               codetools_0.2-19             
 [93] GlobalOptions_0.1.2           profvis_0.3.8                 KEGGREST_1.42.0               Rtsne_0.17                   
 [97] shape_1.4.6                   limma_3.58.1                  Rsamtools_2.18.0              filelock_1.0.3               
[101] foreign_0.8-86                pkgconfig_2.0.3               KEGGgraph_1.62.0              xml2_1.3.6                   
[105] GenomicAlignments_1.38.2      aplot_0.2.2                   biovizBase_1.50.0             spatstat.sparse_3.0-3        
[109] ape_5.7-1                     xtable_1.8-4                  interp_1.1-5                  plyr_1.8.9                   
[113] httr_1.4.7                    tools_4.3.2                   globals_0.16.2                pkgbuild_1.4.3               
[117] checkmate_2.3.1               htmlTable_2.4.2               beeswarm_0.4.0                broom_1.0.5                  
[121] nlme_3.1-164                  HDO.db_0.99.1                 lme4_1.1-35.1                 digest_0.6.34                
[125] farver_2.1.1                  tzdb_0.4.0                    reshape2_1.4.4                ks_1.14.2                    
[129] yulab.utils_0.1.3             rpart_4.1.23                  DirichletMultinomial_1.44.0   glue_1.7.0                   
[133] cachem_1.0.8                  polyclip_1.10-6               Hmisc_5.1-1                   generics_0.1.3               
[137] mvtnorm_1.2-4                 parallelly_1.36.0             pkgload_1.3.4                 statmod_1.5.0                
[141] here_1.0.1                    ScaledMatrix_1.10.0           minqa_1.2.6                   pbapply_1.7-2                
[145] spam_2.10-0                   gson_0.1.0                    dqrng_0.3.2                   utf8_1.2.4                   
[149] gtools_3.9.5                  graphlayouts_1.1.0            gridExtra_2.3                 shiny_1.8.0                  
[153] GSVA_1.50.0                   GenomeInfoDbData_1.2.11       pals_1.8                      rhdf5filters_1.14.1          
[157] RCurl_1.98-1.14               memoise_2.0.1                 rmarkdown_2.25                pheatmap_1.0.12              
[161] scales_1.3.0                  RANN_2.6.1                    stringfish_0.16.0             spatstat.data_3.0-4          
[165] rstudioapi_0.15.0             cluster_2.1.6                 msigdbr_7.5.1                 spatstat.utils_3.0-4         
[169] hms_1.1.3                     fitdistrplus_1.1-11           munsell_0.5.0                 colorspace_2.1-0             
[173] rlang_1.1.3                   DelayedMatrixStats_1.24.0     sparseMatrixStats_1.14.0      dotCall64_1.1-1              
[177] ggforce_0.4.1                 scuttle_1.12.0                xfun_0.41                     CNEr_1.38.0                  
[181] remotes_2.4.2.1               iterators_1.0.14              abind_1.4-5                   interactiveDisplayBase_1.40.0
[185] treeio_1.26.0                 Rhdf5lib_1.24.1               bitops_1.0-7                  promises_1.2.1               
[189] scatterpie_0.2.1              RSQLite_2.3.4                 qvalue_2.34.0                 fgsea_1.28.0                 
[193] DelayedArray_0.28.0           GO.db_3.18.0                  compiler_4.3.2                prettyunits_1.2.0            
[197] boot_1.3-28.1                 beachmat_2.18.0               listenv_0.9.0                 edgeR_4.0.10                 
[201] BiocSingular_1.18.0           tensor_1.5                    MASS_7.3-60.0.1               progress_1.2.3               
[205] UCell_2.6.2                   babelgene_22.9                spatstat.random_3.2-2         R6_2.5.1                     
[209] fastmap_1.1.1                 fastmatch_1.1-4               vipor_0.4.7                   ROCR_1.0-11                  
[213] nnet_7.3-19                   rsvd_1.0.5                    gtable_0.3.4                  KernSmooth_2.23-22           
[217] latticeExtra_0.6-30           miniUI_0.1.1.1                deldir_2.0-2                  htmltools_0.5.7              
[221] RcppParallel_5.1.7            bit64_4.0.5                   spatstat.explore_3.2-5        lifecycle_1.0.4              
[225] nloptr_2.0.3                  restfulr_0.0.15               vctrs_0.6.5                   VGAM_1.1-9                   
[229] spatstat.geom_3.2-7           scran_1.30.1                  ggfun_0.1.4                   sp_2.1-2                     
[233] pracma_2.4.4                  future.apply_1.11.1           pillar_1.9.0                  metapod_1.10.1               
[237] locfit_1.5-9.8                jsonlite_1.8.8                GetoptLong_1.0.5 

Re-used the Pando do the same analysis, meet this same issuses. Thanks for sharing