Sample family trees and generated gene genealogies can be visualized briefly
with the plot()
method. The output can be further customized with ggplot2
functions.
The input can be also customized.
First, use augment()
to add coordinates and other attributes for plotting.
Then you can modify them as needed.
Finally, build the plot with ggplot2::ggplot()
.
Usage
# S3 method for class 'sample_family'
augment(x, layout = NULL, ...)
# S3 method for class 'genealogy'
augment(x, layout = NULL, ...)
layout_demography(x)
# S3 method for class 'genealogy'
plot(x, ..., lwd = 0.5, cex = 5, pch = 16)
# S3 method for class 'sample_family'
plot(x, ..., lwd = 0.5, cex = 5, pch = 16)
Arguments
- x
A
sample_family
ofgenealogy
data.frame.- layout
A data.frame or function to compute coordinates.
layout_demography()
is applied by default.- ...
Additional arguments passed to the layout function.
- lwd
passed to ggplot2::geom_segment.
- cex, pch
passed to ggplot2::geom_point and ggplot2::geom_text.
Value
augment()
returns a data.frame suitable for plotting.
layout_demography()
computes coordinates for plotting genealogy.
plot()
returns a ggplot2 object.
Examples
set.seed(666)
result = tekka("-y20 -l2 --sa 2,2 --sj 2,2")
samples = result$sample_family[[1L]]
augment(samples)
#> # A tibble: 154 × 10
#> from to birth_year capture_year sampled x y xend yend label
#> <int> <int> <int> <int> <lgl> <int> <int> <int> <int> <int>
#> 1 17 1 15 19 TRUE 1 15 3 11 1
#> 2 24 1 15 19 TRUE 1 15 1 10 1
#> 3 30 2 14 19 TRUE 1 14 1 8 2
#> 4 36 2 14 19 TRUE 1 14 3 4 2
#> 5 13 3 19 19 TRUE 1 19 2 15 3
#> 6 38 3 19 19 TRUE 1 19 3 15 3
#> 7 45 4 19 19 TRUE 2 19 1 13 4
#> 8 38 4 19 19 TRUE 2 19 3 15 4
#> 9 49 5 16 20 TRUE 1 16 3 8 5
#> 10 40 5 16 20 TRUE 1 16 2 9 5
#> # ℹ 144 more rows
plot(samples) +
ggplot2::theme_void() +
ggplot2::theme(legend.position = "top")
genealogy = make_gene_genealogy(samples)
plot(genealogy) +
ggplot2::theme_void() +
ggplot2::theme(legend.position = "top")