caravagnalab / rRACES

R wrapper for the RACES package
GNU General Public License v3.0
2 stars 1 forks source link

Wrong cell file format error #97

Closed jovoni closed 8 months ago

jovoni commented 8 months ago

I simulate a tissue with sampling but when I try to retrieve the sample forest via the get_samples_forest() function this error is raised

Aiming cell id 132094 read Cell{id: 132093, parent_id: 46684, birth_time: 72.4925, species_id: 18} Error: Wrong cell file format.

Here is a reproducible example

library(rRACES)
library(dplyr)
library(ggplot2)
library(patchwork)

set.seed(777)

# Prep simulation ####
sim <- new(Simulation, seed = 777, save_snapshot = T)
sim$update_tissue(1e3, 1e3)
# Set the "border" growth model
sim$duplicate_internal_cells <- FALSE

# Set the death activation level to avoid drift
sim$death_activation_level <- 50

# First and Second mutant ####
sim$add_mutant(name = "Clone 1",
               # epigenetic_rates = c("+-" = 0.01, "-+" = 0.01),
               growth_rates = 1,
               death_rates = 0.01)

sim$place_cell("Clone 1", 500, 500)
# Let the simulation evolve until "A+" consists of 1000 cells
sim$run_up_to_size("Clone 1", 1) # to observe muller from beginning
sim$run_up_to_size("Clone 1", 1000)

sim$add_mutant("Clone 2",growth_rates = 1.5, death_rates = 0.01)
sim$mutate_progeny(sim$choose_cell_in("Clone 1"), "Clone 2")

# Let the simulation evolve until "B+" consists of 3000 cells
sim$run_up_to_size("Clone 2",3000)
sim$update_rates("Clone 1",rates = c(growth = .001, death=0.01))

# Third mutant ####
sim$add_mutant("Clone 3",growth_rates = 2, death_rates = 0.01)
sim$mutate_progeny(sim$choose_cell_in("Clone 2"), "Clone 3")
sim$update_rates("Clone 2",rates = c(growth = .001, death=0.01))

sim$run_up_to_size("Clone 3", 3000)
sim$update_rates("Clone 1",rates = c(growth = 0, death=0.01))
sim$update_rates("Clone 2",rates = c(growth = 0, death=0.01))
sim$run_up_to_size("Clone 3", 5e4)
#sim$run_up_to_size("C",1e5)
plot_tissue(sim, num_of_bins = 300)

# First sampling ####
n_w <- n_h <- 50
ncells <- .99*n_w*n_h
bbox <- sim$search_sample(c("Clone 3" = ncells), n_w, n_h)
sim$sample_cells("A", bbox$lower_corner, bbox$upper_corner)

sim$get_samples_forest()

# sessionInfo()
# R version 4.3.2 (2023-10-31)
# Platform: aarch64-apple-darwin20 (64-bit)
# Running under: macOS Sonoma 14.3.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.3-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0
# 
# locale:
#   [1] en_US.UTF-8
# 
# time zone: Europe/Rome
# tzcode source: internal
# 
# attached base packages:
#   [1] stats     graphics  grDevices utils     datasets  methods   base     
# 
# other attached packages:
#   [1] patchwork_1.2.0 ggplot2_3.5.0   dplyr_1.1.4     rRACES_0.6.0   
# 
# loaded via a namespace (and not attached):
#   [1] tidyselect_1.2.1    farver_2.1.1        fastmap_1.1.1       promises_1.2.1      digest_0.6.35       dotCall64_1.1-1    
# [7] timechange_0.3.0    mime_0.12           lifecycle_1.0.4     ellipsis_0.3.2      processx_3.8.4      SeuratObject_5.0.1 
# [13] magrittr_2.0.3      compiler_4.3.2      rlang_1.1.3         tools_4.3.2         utf8_1.2.4          knitr_1.45         
# [19] labeling_0.4.3      htmlwidgets_1.6.4   curl_5.2.1          sp_2.1-3            pkgbuild_1.4.4      RColorBrewer_1.1-3 
# [25] pkgload_1.3.4       miniUI_0.1.1.1      purrr_1.0.2         withr_3.0.0         desc_1.4.3          BiocGenerics_0.48.1
# [31] grid_4.3.2          stats4_4.3.2        fansi_1.0.6         urlchecker_1.0.1    RcppHNSW_0.6.0      profvis_0.3.8      
# [37] xtable_1.8-4        colorspace_2.1-0    future_1.33.2       progressr_0.14.0    globals_0.16.3      scales_1.3.0       
# [43] cli_3.6.2           crayon_1.5.2        remotes_2.5.0       ragg_1.3.0          generics_0.1.3      rstudioapi_0.16.0  
# [49] future.apply_1.11.1 sessioninfo_1.2.2   ape_5.7-1           cachem_1.0.8        stringr_1.5.1       zlibbioc_1.48.2    
# [55] parallel_4.3.2      XVector_0.42.0      vctrs_0.6.5         devtools_2.4.5      Matrix_1.6-5        callr_3.7.6        
# [61] IRanges_2.36.0      S4Vectors_0.40.2    listenv_0.9.1       systemfonts_1.0.6   hexbin_1.28.3       glue_1.7.0         
# [67] parallelly_1.37.1   spam_2.10-0         ps_1.7.6            codetools_0.2-19    stringi_1.8.3       RcppAnnoy_0.0.22   
# [73] lubridate_1.9.3     gtable_0.3.4        later_1.3.2         munsell_0.5.1       tibble_3.2.1        pillar_1.9.0       
# [79] htmltools_0.5.8     R6_2.5.1            textshaping_0.3.7   shiny_1.8.1         lattice_0.22-6      Biobase_2.62.0     
# [85] memoise_2.0.1       httpuv_1.6.15       ggmuller_0.5.6      Rcpp_1.0.12         nlme_3.1-164        xfun_0.43          
# [91] usethis_2.2.3       fs_1.6.3            pkgconfig_2.0.3
#