freq2GenData: Convert Haplotype Frequency Matrices

View source: R/freq2GenData.R

freq2GenDataR Documentation

Convert Haplotype Frequency Matrices

Description

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

Usage

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

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)


EricArcher/strataG documentation built on Feb. 12, 2023, 4:11 a.m.