frequencies: Get allele frequencies

Description Usage Arguments Value Note Author(s) Examples

View source: R/frequencies.R

Description

This function converts loci into data frames consisting of alleles, stratum, frequencies, etc.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
frequencies(x, loci, stratum, ...)

## Default S3 method:
frequencies(x, ...)

## S3 method for class 'locus'
frequencies(x, loci, ...)

## S3 method for class 'data.frame'
frequencies(x, loci, stratum, ...)

Arguments

x

Either a vector of types locus or a data.frame containing locus objects.

loci

The loci to get frequencies from (default is all).

stratum

Partition of the data based upon this stratum (default is no partitions).

...

Ignored

Value

A data frame with Frequencies, Alleles, Loci, and perhaps Stratum columns (Allele and Frequencies are at a minimum).

A data frame with Frequencies, Alleles, Loci, and perhaps Stratum columns (Allele and Frequencies are at a minimum).

A data frame with Frequencies, Alleles, Loci, and perhaps Stratum columns (Allele and Frequencies are at a minimum).

A data frame with Frequencies, Alleles, Loci, and perhaps Stratum columns (Allele and Frequencies are at a minimum).

Note

You can submit RAD-seq genotypes in a normal data.frame to this function BUT it must be formatted as follows. Each locus is represented by three columns of probabilities (must sum to 1). You must label the columns of your data frame with the name of the locus and a column number separated by an underscore '_' (e.g., Loc1_1, Loc1_2, Loc1_3, Loc2_1, Loc2_2, Loc2_3, etc). The function will name the locus the part before the dash (e.g., Loc1). The frequencies of the heterozygote genotype frequency represented in the middle position.

Author(s)

Rodney J. Dyer rjdyer@vcu.edu

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
AA <- locus( c("A","A") )
AB <- locus( c("A","B") )
BB <- locus( c("B","B") )
loc1 <- c(AA,AB,AB,AA,BB)
frequencies(loc1)
loc2 <- c(BB,BB,AB,AA,BB)
df <- data.frame(Population=c(rep("A",3), rep("B",2)), TPI=loc1, PGM=loc2)
frequencies(df)
frequencies(df,stratum="Population")
# RAD-seq example
m <- matrix(abs(rnorm(30)),nrow=10)
m <- m / rowSums(m)
df <- data.frame(m)
names(df) <- c("Loc1_1","Loc1_2","Loc1_3")
frequencies(df)

MarianaLag/Mlag documentation built on Feb. 13, 2020, 12:30 a.m.