Learn R Programming

pooledpeaks (version 1.1.1)

AlRich: Calculate Allelic Richness

Description

This function calculates allelic richness based on provided genetic data.

Usage

AlRich(datafile = data.frame, n = matrix)

Value

A vector containing the allelic richness for each locus.

Arguments

datafile

A data frame containing the data as read in by LoadData

n

A matrix representing the number of markers successfully genotyped like the output of the TypedLoci function.

Examples

Run this code

genetic_data <- data.frame(
Locus = c(1, 1, 1, 1, 1, 2, 2, 2, 2, 2),
Locus_allele = c("Marker1", "n", 1, 2, 3, "Marker2", "n", 1, 2, 3),
Sample1 = c(NA, 10, 0.5, 0.5, 0, NA, 10, 0.2, 0.3, 0.5),
Sample2 = c(NA, 20, 0.1, 0.2, 0.7, NA, 20, 0.3, 0.4, 0.3),
Sample3 = c(NA, 30, 0.3, 0.4, 0.3, NA, 30, 0.4, 0.2, 0.4)
)

n_alleles <- matrix(c(
3, 3, 3,
3, 3, 3,
3, 3, 3
), nrow = 3, byrow = TRUE,
dimnames = list(paste0("Sample", 1:3), paste0("Sample", 1:3)))

AlRich(datafile=genetic_data,n=n_alleles)

Run the code above in your browser using DataLab