gl.test.heterozygosity {dartR.base} | R Documentation |
Tests the difference in heterozygosity between populations taken pairwise
Description
Calculates the expected heterozygosities for each population in a genlight object, and uses re-randomization to test the statistical significance of differences in heterozygosity between populations taken pairwise.
Expected heterozygosity is calculated using the correction for sample size following equation 2 from Nei 1978.
Usage
gl.test.heterozygosity(
x,
nreps = 100,
alpha1 = 0.05,
alpha2 = 0.01,
plot.out = TRUE,
max_plots = 6,
plot.theme = theme_dartR(),
plot.colors = gl.select.colors(ncolors = 2, verbose = 0),
plot.file = NULL,
plot.dir = NULL,
verbose = NULL
)
Arguments
x |
A genlight object containing the SNP genotypes [required]. |
nreps |
Number of replications of the re-randomization [default 1,000]. |
alpha1 |
First significance level for comparison with diff=0 on plot [default 0.05]. |
alpha2 |
Second significance level for comparison with diff=0 on plot [default 0.01]. |
plot.out |
If TRUE, plots a sampling distribution of the differences for each comparison [default TRUE]. |
max_plots |
Maximum number of plots to print per page [default 6]. |
plot.theme |
Theme for the plot. See Details for options [default theme_dartR()]. |
plot.colors |
List of two color names for the borders and fill of the plots [default gl.colors(2)]. |
plot.file |
Name for the RDS binary file to save (base name only, exclude extension) [default NULL] |
plot.dir |
Directory to save the plot RDS files [default as specified by the global working directory or tempdir()] |
verbose |
Verbosity: 0, silent or fatal errors; 1, begin and end; 2, progress log; 3, progress and results summary; 5, full report [default NULL, unless specified using gl.set.verbosity]. |
Details
Function's output If plot.out = TRUE, plots are created showing the sampling distribution for the difference between each pair of heterozygosities, marked with the critical limits alpha1 and alpha2, the observed heterozygosity, and the zero value (if in range). If a plot.file is given, the ggplot arising from this function is saved as an "RDS" binary file using saveRDS(); can be reloaded with readRDS(). A file name must be specified for the plot to be saved. If a plot directory (plot.dir) is specified, the ggplot binary is saved to that directory; otherwise to the tempdir(). Examples of other themes that can be used can be consulted in
Value
A dataframe containing population labels, heterozygosities and sample sizes
Author(s)
Custodian: Luis Mijangos (Post to https://groups.google.com/d/forum/dartr)
References
Nei, M. (1978). Estimation of average heterozygosity and genetic distance from a small number of individuals. Genetics, 89(3), 583-590.
Examples
out <- gl.test.heterozygosity(platypus.gl, nreps=1, verbose=3, plot.out=TRUE)