Skip to contents

Get subset of forest nodes corresponding to phylogenetic branches containing relevant biological events (drivers)

Usage

get_relevant_branches(forest)

Arguments

forest

A forest

Value

A dataframe reporting all the forest nodes corresponding to phylogenetic branches containing relevant biological events (drivers).

Examples

# set the seed of the random number generator
set.seed(0)

sim <- SpatialSimulation()

sim$add_mutant(name = "A",
               growth_rates = 1,
               death_rates = 0)
sim$place_cell("A", 500, 500)

sim$run_up_to_size("A",1e4)
#> 
 [████████████████████████████████████████] 100% [00m:00s] Saving snapshot                                    


sim$add_mutant(name = "B",
               growth_rates = 3.5,
               death_rates = 0)
sim$mutate_progeny(sim$choose_cell_in("A"), "B")

sim$run_up_to_size("B",1e4)
#> 
 [████████████████████████████████████████] 100% [00m:00s] Saving snapshot                                    


bbox <- sim$search_sample(c("A" = 100,"B" = 100), 50, 50)
sim$sample_cells("Sampling", bbox$lower_corner, bbox$upper_corner)

forest = sim$get_samples_forest()
get_relevant_branches(forest)
#> # A tibble: 3,628 × 7
#>    cell_id ancestor mutant epistate sample birth_time label    
#>      <dbl>    <int> <chr>  <chr>    <chr>       <dbl> <chr>    
#>  1       0       NA A      ""       NA           0    Truncal  
#>  2       1        0 A      ""       NA           2.01 Subclonal
#>  3       2        0 A      ""       NA           2.01 B        
#>  4       4        1 A      ""       NA           2.41 Subclonal
#>  5       5        2 A      ""       NA           2.44 B        
#>  6      11        5 A      ""       NA           2.93 B        
#>  7      14        4 A      ""       NA           3.04 Subclonal
#>  8      16       11 A      ""       NA           3.07 B        
#>  9      20       16 A      ""       NA           3.24 B        
#> 10      36       20 A      ""       NA           3.77 B        
#> # ℹ 3,618 more rows