Tabulate alleles the occur in only one population.

Share:

Description

Tabulate alleles the occur in only one population.

Usage

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

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 are matrices with populations or individuals in rows and alleles in columns. Data frames are long form.

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.

drop

logical. if TRUE, populations/individuals without private alleles will be dropped from the result. Defaults to FALSE.

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.

Value

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

Author(s)

Zhian N. Kamvar

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
data(Pinf) # Load P. infestans data.
private_alleles(Pinf)

## Not run: 
# 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))

## End(Not run)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.