Skip to contents

This method loads a simulation from the disk.

Arguments

name

The name of the simulation to be recovered.

Examples

# create a simulation having name "recover_simulation_test" and
# save its snapshots in a local directory
sim <- SpatialSimulation("recover_simulation_test",
           save_snapshots=TRUE)

# add the species of "A"
sim$add_mutant("A",
               epigenetic_rates=c("+-" = 0.01, "-+"=0.01),
               growth_rates = c("+"=0.1, "-"=0.01),
               death_rates = c("+"=0.05, "-"=0.005))

# place a cell in the tissue
sim$place_cell("A+", 500, 500)

# simulate up to time 50
sim$run_up_to_time(50)
#> 
 [████████████████████████████████████████] 100% [00m:00s] Saving snapshot                                 


# show the simulation
sim
#> ──  rRACES   D   S   M  recover_simulation_test ─────────────────────────────────  [1000x1000]51.5 ──
#> 
#> ── Species: 2, with epigenetics 
#>    
#>    =======  ====  =====  ====  ======  ========
#>    species   λ       δ    ε    counts     %    
#>    =======  ====  =====  ====  ======  ========
#>         A-  0.01  0.005  0.01    3     27.27273
#>         A+  0.10  0.050  0.01    8     72.72727
#>    =======  ====  =====  ====  ======  ========
#> 
#> ── Firings: 21 total 
#> 
#> 	Species [A-]:  0 (deaths),  0 (duplications) and  0 (switches)
#> 	Species [A+]:  4 (deaths), 14 (duplications) and  3 (switches)
#>  The simulation has no samples yet!

# remove the object sim from the environment
rm(list=c("sim"))

# the object pointed by sim does not exist any more
exists("sim")
#> [1] FALSE

# recover the simulation from the directory "recover_simulation_test"
sim <- recover_simulation("recover_simulation_test")

sim
#> ──  rRACES   D   S   M  recover_simulation_test ─────────────────────────────────  [1000x1000]51.5 ──
#> 
#> ── Species: 2, with epigenetics 
#>    
#>    =======  ====  =====  ====  ======  ========
#>    species   λ       δ    ε    counts     %    
#>    =======  ====  =====  ====  ======  ========
#>         A-  0.01  0.005  0.01    3     27.27273
#>         A+  0.10  0.050  0.01    8     72.72727
#>    =======  ====  =====  ====  ======  ========
#> 
#> ── Firings: 21 total 
#> 
#> 	Species [A-]:  0 (deaths),  0 (duplications) and  0 (switches)
#> 	Species [A+]:  4 (deaths), 14 (duplications) and  3 (switches)
#>  The simulation has no samples yet!

# delete dump directory
unlink("recover_simulation_test", recursive = TRUE)