View source: R/random_bed_matrix_freqs.r
rbm.haplos.freqs | R Documentation |
Simulates genetic data with respect to allele frequency spectrum and linkage disequilibrium pattern observed on given haplotypes and their frequencies
rbm.haplos.freqs(haplos, freqs, size, replicates)
haplos |
A matrix of haplotypes with one row per haplotype and one column per variant |
freqs |
A matrix of haplotypes frequencies in each group of individuals |
size |
The sizes of each group of individuals |
replicates |
The number of simulations to perform |
Simulations are performed to respect linkage disequilibrium pattern and allelic frequency spectrum in each group of individuals
The phenotypic values will be the colnames of freqs
and stored in @ped$pheno
. The simulation number will be in @snps$genomic.region
.
x |
A bed matrix with simulated genotypes |
#Simulations of 5 groups of individuals with haplotypes frequencies
#from the 5 EUR populations
#Load LCT dataset for haplotype matrix
data(LCT.haplotypes)
#Haplotypes for the variants in the LCT gene in the EUR population
LCT.gene.hap <- LCT.hap[which(LCT.sample$super.population=="EUR"),
which(LCT.snps$pos>=136545410 & LCT.snps$pos<=136594750)]
#Individuals from EUR
LCT.sample.EUR <- subset(LCT.sample, super.population=="EUR")
#Matrix of haplotypic frequencies
LCT.freqs <- sapply(unique(LCT.sample.EUR$population), function(z)
ifelse(LCT.sample.EUR$population==z,
1/table(LCT.sample.EUR$population)[z], 0))
#Simulation of genetic data for five groups of 50 individuals
x <- rbm.haplos.freqs(haplos=LCT.gene.hap, freqs=LCT.freqs, size=rep(50,5), replicates=5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.