rpv_stats: Calculate Entropy Statistics

Description Usage Arguments Details Value Note References Examples

View source: R/entropy.R

Description

Because it's possible to have multiple results with a minimum number of samples, one way of assessing their importance is to calculate how distributed the alleles are among the samples. This can be done with entropy statistics

Usage

1
rpv_stats(tab, f = NULL)

Arguments

tab

a numeric matrix

f

a factor that is the same length as the number of columns in tab. this is used to split the matrix up by groups for analysis.

Details

This function caluclates four statistics from your data using variable counts.

Both G and eH can be thought of as the number of equally abundant variables to acheive the same observed diversity. Both G and eH give different weight to variables based on their abundance, so we use evenness to describe how uniform this distribution is.

Note that this version of Evenness is different than Shannon's Evenness, which is H/ln(S) where S is the number of variables (in our case).

If a vector of factors is supplied, the columns of the matrix is first split by this factor and each statistic calculated on each level.

Value

a data frame with three columns: eH, G, E5, lambda, and missing

Note

The calculations within this function are derived from the vegan and poppr R packages.

References

Claude Elwood Shannon. A mathematical theory of communication. Bell Systems Technical Journal, 27:379-423,623-656, 1948

Simpson, E. H. Measurement of diversity. Nature 163: 688, 1949 doi:10.1038/163688a0

J.A. Stoddart and J.F. Taylor. Genotypic diversity: estimation and prediction in samples. Genetics, 118(4):705-11, 1988.

E.C. Pielou. Ecological Diversity. Wiley, 1975.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
# Calculate statistics for the whole data set -----------------------------

data(monilinia)
rpv_stats(monilinia)

# Use a grouping factor for variables -------------------------------------
# Each variable in this data set represents and allele that is one of
# thirteen loci. If we wanted a table across all loci individually, we can
# group by locus name.

f <- gsub("[.][0-9]+", "", colnames(monilinia))
f <- factor(f, levels = unique(f))
colMeans(emon <- rpv_stats(monilinia, f = f)) # average entropy across loci
emon

# calculating entropy for minimum sets ------------------------------------

set.seed(1999)
i <- rpv_find(monilinia, n = 150, cut = TRUE, progress = FALSE)
colMeans(emon1 <- rpv_stats(monilinia[i[[1]], ], f = f))
colMeans(emon2 <- rpv_stats(monilinia[i[[2]], ], f = f))

zkamvar/repvar documentation built on May 7, 2019, 3:18 p.m.