knitr::opts_chunk$set(echo = TRUE)
knitr::opts_chunk$set(fig.width=6) 
library(isoSIM)
library(ggplot2)
packageVersion("isoSIM")

Demonstration of how to use joyplots

To demonstrate the applicability and versatility of joyplots, we create a population, and select on this population on two separate locations, for two different ancestors.

select_matrix <- matrix(ncol = 5, nrow = 2)
s <- 0.1
select_matrix[1, ] <- c(0.23, 1.0, 1+0.5*s, 1+s, 0)
select_matrix[2, ] <- c(0.27, 1.0, 1+0.5*s, 1+s, 1)

track_freq <- c(0.2, 0.3, 100)

We track frequencies of all ancestors in the range [0.2, 0.3], using 100 markers.

selected_pop <- create_population_selection(pop_size = 1000,
                                            number_of_founders = 4,
                                            total_runtime = 1001,
                                            morgan = 1,
                                            select_matrix,
                                            seed = 1234,
                                            track_frequency = track_freq)

We can now plot all the ancestors over time, we choose here to plot them only for a select subset of times.

time_points <- seq(from = 0, to = 1000, by = 100)
joyplot_frequencies(selected_pop$frequencies, time_points, picked_ancestor = "ALL")

Alternatively, we can plot them separately.

p1 <- joyplot_frequencies(selected_pop$frequencies, time_points, picked_ancestor = 0)
p1 + ggplot2::geom_vline(xintercept = 0.23, lty = 2)

And for the other ancestor:

p2 <- joyplot_frequencies(selected_pop$frequencies, time_points, picked_ancestor = 1)
p2 + ggplot2::geom_vline(xintercept = 0.27, lty = 2)


thijsjanzen/isoSIM documentation built on May 29, 2019, 10:39 a.m.