sim.phe: Simulation for phenotypes (SimPhe main process)

Description Usage Arguments Details Value Author(s) Examples

Description

Main process of simulation for phenotypes

Usage

1
2
3
4
5
sim.phe(sim.pars = NULL, fgeno = NULL, ftype = c("ind.head", "plink",
  "snp.head"), fwrite = TRUE, fphename = "simu.pheno",
  fusepar = "usedpars.txt", seed = NA, Dskim = 0, noise.var = 1,
  pattern = "[[:alpha:]]+", plink.path = system("which plink"),
  genetic.model = "epistasis", ...)

Arguments

sim.pars

a prepared list containing the parameters settings for simulation or a file of parameters settings. Please set your own parameters following the same structure as the object genepars or as the file simupars.txt (you could find example file
system.file("extdata","simupars.txt",package="SimPhe")).

To specify heritability, there are two ways: one is to set heritability in parameter file or in the prepared list object which will futher pass to sim.pars. Another way is to set noise.var by using function get.noise.var given specify heritability.

List format: please follow the example of the object genepars. The meaning of each elment in the list is similar like the file format description below.

File format: please follow the example of the simupars.txt file found in the inst/extdata/ directory of the package (run
system.file("extdata", "simupars.txt", package="SimPhe")
to to get the path to the file), blank lines are ignored. The file consists of three or four blocks for each phenotype (the number of blocks depends on user): mean, main and epistasis, sometimes heritability. Each block is started by a line of the form '[blockname]' followed by the parameter setting for the block, e.g. for first phenotype,

[P1mean]
mean

β_0: coefficient parameter of "basic" genetic effects in Gij = β_0 + ∑(β_Gwt*wtij), t in (1, 2, ..., 8).

[P1main]
SNP

SNP name

additive

coefficient of additive effect

dominance

coefficient of dominance effect

[P1epistasis]
SNPA

first SNP

SNPB

second SNP

additive_additive

coefficient for additive-additive interaction

additive_dominance

coefficient for additive-dominance interaction

dominance_additive

coefficient for dominance-additive interaction

dominance_dominance

coefficient for dominance-dominance interaction

[P1heritability]
heritability

expected heritability

Similar meanings for "[P2mean]", "[P2main]", "[P2epistasis]", and so on.

fgeno

file to read genotype information from or pre-read data.frame with that information (matching the output format of read.geno).

ftype

genotype file format, it accepts three options:

"plink":

plink format (.bed, .bim, .fam or .map, .ped);

"ind.head":

columns are the indviduals and lines are SNPs;

"snp.head":

columns are SNPs and lines are indviduals.

For "plink", fgeno needs to be given without suffix and plink.path may need to be assigned by the user because plink will be run from within SimPhe. More detail see plink.path. For the other options, fgeno should be the full name (with suffix and path if necessary) of the genotype file. Of course, this does not apply if fgeno is provided as a data frame.

fwrite

logical. Write out file (simulated data) or not. If TRUE (default), simulated phenotypes will be written, respectively.

fphename

filename of the phnotype(s). Default is "simu.pheno".

fusepar

filename of the setting for simulation (for recording). Default is "usedpars.txt".

seed

an integer used for set.seed(). Default is NA.

Dskim

the coefficient of linkage disequilibrium. Default is 0 (no LD).

noise.var

variance for random noise. Default is 1. Note that this is overridden by the heritability setting in the simulation parameter file. If heritability is given in parameter file then noise.var will not work.

pattern

ignore pattern for detecting the phenotype index from the parameter names. Default is "[[:alpha:]]+" which means letters.

plink.path

path of plink executable. Only needed when the ftype is "plink". Default is NULL. The function will detect the plink path with system("where plink") for Windows users and system("which plink") for Linux and MacOS users. But there is no garantee that the commands work on all devices. If the path cannot be determined or the executable cannot be called from read.geno, then users have to try other formats.

genetic.model

a string show the genetic model to use for simulation. Default is "epistasis".

...

not used.

Details

further discussion on pattern

Value

a data.frame with the simulated phenotype(s) where the column(s) refer to different phenotype(s) and rows to individuals.

Author(s)

Beibei Jiang beibei_jiang@psych.mpg.de and Benno Pütz puetz@psych.mpg.de

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#### file path of example
# simulation parameters:
fpar.path <- system.file("extdata", "simupars.txt", package="SimPhe")

# genotype file: rows are individuals and columns are SNPs
fgeno.path <- system.file("extdata", "10SNP.txt", package="SimPhe")


#### instead of a parameter file, prepared list like genepars also works
genepars


#### simulate phenotype(s)
phe <- sim.phe(sim.pars = fpar.path, fgeno = fgeno.path, ftype = "snp.head", fwrite = FALSE)
# or
phe <- sim.phe(sim.pars = genepars, fgeno = fgeno.path, ftype = "snp.head", fwrite = FALSE)

# the simulated phenotype(s)
str(phe)
head(phe)

SimPhe documentation built on May 1, 2019, 9:10 p.m.