% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/simer.r
\name{simer}
\alias{simer}
\title{Main function of simer}
\usage{
simer(
  num.gen = 5,
  replication = 1,
  verbose = TRUE,
  mrk.dense = TRUE,
  incols = 2,
  outcols = 1,
  out = "simer",
  outpath = NULL,
  selPath = NULL,
  out.format = "numeric",
  seed.sim = runif(1, 0, 100),
  out.geno.gen = (num.gen - 2):num.gen,
  out.pheno.gen = 1:num.gen,
  rawgeno1 = NULL,
  rawgeno2 = NULL,
  rawgeno3 = NULL,
  rawgeno4 = NULL,
  num.ind = 100,
  prob = c(0.5, 0.5),
  input.map = NULL,
  len.block = 5e+07,
  range.hot = 4:6,
  range.cold = 1:5,
  rate.mut = 1e-08,
  cal.model = "A",
  FR = NULL,
  cv = NULL,
  var.pheno = NULL,
  h2.tr1 = c(0.3, 0.1, 0.05, 0.05, 0.05, 0.01),
  num.qtn.tr1 = 500,
  sd.tr1 = c(0.4, 0.2, 0.02, 0.02, 0.02, 0.02),
  dist.qtn.tr1 = rep("normal", 6),
  prob.tr1 = rep(0.5, 6),
  shape.tr1 = rep(1, 6),
  scale.tr1 = rep(1, 6),
  shape1.tr1 = rep(1, 6),
  shape2.tr1 = rep(1, 6),
  ncp.tr1 = rep(0, 6),
  multrait = FALSE,
  num.qtn.trn = matrix(c(400, 100, 100, 400), 2, 2),
  sd.trn = matrix(c(1, 0, 0, 0.5), 2, 2),
  gnt.cov = matrix(c(1, 2, 2, 16), 2, 2),
  h2.trn = c(0.3, 0.5),
  qtn.spot = rep(0.1, 10),
  maf = 0,
  sel.crit = "pheno",
  sel.on = TRUE,
  mtd.reprod = "randmate",
  userped = NULL,
  num.prog = 2,
  ratio = 0.5,
  prog.tri = 2,
  prog.doub = 2,
  prog.back = rep(2, num.gen),
  refresh = c(1, 0.6),
  keep.max.gen = rep(3, 2),
  ps = rep(0.8, 2),
  decr = TRUE,
  sel.multi = "index",
  index.wt = c(0.5, 0.5),
  index.tdm = 1,
  goal.perc = 0.1,
  pass.perc = 0.9,
  sel.sing = "comb"
)
}
\arguments{
\item{num.gen}{number of generations in simulation}

\item{replication}{replication index of simulation}

\item{verbose}{whether to print detail}

\item{mrk.dense}{whether markers are dense, it is TRUE when sequencing data}

\item{incols}{the column number of an individual in the input genotype matrix, it can be 1 or 2}

\item{outcols}{the column number of an individual in the output genotype matrix, it can be 1 or 2}

\item{out}{prefix of output file name}

\item{outpath}{path of output files}

\item{selPath}{the path of breeding_plan}

\item{out.format}{format of output, "numeric" or "plink"}

\item{seed.sim}{random seed of a simulation process}

\item{out.geno.gen}{indice of generations of output genotype}

\item{out.pheno.gen}{indice of generations of output phenotype}

\item{rawgeno1}{extrinsic genotype matrix1}

\item{rawgeno2}{extrinsic genotype matrix2}

\item{rawgeno3}{extrinsic genotype matrix3}

\item{rawgeno4}{extrinsic genotype matrix4}

\item{num.ind}{population size of the base population}

\item{prob}{weight of "0" and "1" in genotype matrix, the sum of elements in vector equal to 1}

\item{input.map}{map that should be input, the marker number should be consistent in both map file and genotype data}

\item{len.block}{length of every blocks}

\item{range.hot}{range of number of chromosome crossovers in a hot spot block}

\item{range.cold}{range of number of chromosome crossovers in a cold spot block}

\item{rate.mut}{mutation rate between 1e-8 and 1e-6}

\item{cal.model}{phenotype model with the options: "A", "AD", "ADI"}

\item{FR}{list of fixed effects, random effects, and their combination}

\item{cv}{list of population Coefficient of Variation or family Coefficient of Variation}

\item{var.pheno}{the phenotype variance, only used in single-trait simulation}

\item{h2.tr1}{heritability vector of a single trait, every element are corresponding to a, d, aXa, aXd, dXa, dXd respectively}

\item{num.qtn.tr1}{integer or integer vector, the number of QTN in a single trait}

\item{sd.tr1}{standard deviation of different effects, the last 5 vector elements are corresponding to d, aXa, aXd, dXa, dXd respectively and the rest elements are corresponding to a}

\item{dist.qtn.tr1}{distributions of the QTN effects with the options: "normal", "geometry", "gamma", and "beta", vector elements are corresponding to a, d, aXa, aXd, dXa, dXd respectively}

\item{prob.tr1}{unit effect of geometric distribution of a single trait, its length should be same as dist.qtn.tr1}

\item{shape.tr1}{shape of gamma distribution of a single trait, its length should be same as dist.qtn.tr1}

\item{scale.tr1}{scale of gamma distribution of a single trait, its length should be same as dist.qtn.tr1}

\item{shape1.tr1}{non-negative parameters of the Beta distribution, its length should be same as dist.qtn.tr1}

\item{shape2.tr1}{non-negative parameters of the Beta distribution, its length should be same as dist.qtn.tr1}

\item{ncp.tr1}{non-centrality parameter, its length should be same as dist.qtn.tr1}

\item{multrait}{whether to apply multiple traits, TRUE represents applying, FALSE represents not}

\item{num.qtn.trn}{QTN distribution matrix, diagonal elements are total QTN number of the trait, non-diagonal elements are QTN number of overlap QTN between two traits}

\item{sd.trn}{a matrix with the standard deviation of the QTN effects}

\item{gnt.cov}{genetic covariance matrix among all traits}

\item{h2.trn}{heritability among all traits}

\item{qtn.spot}{QTN probability in every block}

\item{maf}{Minor Allele Frequency, marker selection range is from maf to 0.5}

\item{sel.crit}{selection criteria with the options: "TGV", "TBV", "pEBVs", "gEBVs", "ssEBVs", and "pheno"}

\item{sel.on}{whether to add selection}

\item{mtd.reprod}{different reproduction methods with the options: "clone", "dh", "selfpol", "singcro", "tricro", "doubcro", "backcro","randmate", "randexself", and "userped"}

\item{userped}{user-designed pedigree to control mating process}

\item{num.prog}{litter size of dams}

\item{ratio}{ratio of the males in all individuals}

\item{prog.tri}{litter size of the first single cross process in trible cross process}

\item{prog.doub}{litter size of the first two single cross process in double cross process}

\item{prog.back}{a vector with litter size in every generation of back-cross}

\item{refresh}{refresh ratio of core population of sires and dams, only used in ps > 1}

\item{keep.max.gen}{the max keep generation range in the selection for sires and dams, only used in ps > 1}

\item{ps}{if ps <= 1, fraction selected in selection of males and females; if ps > 1, ps is number of selected males and females}

\item{decr}{whether to sort by descreasing}

\item{sel.multi}{selection method of multiple traits with options: "tdm", "indcul" and "index"}

\item{index.wt}{economic weights of selection index method, its length should equals to the number of traits}

\item{index.tdm}{index represents which trait is being selected}

\item{goal.perc}{percentage of goal more than mean of scores of individuals}

\item{pass.perc}{percentage of expected excellent individuals}

\item{sel.sing}{selection method of single trait with options: "ind", "fam", "infam" and "comb"}
}
\value{
a list with population information, genotype matrix, map information, selection intensity
}
\description{
Build date: Jan 7, 2019
Last update: Oct 13, 2019
}
\examples{
\donttest{
# get map file, map is necessary
data(simdata)

# run simer
simer.list <-
     simer(num.gen = 5,
           replication = 1,
           verbose = TRUE, 
           mrk.dense = TRUE,
           incols = 2, 
           outcols = 1, 
           out = "simer", 
           outpath = NULL,
           selPath = NULL, 
           out.format = "numeric",
           seed.sim = runif(1, 0, 100),
           out.geno.gen = 3:5,
           out.pheno.gen = 1:5,
           rawgeno1 = rawgeno,
           rawgeno2 = NULL,
           rawgeno3 = NULL,
           rawgeno4 = NULL,
           num.ind = NULL,
           prob = c(0.5, 0.5),
           input.map = input.map,
           len.block = 5e7,
           range.hot = 4:6,
           range.cold = 1:5,
           rate.mut = 1e-8,
           cal.model = "A",
           FR = NULL, 
           cv = NULL, 
           h2.tr1 = c(0.3, 0.1, 0.05, 0.05, 0.05, 0.01),
           num.qtn.tr1 = 500,
           sd.tr1 = c(0.4, 0.2, 0.02, 0.02, 0.02, 0.02),
           dist.qtn.tr1 = rep("normal", 6),
           prob.tr1 = rep(0.5, 6),
           shape.tr1 = rep(1, 6),
           scale.tr1 = rep(1, 6),
           shape1.tr1 = rep(1, 6),
           shape2.tr1 = rep(1, 6),
           ncp.tr1 = rep(0, 6),
           multrait = FALSE,
           num.qtn.trn = matrix(c(400, 100, 100, 400), 2, 2),
           sd.trn = matrix(c(0.07, 0, 0, 0.07), 2, 2),
           gnt.cov = matrix(c(1, 2, 2, 16), 2, 2),
           h2.trn = c(0.3, 0.5), 
           qtn.spot = rep(0.1, 10),
           maf = 0,
           sel.crit = "pheno",
           sel.on = TRUE, 
           mtd.reprod = "randmate",
           userped = userped,
           num.prog = 2,
           ratio = 0.5,
           prog.tri = 2,
           prog.doub = 2,
           prog.back = rep(2, 5),
           ps = rep(0.8, 2),
           decr = TRUE,
           sel.multi = "index",
           index.wt = c(0.5, 0.5),
           index.tdm = 1,
           goal.perc = 0.1,
           pass.perc = 0.9, 
           sel.sing = "comb") 
pop <- simer.list$pop
effs <- simer.list$effs
trait <- simer.list$trait
geno <- simer.list$geno
genoid <- simer.list$genoid
map <- simer.list$map
si <- simer.list$si
head(pop)
str(effs)
str(trait)
geno[1:6, 1:6]
genoid[1:6]
str(map)
si
}
}
\author{
Dong Yin, Lilin Yin, Haohao Zhang and Xiaolei Liu
}
