theMILOlab / SPATA2

A Toolbox for Spatial Gene Expression Analysis
77 stars 15 forks source link

Function asSeurat() gives error in confuns package #101

Open emcramer opened 5 months ago

emcramer commented 5 months ago

When I try to convert a SPATA object to Seurat, I get the following error using SPATA2::asSeurat():

> seurat_t313 <- asSeurat(spata2_t313)

Error in confuns::give_feedback(msg = msg, fdb.fn = fdb.fn, with.time = with.time,  : 
  Value 'y' of input for argument 'axis' is invalid. 
Instead of 'y' did you mean 'h' or 'v'?.
In addition: Warning message:
Layer 'TRUE' is empty

I updated to the latest version of confuns yesterday (commit 3f03060dbc86545313bfbb7634741bc2bdc6f7bd, and that solved another issue, however, I still get the above error message. My code finishes running in the R console but no Seurat object (i.e. seurat_t313) is generated. Any thoughts as to why this is happening? Do I need to provide another parameter?

Thanks!

Here is my session info (in case that is helpful):

R version 4.3.2 (2023-10-31)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Ventura 13.6.2

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.3-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.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/Los_Angeles
tzcode source: internal

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

other attached packages:
 [1] celldex_1.12.0              SingleR_2.4.1               org.Hs.eg.db_3.18.0         AnnotationDbi_1.64.1       
 [5] STdeconvolve_1.6.0          cowplot_1.1.3               infercnv_1.18.1             lubridate_1.9.3            
 [9] forcats_1.0.0               stringr_1.5.1               dplyr_1.1.4                 purrr_1.0.2                
[13] readr_2.1.5                 tidyr_1.3.1                 tibble_3.2.1                tidyverse_2.0.0            
[17] SPATAData_0.0.0.9000        ggplot2_3.4.4               Seurat_5.0.1                SeuratObject_5.0.1         
[21] sp_2.1-2                    SpatialExperiment_1.11.2    SingleCellExperiment_1.24.0 topicmodels_0.2-16         
[25] SPATA2_2.0.4                SummarizedExperiment_1.32.0 Biobase_2.62.0              GenomicRanges_1.54.1       
[29] GenomeInfoDb_1.38.5         IRanges_2.36.0              S4Vectors_0.40.2            BiocGenerics_0.48.1        
[33] MatrixGenerics_1.14.0       matrixStats_1.2.0           Matrix_1.6-5               

loaded via a namespace (and not attached):
  [1] coin_1.4-3                    R.methodsS3_1.8.2             vroom_1.6.5                   tiff_0.1-12                  
  [5] goftest_1.2-3                 Biostrings_2.70.2             HDF5Array_1.30.0              TH.data_1.1-2                
  [9] vctrs_0.6.5                   spatstat.random_3.2-2         digest_0.6.34                 png_0.1-8                    
 [13] ggrepel_0.9.5                 deldir_2.0-2                  parallelly_1.36.0             renv_1.0.3                   
 [17] magick_2.8.2                  MASS_7.3-60.0.1               reshape2_1.4.4                httpuv_1.6.14                
 [21] foreach_1.5.2                 withr_3.0.0                   ggfun_0.1.4                   ellipsis_0.3.2               
 [25] survival_3.5-7                memoise_2.0.1                 ggbeeswarm_0.7.2              systemfonts_1.0.5            
 [29] ragg_1.2.7                    zoo_1.8-12                    gtools_3.9.5                  V8_4.4.1                     
 [33] pbapply_1.7-2                 argparse_2.2.2                R.oo_1.26.0                   KEGGREST_1.42.0              
 [37] promises_1.2.1                confuns_1.0.3                 httr_1.4.7                    globals_0.16.2               
 [41] fitdistrplus_1.1-11           rhdf5filters_1.14.1           rhdf5_2.46.1                  rstudioapi_0.15.0            
 [45] units_0.8-5                   miniUI_0.1.1.1                generics_0.1.3                concaveman_1.1.0             
 [49] curl_5.2.0                    zlibbioc_1.48.0               ScaledMatrix_1.10.0           polyclip_1.10-6              
 [53] ExperimentHub_2.10.0          GenomeInfoDbData_1.2.11       SparseArray_1.2.3             interactiveDisplayBase_1.40.0
 [57] fftwtools_0.9-11              xtable_1.8-4                  doParallel_1.0.17             S4Arrays_1.2.0               
 [61] BiocFileCache_2.10.1          hms_1.1.3                     irlba_2.3.5.1                 filelock_1.0.3               
 [65] colorspace_2.1-0              NLP_0.2-1                     ROCR_1.0-11                   reticulate_1.34.0            
 [69] spatstat.data_3.0-4           magrittr_2.0.3                lmtest_0.9-40                 viridis_0.6.5                
 [73] later_1.3.2                   modeltools_0.2-23             lattice_0.22-5                spatstat.geom_3.2-8          
 [77] future.apply_1.11.1           scattermore_1.2               scuttle_1.12.0                RcppAnnoy_0.0.22             
 [81] pillar_1.9.0                  nlme_3.1-164                  iterators_1.0.14              EBImage_4.44.0               
 [85] caTools_1.18.2                compiler_4.3.2                beachmat_2.18.0               RSpectra_0.16-1              
 [89] stringi_1.8.3                 tensor_1.5                    plyr_1.8.9                    scater_1.30.1                
 [93] crayon_1.5.2                  abind_1.4-5                   gridGraphics_0.5-1            locfit_1.5-9.8               
 [97] rjags_4-15                    bit_4.0.5                     sandwich_3.1-0                libcoin_1.0-10               
[101] fastcluster_1.2.6             codetools_0.2-19              multcomp_1.4-25               textshaping_0.3.7            
[105] BiocSingular_1.18.0           slam_0.1-50                   plotly_4.10.4                 tm_0.7-11                    
[109] mime_0.12                     splines_4.3.2                 Rcpp_1.0.12                   fastDummies_1.7.3            
[113] dbplyr_2.4.0                  sparseMatrixStats_1.14.0      blob_1.2.4                    utf8_1.2.4                   
[117] BiocVersion_3.18.1            fs_1.6.3                      listenv_0.9.0                 DelayedMatrixStats_1.24.0    
[121] ggplotify_0.1.2               statmod_1.5.0                 tzdb_0.4.0                    svglite_2.1.3                
[125] phyclust_0.1-34               pkgconfig_2.0.3               tools_4.3.2                   cachem_1.0.8                 
[129] RSQLite_2.3.5                 viridisLite_0.4.2             DBI_1.2.0                     fastmap_1.1.1                
[133] scales_1.3.0                  grid_4.3.2                    ica_1.0-3                     AnnotationHub_3.10.0         
[137] patchwork_1.2.0               coda_0.19-4                   BiocManager_1.30.22           dotCall64_1.1-1              
[141] RANN_2.6.1                    farver_2.1.1                  mgcv_1.9-1                    liger_2.0.1                  
[145] yaml_2.3.8                    cli_3.6.2                     leiden_0.4.3.1                lifecycle_1.0.4              
[149] dbscan_1.1-12                 uwot_0.1.16                   mvtnorm_1.2-4                 lambda.r_1.2.4               
[153] DropletUtils_1.22.0           BiocParallel_1.36.0           timechange_0.3.0              gtable_0.3.4                 
[157] rjson_0.2.21                  ggridges_0.5.6                progressr_0.14.0              parallel_4.3.2               
[161] ape_5.7-1                     limma_3.58.1                  jsonlite_1.8.8                edgeR_4.0.12                 
[165] RcppHNSW_0.5.0                bitops_1.0-7                  bit64_4.0.5                   assertthat_0.2.1             
[169] Rtsne_0.17                    yulab.utils_0.1.4             BiocNeighbors_1.20.2          spatstat.utils_3.0-4         
[173] RcppParallel_5.1.7            futile.options_1.0.1          dqrng_0.3.2                   R.utils_2.12.3               
[177] lazyeval_0.2.2                shiny_1.8.0                   htmltools_0.5.7               sctransform_0.4.1            
[181] rappdirs_0.3.3                formatR_1.14                  glue_1.7.0                    spam_2.10-0                  
[185] XVector_0.42.0                RCurl_1.98-1.14               jpeg_0.1-10                   futile.logger_1.4.3          
[189] gridExtra_2.3                 igraph_1.6.0                  R6_2.5.1                      gplots_3.1.3                 
[193] labeling_0.4.3                anndata_0.7.5.6               cluster_2.1.6                 pkgload_1.3.4                
[197] Rhdf5lib_1.24.1               stringdist_0.9.12             aplot_0.2.2                   vipor_0.4.7                  
[201] DelayedArray_0.28.0           tidyselect_1.2.0              xml2_1.3.6                    future_1.33.1                
[205] rsvd_1.0.5                    munsell_0.5.0                 KernSmooth_2.23-22            data.table_1.15.0            
[209] htmlwidgets_1.6.4             RColorBrewer_1.1-3            rlang_1.1.3                   spatstat.sparse_3.0-3        
[213] spatstat.explore_3.2-5        remotes_2.4.2.1               fansi_1.0.6                   parallelDist_0.2.6           
[217] beeswarm_0.4.0  
kueckelj commented 5 months ago

Can you reinstall SPATA2 and test, if it works now?

emcramer commented 4 months ago

I reinstalled the package and tried again, but I get a different error:

> seurat_t313 <- asSeurat(spata2_t313)

Error in validObject(.Object) : 
  invalid class “VisiumV1” object: 1: invalid object for slot "scale.factors" in class "VisiumV1": got class "NULL", should be or extend class "scalefactors"
invalid class “VisiumV1” object: 2: invalid object for slot "spot.radius" in class "VisiumV1": got class "NULL", should be or extend class "numeric"
simonmfr commented 4 months ago

Hi @emcramer, thanks for raising this, I found a bug in asSeurat. Please re-install SPATA2 and try again.

Otherwise, to transfer barcode metadata from SPATA2 to Seurat, an easy solution is:

meta_col <- as.data.frame(SPATA2::getFeatureDf(spata_object)[c("barcodes","column_to_transfer")])
seurat_object <- Seurat::AddMetaData(seurat_object, meta_col)

Hope that helps!