This function simulates PCA of allele frequencies under an admixture graph model

graph_to_pcs(
  graph,
  nsnps = 10000,
  drift_default = 0.02,
  admix_default = 0.5,
  leaves_only = TRUE
)

Arguments

graph

An admixture graph as igraph object, or as edge list data frame with a column weight, as returned by qpgraph()$edges

nsnps

Number of SNPs to simulate

drift_default

Default branch lengths. Ignored if graph is a data frame with weights

admix_default

Default admixture weights. Ignored if graph is a data frame with weights

leaves_only

Return PCs for leaf nodes only

Value

A data frame with PCs for each population

See also

Examples

if (FALSE) {
pcs = graph_to_pcs(example_igraph)
pcs %>% ggplot(aes(PC1, PC2, label = pop)) + geom_text() + geom_point()
}