Learn R Programming

mlPhaser (version 0.01)

simGenoFromHaplo: Simulate genotypes

Description

Simulates genotypes from a table of haplotypes.

Usage

simGenoFromHaplo(haploTable, haploFreqs, n = 1, ploidy = 2)

Arguments

haploTable
The list of haplotypes in table format
haploFreqs
A named vector of haplotype frequencies.
n
How many genotypes to simulate.
ploidy
How many alleles per locus. Default = 2.

Value

A data.frame of genotypes. Each locus will have multiple colums as per the ploidy level.

Details

Simulates n genotypes from a table of haplotypes. Genotypes will include one allele per ploidy level.

Examples

Run this code
# create a data frame to store alleles of haplotypes. Columns are loci.
haplotypes <- data.frame(	A= c("a","b","c","a","b","c","b"),
					B= c("a","b","c","b","c","a","a"),
					C= c("a","b","c","b","c","a","a") )
# give the haplotypes sensible names as rownames.
rownames(haplotypes) <- apply(haplotypes, 1, paste,sep="" , collapse="")
# Create a named vector of haplotype frequencies.
haploFreqs <- c(0.4, 0.3, 0.15, 0.07,0.05, 0.02, 0.01)
names(haploFreqs) <- rownames(haplotypes)

# simulate a set of genotypes
my.genotypes <- simGenoFromHaplo(haploTable=haplotypes, haploFreqs=haploFreqs , n=20, ploidy=2)

Run the code above in your browser using DataLab