diversity_stats: Produce a table of diversity statistics

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/bootstraping.R

Description

Calculate diversity statistics on a matrix containing counts of multilocus genotypes per population.

Usage

1
diversity_stats(z, H = TRUE, G = TRUE, lambda = TRUE, E5 = TRUE, ...)

Arguments

z

a table of integers representing counts of MLGs (columns) per population (rows)

H

logical whether or not to calculate Shannon's index

G

logical whether or not to calculate Stoddart and Taylor's index (aka inverse Simpson's index).

lambda

logical whether or not to calculate Simpson's index

E5

logical whether or not to calculate Evenness

...

any functions that can be calculated on a vector or matrix of genotype counts.

Details

This function will calculate any diversity statistic for counts of multilocus genotypes per population. This does not count allelic diversity. The calculations of H, G, and lambda are all performed by vegan::diversity(). E5 is calculated as

(G - 1)/(exp(H) - 1)

.

Value

a numeric matrix giving statistics (columns) for each population (rows).

Author(s)

Zhian N. Kamvar

See Also

diversity_boot() diversity_ci() poppr()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
library(poppr)
data(Pinf)
tab <- mlg.table(Pinf, plot = FALSE)
diversity_stats(tab)
## Not run: 
# Example using the poweRlaw package to calculate the negative slope of the
# Pareto distribution.

library("poweRlaw")
power_law_beta <- function(x){
  xpow <- displ(x[x > 0])                 # Generate the distribution
  xpow$setPars(estimate_pars(xpow))       # Estimate the parameters
  xdat <- plot(xpow, draw = FALSE)        # Extract the data
  xlm <- lm(log(y) ~ log(x), data = xdat) # Run log-log linear model for slope
  return(-coef(xlm)[2])
}

Beta <- function(x){
  x <- drop(as.matrix(x))
  if (length(dim(x)) > 1){
    res <- apply(x, 1, power_law_beta)
  } else {
    res <- power_law_beta(x)
  }
  return(res)
}

diversity_stats(tab, B = Beta)

## End(Not run)

Example output

Loading required package: adegenet
Loading required package: ade4

   /// adegenet 2.0.1 is loaded ////////////

   > overview: '?adegenet'
   > tutorials/doc/questions: 'adegenetWeb()' 
   > bug reports/feature requests: adegenetIssues()


This is poppr version 2.5.0. To get started, type package?poppr
OMP parallel support: available
               Index
Pop                    H        G    lambda       E.5
  South America 3.267944 23.29032 0.9570637 0.8825297
  North America 3.687013 34.90909 0.9713542 0.8711297
               Index
Pop                    H        G    lambda       E.5        B
  South America 3.267944 23.29032 0.9570637 0.8825297 2.087440
  North America 3.687013 34.90909 0.9713542 0.8711297 2.735194

poppr documentation built on Feb. 7, 2021, 1:06 a.m.