Learn R Programming

poppr (version 2.1.1)

private_alleles: Tabulate alleles the occur in only one population.

Description

Tabulate alleles the occur in only one population.

Usage

private_alleles(gid, form = alleles ~ ., report = "table",
  level = "population", count.alleles = TRUE)

Arguments

gid
a genind or genclone object.
form
a formula giving the levels of markers and hierarchy to analyze. See Details.
report
one of "table", "vector", or "data.frame". Tables (Default) and data frame will report counts along with populations or individuals. Vectors will simply report which populations or individuals contain private alleles. Tables ar
level
one of "population" (Default) or "individual".
count.alleles
logical. If TRUE (Default), The report will return the observed number of alleles private to each population. If FALSE, each private allele will be counted once, regardless of dosage.

Value

  • a matrix, data.frame, or vector defining the populations or individuals containing private alleles. If vector is chosen, alleles are not defined.

Details

the argument form allows for control over the strata at which private alleles should be computed. It takes a form where the left hand side of the formula can be either "allele", "locus", or "loci". The right hand of the equation, by default is ".". If you change it, it must correspond to strata located in the strata slot. Note, that the right hand side is disabled for genpop objects.

Examples

Run this code
data(Pinf) # Load P. infestans data.
private_alleles(Pinf)

# Analyze private alleles based on the country of interest:
private_alleles(Pinf, alleles ~ Country)

# Number of observed alleles per locus
private_alleles(Pinf, locus ~ Country, count.alleles = TRUE)

# Get raw number of private alleles per locus.
(pal <- private_alleles(Pinf, locus ~ Country, count.alleles = FALSE))

# Get percentages.
sweep(pal, 2, nAll(Pinf)[colnames(pal)], FUN = "/")

# An example of how these data can be displayed.
library("ggplot2")
Pinfpriv <- private_alleles(Pinf, report = "data.frame")
ggplot(Pinfpriv) + geom_tile(aes(x = population, y = allele, fill = count))

Run the code above in your browser using DataLab