Writes a Pop-class as PLINK files
Writes a Pop-class as PLINK PED and MAP files
writePlink( pop, baseName, trait = 1L, snpChip = 1L, simParam = NULL, chromLength = 10L^8 )
pop |
an object of |
baseName |
a character. Basename of PED and MAP files. |
trait |
an integer. Which phenotype trait should be used. |
snpChip |
an integer. Which SNP array should be used. |
simParam |
an object of |
chromLength |
an integer. The size of chromosomes in base pairs; assuming all chromosomes are of the same size. |
## Not run:
#Create founder haplotypes
founderPop = quickHaplo(nInd=10, nChr=1, segSites=10)
#Set simulation parameters
SP = SimParam$new(founderPop)
SP$setSexes(sex = "yes_rand")
SP$addTraitA(nQtlPerChr = 10)
SP$addSnpChip(nSnpPerChr = 5)
#Create population
pop = newPop(rawPop = founderPop)
pop = setPheno(pop, varE = SP$varA)
writePlink(pop, baseName="test")
#Test
test = read.table(file = "test.ped")
#...sex
if (!identical(x = c("M", "F")[test[[5]]], y = pop@sex)) { stop() }
#...pheno (issues with rounding)
# if (!identical(x = test[[6]], y = pop@pheno[, 1])) { stop() }
#...genotypes
x = test[, -(1:6)] - 1
x[, 1] = x[, 1] + x[, 2]
x[, 2] = x[, 3] + x[, 4]
x[, 3] = x[, 5] + x[, 6]
x[, 4] = x[, 7] + x[, 8]
x[, 5] = x[, 9] + x[, 10]
y = pullSnpGeno(pop)
if (sum(x[, 1:5] - y) != 0) { stop() }
## End(Not run)Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.