Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

writePlink

Writes a Pop-class as PLINK files


Description

Writes a Pop-class as PLINK PED and MAP files

Usage

writePlink(
  pop,
  baseName,
  trait = 1L,
  snpChip = 1L,
  simParam = NULL,
  chromLength = 10L^8
)

Arguments

pop

an object of Pop-class

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 SimParam

chromLength

an integer. The size of chromosomes in base pairs; assuming all chromosomes are of the same size.

Examples

## 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)

AlphaSimR

Breeding Program Simulations

v0.13.0
MIT + file LICENSE
Authors
Chris Gaynor [aut, cre] (<https://orcid.org/0000-0003-0558-6656>), Gregor Gorjanc [aut] (<https://orcid.org/0000-0001-8008-2787>), John Hickey [aut] (<https://orcid.org/0000-0001-5675-3974>), Daniel Money [ctb] (<https://orcid.org/0000-0001-5151-3648>), David Wilson [ctb]
Initial release
2020-10-20

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.