caravagnalab / rRACES

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

Error in building a MutationEngine even by using the "demo" setup #101

Closed saracoco closed 7 months ago

saracoco commented 7 months ago

Errore: basic_string::substr: __pos (which is 3) > this->size() (which is 1)

set.seed(1234567)
rm(list = ls())
library(rRACES)
require(dplyr)
library(knitr)
library(ggplot2)
library(patchwork)

sim <- new(Simulation, "Border Growth")

# Set the "border" growth model
sim$duplicate_internal_cells <- TRUE

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

# Add mutants
sim$update_tissue(100, 100)
sim$add_mutant(name = "A", growth_rates = 0.1, death_rates = 0)
sim$place_cell("A", 50, 50)
sim$run_up_to_time(500)

n_w <- n_h <- 40
ncells <- 0.9*n_w*n_h
bbox <- sim$search_sample(c("A" = ncells), n_w, n_h)
sim$sample_cells("SA", bbox$lower_corner, bbox$upper_corner)
plot_tissue(sim, num_of_bins = 100)

# Add "B" mutant
sim$add_mutant(name="B", growth_rates = 0.5, death_rates=.01)
sim$mutate_progeny(sim$choose_cell_in("A"), "B")
sim$update_rates("A", c(growth = 0, death=.01))
sim$run_up_to_size("B", 100*100*.9)
plot_tissue(sim, num_of_bins = 100)

# Add "C" mutant
sim$add_mutant(name="C", growth_rates = 0.5, death_rates=.01)
sim$mutate_progeny(sim$choose_cell_in("B"), "C")
sim$update_rates("B", c(growth = 0, death=.01))
sim$run_up_to_size("C", 9000)

plot_tissue(sim, num_of_bins = 100)

# Sample cells ####
n_w <- n_h <- 40
ncells <- 0.9*n_w*n_h

bbox <- sim$search_sample(c("C" = ncells), n_w, n_h)
sim$sample_cells("SC", bbox$lower_corner, bbox$upper_corner)
plot_tissue(sim, num_of_bins = 100)

forest <- sim$get_samples_forest()

# build a mutation engine 
m_engine <- build_mutation_engine(setup_code = "demo")

sessionInfo()
# 
# R version 4.3.1 (2023-06-16 ucrt)
# Platform: x86_64-w64-mingw32/x64 (64-bit)
# Running under: Windows 11 x64 (build 22631)
# 
# Matrix products: default
# 
# 
# locale:
#   [1] LC_COLLATE=Italian_Italy.utf8  LC_CTYPE=Italian_Italy.utf8    LC_MONETARY=Italian_Italy.utf8
# [4] LC_NUMERIC=C                   LC_TIME=Italian_Italy.utf8    
# 
# 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.1   dplyr_1.1.3     rRACES_0.6.2   
# 
# loaded via a namespace (and not attached):
#   [1] gtable_0.3.5        xfun_0.40           QuickJSR_1.0.8      htmlwidgets_1.6.4   devtools_2.4.5     
# [6] remotes_2.4.2.1     processx_3.8.2      lattice_0.21-8      inline_0.3.19       callr_3.7.3        
# [11] ps_1.7.5            vctrs_0.6.3         tools_4.3.1         generics_0.1.3      stats4_4.3.1       
# [16] curl_5.2.0          parallel_4.3.1      tibble_3.2.1        fansi_1.0.4         R.oo_1.26.0        
# [21] pkgconfig_2.0.3     RColorBrewer_1.1-3  desc_1.4.3          RcppParallel_5.1.7  lifecycle_1.0.4    
# [26] farver_2.1.1        compiler_4.3.1      stringr_1.5.1       munsell_0.5.1       codetools_0.2-19   
# [31] httpuv_1.6.14       htmltools_0.5.7     usethis_2.2.2       yaml_2.3.8          hexbin_1.28.3      
# [36] pillar_1.9.0        later_1.3.2         urlchecker_1.0.1    R.utils_2.12.3      ellipsis_0.3.2     
# [41] cachem_1.0.8        StanHeaders_2.26.28 sessioninfo_1.2.2   mime_0.12           rstan_2.32.3       
# [46] tidyselect_1.2.1    digest_0.6.34       stringi_1.7.12      purrr_1.0.2         labeling_0.4.3     
# [51] fastmap_1.1.1       grid_4.3.1          colorspace_2.1-0    cli_3.6.1           magrittr_2.0.3     
# [56] loo_2.6.0           pkgbuild_1.4.3      utf8_1.2.3          withr_3.0.0         scales_1.3.0       
# [61] promises_1.2.1      rmarkdown_2.25      matrixStats_1.0.0   gridExtra_2.3       R.methodsS3_1.8.2  
# [66] memoise_2.0.1       shiny_1.8.0         evaluate_0.23       knitr_1.46          miniUI_0.1.1.1     
# [71] profvis_0.3.8       rlang_1.1.1         Rcpp_1.0.11         xtable_1.8-6        glue_1.6.2         
# [76] pkgload_1.3.4       rstudioapi_0.15.0   jsonlite_1.8.7      R6_2.5.1            fs_1.6.3 
albertocasagrande commented 7 months ago

Can you try to delete the directory demo and retry?

saracoco commented 7 months ago

Sure! I obtain this error message:

Downloading reference genome...
apertura URL 'https://ftp.ensembl.org/pub/grch37/current/fasta/homo_sapiens/dna/Homo_sapiens.GRCh37.dna.chromosome.22.fa.gz'
Content type 'application/x-gzip' length 10529959 bytes (10.0 MB)
downloaded 10.0 MB

Reference genome downloaded
Decompressing reference file...done
Downloading SBS file...
apertura URL 'https://cancer.sanger.ac.uk/signatures/documents/2123/COSMIC_v3.4_SBS_GRCh37.txt'
Content type 'text/plain' length 96398 bytes (94 KB)
downloaded 94 KB

SBS file downloaded
Downloading driver mutation file...
apertura URL 'https://raw.githubusercontent.com/caravagnalab/rRACES/main/inst/extdata/driver_mutations_hg19.csv'
Content type 'text/plain; charset=utf-8' length 42330 bytes (41 KB)
downloaded 41 KB

Driver mutation file downloaded
Downloading passenger CNAs file...
apertura URL 'https://raw.githubusercontent.com/caravagnalab/rRACES/main/inst/extdata/passenger_CNAs_hg19.csv'
Content type 'text/plain; charset=utf-8' length 2521055 bytes (2.4 MB)
downloaded 2.4 MB

Passenger CNAs file downloaded
Downloading germline mutations...
apertura URL 'https://www.dropbox.com/scl/fi/g9oloxkip18tr1rm6wjve/germline_data_demo.tar.gz?rlkey=15jshuld3bqgyfcs7fa0bzqeo&dl=1'
Content type 'application/binary' length 2358272 bytes (2.2 MB)
downloaded 2.2 MB

Germline mutations downloaded
Building context index...
Errore: basic_string::substr: __pos (which is 3) > this->size() (which is 1)
In aggiunta: Messaggi di avvertimento:
1: In grep(pattern, bfr, value = TRUE) :
  unable to translate ' Il volume nell'unit<85> C <8a> Windows' to a wide string
2: In grep(pattern, bfr, value = TRUE) : input string 1 is invalid
3: In grep(pattern, bfr, value = TRUE) :
  unable to translate ' Il volume nell'unit<85> C <8a> Windows' to a wide string
4: In grep(pattern, bfr, value = TRUE) : input string 1 is invalid
5: In grep(pattern, bfr, value = TRUE) :
  unable to translate ' Il volume nell'unit<85> C <8a> Windows' to a wide string
6: In grep(pattern, bfr, value = TRUE) : input string 1 is invalid
albertocasagrande commented 7 months ago

You need to remove the previous installation of rRACES and install the new version.

remove.packages("rRACES")
devtools::install_github("caravagnalab/rRACES")