freq2GenData: Convert Haplotype Frequency Matrices

Description Usage Arguments Value Author(s) Examples

View source: R/freq2GenData.R

Description

Create a data frame of stratified individuals and their haplotypes from a frequency table

Usage

1
2
3
4
5
6
7
freq2GenData(
  freq.mat,
  hap.col = NULL,
  freq.col = 1,
  id.label = NULL,
  hap.label = NULL
)

Arguments

freq.mat

a matrix or data.frame containing haplotypic frequencies with strata as column names.

hap.col

a number giving the column providing haplotype labels or a vector the same length as freq.mat. If NULL rownames are used.

freq.col

a number giving the first column containing haplotype frequencies.

id.label

character to label sample IDs with in resulting data.frame.

hap.label

character to label haplotypes with in resulting data.frame.

Value

a data frame with one row per sample and columns for id, strata, and haplotype, suitable for use in df2gtypes.

Author(s)

Eric Archer eric.archer@noaa.gov

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
hap.freqs <- data.frame(
  haps = c("hap1", "hap2", "hap3"),
  pop1 = rmultinom(1, 50, prob = c(0.1, 0.2, 0.7)),
  pop2 = rmultinom(1, 25, prob = c(0.5, 0.4, 0.1))
)

gen.data <- freq2GenData(hap.freqs, hap.col = 1, freq.col = 2)

x <- df2gtypes(gen.data, ploidy = 1)
summary(x)

strataG documentation built on Feb. 28, 2020, 9:07 a.m.