Workflow
Perform simulation and extract population data:
library(tumopp)
library(dplyr)
result = tumopp::tumopp("-N20000 -D3 -Chex -Lconst -k10")
population = result$population[[1L]]
graph = result$graph[[1L]]
Sample cells and put neutral mutations on the lineages:
extant = population |> tumopp::filter_extant()
ncell = 200L
regions = tumopp::sample_uniform_regions(extant, nsam = 4L, ncell = ncell)
subgraph = tumopp::subtree(graph, unlist(regions$id))
vaf = tumopp::make_vaf(subgraph, regions$id, mu = 8.0) |> print()
#> # A tibble: 29,816 × 4
#> `1` `2` `3` `4`
#> <dbl> <dbl> <dbl> <dbl>
#> 1 0 0 0 0.005
#> 2 0 0 0 0.005
#> 3 0 0 0 0.005
#> 4 0 0 0 0.005
#> 5 0 0 0 0.005
#> 6 0 0 0 0.005
#> 7 0 0 0 0.005
#> 8 0 0 0 0.005
#> 9 0 0 0 0.025
#> 10 0 0 0 0.025
#> # ℹ 29,806 more rows
Estimate \(F_{ST}\) from VAF.
tumopp::dist_vaf(vaf, ncell) |> tumopp::fst()
#> [1] 0.06250332
# True FST from cell genealogy
tumopp::dist_genealogy(subgraph, regions$id) |> tumopp::fst()
#> [1] 0.06050219
Summarize and visualize VAF:
vaf_tidy = vaf |>
tumopp::filter_detectable(0.01) |>
tumopp::sort_vaf() |>
tumopp::longer_vaf() |>
print()
library(ggplot2)
ggplot(vaf_tidy) +
aes(sample, site) +
geom_tile(aes(fill = frequency)) +
scale_fill_distiller(palette = "Spectral", limit = c(0, 1), guide = FALSE) +
coord_cartesian(expand = FALSE)