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)
#> 
 [█████████████---------------------------] 31% [00m:00s] Saving snapshot                                                       

 [█████████████---------------------------] 31% [00m:00s] Cells: 0                                                              

 [█████████████---------------------------] 31% [00m:00s] Cells: 0                                                              

 [█████████████---------------------------] 31% [00m:00s] Cells: 0                                                              


# show the simulation
sim
#> ──  ProCESS   D   S   M  recover_simulation_test ─────────────────────────────────────────────────────  [1000x1000]15.8 ──
#> 
#> ── Species: 2, with epigenetics 
#>    
#>    =======  ====  =====  ====  ======  ===
#>    species   λ       δ    ε    counts   % 
#>    =======  ====  =====  ====  ======  ===
#>         A-  0.01  0.005  0.01    0     NaN
#>         A+  0.10  0.050  0.01    0     NaN
#>    =======  ====  =====  ====  ======  ===
#> 
#> ── Firings: 3 total 
#> 
#> 	Species [A-]: 0 (deaths), 0 (duplications) and 0 (switches)
#> 	Species [A+]: 2 (deaths), 1 (duplications) and 0 (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
#> ──  ProCESS   D   S   M  recover_simulation_test ─────────────────────────────────────────────────────  [1000x1000]15.8 ──
#> 
#> ── Species: 2, with epigenetics 
#>    
#>    =======  ====  =====  ====  ======  ===
#>    species   λ       δ    ε    counts   % 
#>    =======  ====  =====  ====  ======  ===
#>         A-  0.01  0.005  0.01    0     NaN
#>         A+  0.10  0.050  0.01    0     NaN
#>    =======  ====  =====  ====  ======  ===
#> 
#> ── Firings: 3 total 
#> 
#> 	Species [A-]: 0 (deaths), 0 (duplications) and 0 (switches)
#> 	Species [A+]: 2 (deaths), 1 (duplications) and 0 (switches)
#>  The simulation has no samples yet!

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