sweep_sequence: Calculate how the genotype frequency distribution changes...

Description Usage Arguments Value Examples

View source: R/sweepmetrics.R

Description

Calculate how the genotype frequency distribution changes over time

Usage

1
2
sweep_sequence(pop_df, lag_type = "generations", breaks = 10,
  lag_gens = 500)

Arguments

pop_df

Dataframe with column names "Identity", "Population" and "Generation"

lag_type

Either "generations" or "proportions" (default "generations")

breaks

Number of breaks for determining lag (used only if lag_type = "proportions"; default 10)

lag_gens

Lag in terms of generations (used only if lag_type = "generations"; default 500)

Value

For each generation g in pop_df, excluding the first generation, the output vector quantifies the change in genotype frequencies compared to generation g - lag_gens (by summing the squares of the differences). The length of the output sequence is the same as the number of rows in the input dataframe. The first value is always zero.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
library(ggmuller)
library(dplyr)
phylo <- filter(driver_phylo, CellsPerSample == -1)
pop_df <- get_population_df(phylo)
sweep_seq1 <- sweep_sequence(pop_df, lag_type = "proportions", breaks = 6)
lag_gens <- round(length(unique(pop_df$Generation))/6)
sweep_seq2 <- sweep_sequence(pop_df, lag_type = "generations", lag_gens = lag_gens)
identical(sweep_seq1, sweep_seq2)
sweep_df <- data.frame(y = sweep_seq2, x = (1:length(sweep_seq2))/length(sweep_seq2))
plot(y ~ x , data = sweep_df, type = "l")

robjohnnoble/demonanalysis documentation built on June 30, 2020, 12:47 a.m.