Supercells with Basilisk fails for dtype('float64') to dtype('int64') conversion
1
0
Entering edit mode
@stefanomangiola-6873
Last seen 1 hour ago
Australia

I have a strange error, that I don't think is related to the input data, about dtype('float64') to dtype('int64') conversion. Is it possible that from the A2 python connection something strange is happening here?

Thanks a lot

Offending code


library(basilisk)
metacells_env <- BasiliskEnvironment(
  envname = "metacells_env",
  pkgname = "HPCell",
  packages = c("numpy==1.24.3"),  # Upgrade numpy to a version compatible with Python 3.10
  pip = c("metacells==0.9.4", "anndata==0.10.9")  # Use pip to install metacells
)
basiliskStart(metacells_env)

mc <- reticulate::import("metacells", delay_load = TRUE)
np <- reticulate::import("numpy", delay_load = TRUE)

my_anndata = anndata$AnnData(X = matrix(as.integer(rpois(200, lambda = 5)), nrow = 20, ncol = 10) )

mc$pl$divide_and_conquer_pipeline(my_anndata, random_seed=123456)


# ERROR

set unnamed.var[selected_gene]: * -> False
set unnamed.var[rare_gene]: 0 true (0%) out of 36412 bools
set unnamed.var[rare_gene_module]: 36412 int32 elements with all outliers (100%)
set unnamed.obs[cells_rare_gene_module]: 4860 int32 elements with all outliers (100%)
set unnamed.obs[rare_cell]: 0 true (0%) out of 4860 bools
Error in py_call_impl(callable, call_args$unnamed, call_args$named) : 
  TypeError: Cannot cast scalar from dtype('float64') to dtype('int64') according to the rule 'safe'


sessionInfo()
R version 4.4.1 (2024-06-14)
Platform: x86_64-pc-linux-gnu
Running under: Red Hat Enterprise Linux 9.4 (Plow)

Matrix products: default
BLAS:   /stornext/System/data/software/rhel/9/base/tools/R/4.4.1/lib64/R/lib/libRblas.so 
LAPACK: /home/users/allstaff/mangiola.s/.cache/R/basilisk/1.16.0/HPCell/0.3.7/metacells_env/lib/libmkl_rt.so.1;  LAPACK version 3.9.0

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

time zone: Australia/Melbourne
tzcode source: system (glibc)

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

other attached packages:
 [1] SummarizedExperiment_1.34.0 Biobase_2.64.0              GenomicRanges_1.56.1        GenomeInfoDb_1.40.1         IRanges_2.38.1             
 [6] S4Vectors_0.42.1            BiocGenerics_0.50.0         MatrixGenerics_1.16.0       matrixStats_1.4.1           basilisk_1.16.0            
[11] reticulate_1.39.0           CuratedAtlasQueryR_1.4.7    crew.cluster_0.3.2          HPCell_0.3.7                shinyBS_0.61.1             
[16] stringr_1.5.1               purrr_1.0.2                 tibble_3.2.1                glue_1.8.0                  targets_1.8.0.9003         
[21] duckdb_1.0.0-2              DBI_1.2.3                   dplyr_1.1.4                 arrow_17.0.0.1             

loaded via a namespace (and not attached):
  [1] igraph_2.1.1                      ica_1.0-3                         plotly_4.10.4                     SingleR_2.6.0                    
  [5] scater_1.32.1                     zlibbioc_1.50.0                   tidyselect_1.2.1                  bit_4.5.0                        
  [9] lattice_0.22-6                    rjson_0.2.23                      blob_1.2.4                        S4Arrays_1.4.1                   
 [13] parallel_4.4.1                    seqLogo_1.70.0                    png_0.1-8                         cli_3.6.3                        
 [17] ProtGenerics_1.36.0               goftest_1.2-3                     gargle_1.5.2                      BiocIO_1.14.0                    
 [21] bluster_1.14.0                    basilisk.utils_1.16.0             BiocNeighbors_1.22.0              tarchetypes_0.10.0               
 [25] Signac_1.14.0                     uwot_0.2.2                        curl_5.2.3                        mime_0.12                        
 [29] leiden_0.4.3.1                    V8_5.0.0                          stringi_1.8.4                     ids_1.0.1                        
 [33] backports_1.5.0                   XML_3.99-0.17                     httpuv_1.6.15                     AnnotationDbi_1.66.0             
 [37] magrittr_2.0.3                    rappdirs_0.3.3                    splines_4.4.1                     RcppRoll_0.3.1                   
 [41] nanonext_1.3.0                    RApiSerialize_0.1.4               DT_0.33                           sctransform_0.4.1                
 [45] ggbeeswarm_0.7.2                  HDF5Array_1.32.1                  withr_3.0.1                       rprojroot_2.0.4                  
 [49] xgboost_1.7.8.1                   tidySummarizedExperiment_1.14.0   lmtest_0.9-40                     BiocManager_1.30.25              
 [53] rtracklayer_1.64.0                htmlwidgets_1.6.4                 fs_1.6.4                          biomaRt_2.60.1                   
 [57] SingleCellExperiment_1.26.0       ggrepel_0.9.6                     SparseArray_1.4.8                 cellranger_1.1.0                 
 [61] tidyseurat_0.8.1                  annotate_1.82.0                   zoo_1.8-12                        JASPAR2020_0.99.10               
 [65] XVector_0.44.0                    knitr_1.48                        TFBSTools_1.42.0                  UCSC.utils_1.0.0                 
 [69] TFMPvalue_0.0.9                   secretbase_1.0.3                  fansi_1.0.6                       patchwork_1.3.0                  
 [73] caTools_1.18.3                    grid_4.4.1                        data.table_1.16.2                 rhdf5_2.48.0                     
 [77] pwalign_1.0.0                     R.oo_1.26.0                       poweRlaw_0.80.0                   RSpectra_0.16-2                  
 [81] irlba_2.3.5.1                     alabaster.schemas_1.4.0           fastDummies_1.7.4                 ellipsis_0.3.2                   
 [85] base64url_1.4                     lazyeval_0.2.2                    yaml_2.3.10                       tidySingleCellExperiment_1.15.5  
 [89] survival_3.7-0                    scattermore_1.2                   BiocVersion_3.19.1                crayon_1.5.3                     
 [93] mirai_1.3.0                       RcppAnnoy_0.0.22                  RColorBrewer_1.1-3                tidyr_1.3.1                      
 [97] progressr_0.14.0                  later_1.3.2                       tidybulk_1.17.3                   ggridges_0.5.6                   
[101] codetools_0.2-20                  Seurat_5.1.0                      KEGGREST_1.44.1                   Rtsne_0.17                       
[105] limma_3.60.4                      Rsamtools_2.20.0                  filelock_1.0.3                    pkgconfig_2.0.3                  
[109] xml2_1.3.6                        spatstat.univar_3.0-1             GenomicAlignments_1.40.0          alabaster.base_1.4.2             
[113] spatstat.sparse_3.1-0             BSgenome_1.72.0                   viridisLite_0.4.2                 xtable_1.8-4                     
[117] plyr_1.8.9                        httr_1.4.7                        tools_4.4.1                       globals_0.16.3                   
[121] SeuratObject_5.0.2                pkgbuild_1.4.4                    checkmate_2.3.2                   beeswarm_0.4.0                   
[125] broom_1.0.7                       nlme_3.1-166                      loo_2.8.0                         ExperimentHub_2.12.0             
[129] dbplyr_2.5.0                      hdf5r_1.3.11                      shinyjs_2.1.0                     lme4_1.1-35.5                    
[133] assertthat_0.2.1                  digest_0.6.37                     Matrix_1.7-0                      dir.expiry_1.12.0                
[137] farver_2.1.2                      tzdb_0.4.0                        AnnotationFilter_1.28.0           reshape2_1.4.4                   
[141] viridis_0.6.5                     DirichletMultinomial_1.46.0       cachem_1.1.0                      BiocFileCache_2.12.0             
[145] polyclip_1.10-7                   generics_0.1.3                    Biostrings_2.72.1                 googledrive_2.1.1                
[149] presto_1.0.0                      parallelly_1.38.0                 statmod_1.5.0                     here_1.0.1                       
[153] RcppHNSW_0.6.0                    ScaledMatrix_1.12.0               minqa_1.2.8                       pbapply_1.7-2                    
[157] httr2_1.0.3                       job_0.3.1                         spam_2.11-0                       dqrng_0.4.1                      
[161] utf8_1.2.4                        scDblFinder_1.18.0                StanHeaders_2.32.10               gtools_3.9.5                     
[165] preprocessCore_1.66.0             alabaster.se_1.4.1                crew_0.10.0                       gridExtra_2.3                    
[169] shiny_1.9.1                       GenomeInfoDbData_1.2.12           R.utils_2.12.3                    rhdf5filters_1.16.0              
[173] RCurl_1.98-1.16                   memoise_2.0.1                     scales_1.3.0                      R.methodsS3_1.8.2                
[177] googlesheets4_1.1.1               gypsum_1.0.1                      future_1.34.0                     RANN_2.6.2                       
[181] stringfish_0.16.0                 spatstat.data_3.1-2               rstudioapi_0.16.0                 zellkonverter_1.14.1             
[185] cluster_2.1.6                     QuickJSR_1.3.1                    spatstat.utils_3.1-0              hms_1.1.3                        
[189] fitdistrplus_1.2-1                munsell_0.5.1                     cowplot_1.1.3                     colorspace_2.1-1                 
[193] rlang_1.1.4                       DelayedMatrixStats_1.26.0         sparseMatrixStats_1.16.0          dotCall64_1.2                    
[197] shinydashboard_0.7.2              scuttle_1.14.0                    xfun_0.48                         alabaster.matrix_1.4.2           
[201] CNEr_1.40.0                       abind_1.4-8                       EnsDb.Hsapiens.v86_2.99.0         rstan_2.32.6                     
[205] celldex_1.14.0                    Rhdf5lib_1.26.0                   ggplot2_3.5.1                     readr_2.1.5                      
[209] bitops_1.0-9                      ps_1.8.0                          promises_1.3.0                    inline_0.3.19                    
[213] RSQLite_2.3.7                     getip_0.1-4                       DelayedArray_0.30.1               GO.db_3.19.1                     
[217] compiler_4.4.1                    alabaster.ranges_1.4.2            prettyunits_1.2.0                 boot_1.3-30                      
[221] beachmat_2.20.0                   ttservice_0.4.1                   listenv_0.9.1                     BSgenome.Hsapiens.UCSC.hg38_1.4.5
[225] Rcpp_1.0.13                       AnnotationHub_3.12.0              edgeR_4.2.1                       BiocSingular_1.20.0              
[229] tensor_1.5                        autometric_0.0.5                  qs_0.27.2                         MASS_7.3-61                      
[233] progress_1.2.3                    uuid_1.2-1                        BiocParallel_1.38.0               ggupset_0.4.0                    
[237] spatstat.random_3.3-2             R6_2.5.1                          Azimuth_0.5.0                     fastmap_1.2.0                    
[241] fastmatch_1.1-4                   vipor_0.4.7                       ensembldb_2.28.1                  ROCR_1.0-11                      
[245] SeuratDisk_0.0.0.9021             rsvd_1.0.5                        gtable_0.3.5                      KernSmooth_2.23-24               
[249] miniUI_0.1.1.1                    deldir_2.0-4                      htmltools_0.5.8.1                 RcppParallel_5.1.9               
[253] bit64_4.5.2                       spatstat.explore_3.3-2            lifecycle_1.0.4                   processx_3.8.4                   
[257] nloptr_2.1.1                      callr_3.7.6                       restfulr_0.0.15                   vctrs_0.6.5                      
[261] spatstat.geom_3.3-3               scran_1.32.0                      sp_2.1-4                          SeuratData_0.2.2.9001            
[265] future.apply_1.11.2               pracma_2.4.4                      pillar_1.9.0                      GenomicFeatures_1.56.0           
[269] DropletUtils_1.24.0               metapod_1.12.0                    locfit_1.5-9.10                   jsonlite_1.8.9
basilisk • 1.2k views
ADD COMMENT
2
Entering edit mode
@stefanomangiola-6873
Last seen 1 hour ago
Australia

I focused on the main data, while the problem was the seed class. This solves the problem

mc$pl$divide_and_conquer_pipeline(my_anndata, random_seed=123456L)

ADD COMMENT
0
Entering edit mode

For the general audience, reticulate / python (which basilisk depends on / wraps) requires explicit declaration of integers, so one needs indeed 123456L rather than 123456, mind the L for long integer.

ADD REPLY

Login before adding your answer.

Traffic: 550 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6