Learn R Programming

strataG (version 2.4.905)

freq2GenData: 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.

Examples

Run this code
# NOT RUN {
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)

# }

Run the code above in your browser using DataLab