Czh3 / iSpatial

infer whole genome spatial transcriptome by integrating single cell RNAseq and spatial transcriptome
3 stars 3 forks source link

Incompatible matrix dimensions: 100x2 and 2x1 for tutorial data #6

Closed pakiessling closed 10 months ago

pakiessling commented 11 months ago

Hi,

I am trying to follow the tutorial:

library(iSpatial)
library(Seurat)
library(ggplot2)

# scRNA-seq data
data(NA_scRNA)

# merFISH data
data(NA_merFISH)
NA_merFISH_infer = infer_v2(NA_merFISH, NA_scRNA)

but I receive the following error:

1st level integration

Warning message:
“Adding image data that isn't associated with any assays”
Warning message:
“Adding image data that isn't associated with any assays”
Warning message:
“Adding image data that isn't associated with any assays”
2nd level integration

Error in eval(expr, envir, enclos): element-wise pow(): incompatible matrix dimensions: 100x2 and 2x1
Traceback:

1. infer_v2(NA_merFISH, NA_scRNA)
2. suppressWarnings(harmony::RunHarmony(object = integrated, group.by.vars = "tech", 
 .     plot_convergence = F, theta = 2, lambda = 0.5, assay.use = "integrated", 
 .     verbose = FALSE, max.iter.harmony = 20))
3. withCallingHandlers(expr, warning = function(w) if (inherits(w, 
 .     classes)) tryInvokeRestart("muffleWarning"))
4. harmony::RunHarmony(object = integrated, group.by.vars = "tech", 
 .     plot_convergence = F, theta = 2, lambda = 0.5, assay.use = "integrated", 
 .     verbose = FALSE, max.iter.harmony = 20)
5. RunHarmony.Seurat(object = integrated, group.by.vars = "tech", 
 .     plot_convergence = F, theta = 2, lambda = 0.5, assay.use = "integrated", 
 .     verbose = FALSE, max.iter.harmony = 20)
6. HarmonyMatrix(embedding, metavars_df, group.by.vars, FALSE, 0, 
 .     theta, lambda, sigma, nclust, tau, block.size, max.iter.harmony, 
 .     max.iter.cluster, epsilon.cluster, epsilon.harmony, plot_convergence, 
 .     FALSE, verbose, reference_values)
7. harmonize(harmonyObj, max.iter.harmony, verbose)
8. cluster(harmonyObj)
9. harmonyObj$cluster_cpp()

Any idea what is going wrong?

Czh3 commented 11 months ago

I believe this is caused by the new version V5 of Seurat you used. Can you provide the session infor by running sessionInfo() in R.

pakiessling commented 11 months ago

Ah yeah, it said something about loading the objects in compatibility mode.

I will trying downgrading Seutat later, thank you!

pakiessling commented 11 months ago

I downgraded Seuratobject from 5.0.0 to 4.1.3, but I still receive the same error. sessionInfo():


R version 4.3.1 (2023-06-16)
Platform: x86_64-conda-linux-gnu (64-bit)
Running under: Rocky Linux 8.8 (Green Obsidian)

Matrix products: default
BLAS/LAPACK: [/rwthfs/rz/cluster/work/rwth1209/enviroments/iSpatial/lib/libopenblasp-r0.3.24.so](https://vscode-remote+ssh-002dremote-002blogin18-002d2-002ehpc-002eitc-002erwth-002daachen-002ede.vscode-resource.vscode-cdn.net/rwthfs/rz/cluster/work/rwth1209/enviroments/iSpatial/lib/libopenblasp-r0.3.24.so);  LAPACK version 3.11.0

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       

time zone: :/etc/localtime
tzcode source: system (glibc)

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

other attached packages:
[1] ggplot2_3.4.4      SeuratObject_4.1.4 Seurat_4.4.0       iSpatial_1.0.0    

loaded via a namespace (and not attached):
  [1] deldir_1.0-9           pbapply_1.7-2          gridExtra_2.3         
  [4] rlang_1.1.1            magrittr_2.0.3         RcppAnnoy_0.0.21      
  [7] spatstat.geom_3.2-7    matrixStats_1.0.0      ggridges_0.5.4        
 [10] compiler_4.3.1         png_0.1-8              vctrs_0.6.4           
 [13] reshape2_1.4.4         stringr_1.5.0          pkgconfig_2.0.3       
 [16] crayon_1.5.2           fastmap_1.1.1          ellipsis_0.3.2        
 [19] utf8_1.2.4             promises_1.2.1         purrr_1.0.2           
 [22] jsonlite_1.8.7         goftest_1.2-3          later_1.3.1           
 [25] uuid_1.1-1             spatstat.utils_3.0-4   irlba_2.3.5.1         
 [28] parallel_4.3.1         cluster_2.1.4          R6_2.5.1              
 [31] ica_1.0-3              spatstat.data_3.0-3    stringi_1.7.12        
 [34] RColorBrewer_1.1-3     reticulate_1.34.0      parallelly_1.36.0     
 [37] lmtest_0.9-40          scattermore_1.2        Rcpp_1.0.11           
 [40] IRkernel_1.3.2         tensor_1.5             future.apply_1.11.0   
 [43] zoo_1.8-12             base64enc_0.1-3        sctransform_0.4.1     
 [46] httpuv_1.6.12          Matrix_1.6-1.1         splines_4.3.1         
 [49] igraph_1.5.1           tidyselect_1.2.0       abind_1.4-5           
 [52] spatstat.random_3.2-1  codetools_0.2-19       miniUI_0.1.1.1        
 [55] spatstat.explore_3.2-5 listenv_0.9.0          lattice_0.22-5        
 [58] tibble_3.2.1           plyr_1.8.9             withr_2.5.2           
 [61] shiny_1.7.5.1          ROCR_1.0-11            evaluate_0.22         
 [64] Rtsne_0.16             future_1.33.0          survival_3.5-7        
 [67] polyclip_1.10-6        fitdistrplus_1.1-11    pillar_1.9.0          
 [70] KernSmooth_2.23-22     plotly_4.10.3          generics_0.1.3        
 [73] sp_2.1-1               IRdisplay_1.1          munsell_0.5.0         
 [76] scales_1.2.1           globals_0.16.2         xtable_1.8-4          
 [79] glue_1.6.2             lazyeval_0.2.2         tools_4.3.1           
 [82] data.table_1.14.8      pbdZMQ_0.3-10          RANN_2.6.1            
 [85] leiden_0.4.3           dotCall64_1.1-0        cowplot_1.1.1         
 [88] grid_4.3.1             tidyr_1.3.0            colorspace_2.1-0      
 [91] nlme_3.1-163           patchwork_1.1.3        repr_1.1.6            
 [94] cli_3.6.1              spatstat.sparse_3.0-3  spam_2.9-1            
 [97] fansi_1.0.5            viridisLite_0.4.2      dplyr_1.1.3           
[100] uwot_0.1.16            gtable_0.3.4           digest_0.6.33         
[103] progressr_0.14.0       ggrepel_0.9.4          htmlwidgets_1.6.2     
[106] htmltools_0.5.6.1      lifecycle_1.0.3        httr_1.4.7            
[109] mime_0.12              harmony_1.0            MASS_7.3-60
Czh3 commented 11 months ago

Can you check the Version of NA_merFISH Object: Version(NA_merFISH) . You may reinstall or reload iSpatial.

pakiessling commented 11 months ago
Version(NA_merFISH)
> [1] ‘3.1.5.9900’
pakiessling commented 10 months ago

Resolved by updating Harmony to the latest version