Population: Population constructor.

View source: R/Population.R

PopulationR Documentation

Population constructor.

Description

The constructor for the Population object.

Usage

Population(
  pop = NULL,
  popSize = NULL,
  vcf = NULL,
  map = NULL,
  QTL = NULL,
  genotypes = NULL,
  literal = TRUE,
  alleleFrequencies = NULL,
  broadH2 = NULL,
  narrowh2 = NULL,
  traitVar = NULL,
  h2est = NULL
)

Arguments

pop

an optional Population object to use for default values

popSize

an optional number of individuals in the new Population to be created

vcf

an optional VCF file which will provide the map and genotypes

map

an optional data.frame specifying the name, chromosome and position (in base-pairs) of each SNP

QTL

an optional argument giving either a single number which specifies the number of SNPs to randomly select as QTLs, or a vector of SNP IDs (from map) to select as QTLs

genotypes

an optional matrix of genotypes to use for the population; see below for details

literal

an optional logical value specifying whether to use the genotypes directly or to generate new genotypes based on the allele frequencies of the given genotypes

alleleFrequencies

an optional vector of allele frequencies for generating genotypes

broadH2

initial broad-sense heritability within the new Population

narrowh2

initial narrow-sense heritability within the new Population

traitVar

initial phenotypic variance within the new Population

h2est

suggested heritability estimate for the new Population

Details

Population() creates a new Population object based on arguments which optionally modify a previously defined Population object. If no Population object is given, the new Population is created using only the arguments given.

The arguments vcf, map, genotypes, literal and alleleFrequencies all work together in a specific way.

If a VCF file is supplied via the vcf argument, the map, genotypes and alleleFrequencies arguments are not needed, since a map and set of genotypes are given within the VCF file. If the number of individuals' genotypes given by the VCF file does not match the number of individuals specified by the popSize argument, the supplied genotypes within the VCF file are used to suggest allele frequencies only: this behaviour can also be forced by setting the literal argument to FALSE.

The genotypes argument supplies genotypes directly. In this case, the user should supply a phased, individual-major genotypes matrix: one individual per row and two columns per single nucleotide polymorphism (SNP). Odd columns are assumed to be the haplotypes inherited from the sires, while even columns are assumed to be the haplotypes inherited from the dams. As with genotypes supplied via a VCF file, if the number of individuals' genotypes given by the matrix does not match the number of individuals specified by the popSize argument, the supplied genotypes are used to suggest allele frequencies only; again, this behaviour can also be forced by setting the literal argument to FALSE.

When supplying genotypes either directly or via a VCF file, all SNPs should be biallelic and phased, with no missing values. Genotypes supplied directly should have variants coded as either 0 or 1.

Any map (either supplied directly or via a VCF file) will be sorted, such that all SNPs along the first chromosome listed will appear at the start of the map, sorted in terms of base-pair distance; the second chromosome to appear will then be treated similarly, and so on. SNPs will be referenced within the population in this order.

The alleleFrequencies argument is used when genotypes are not given directly. In this case, the literal argument has no meaning.

An example map data.frame has been included in the epinetr package as map100snp. Note that all chromosomes must be autosomal, whether given via the map parameter or via a VCF file.

The Population object will estimate breeding values once all necessary effects are given. An optional heritability estimate can be supplied using the h2est parameter.

When supplying an existing Population object, any additive effects and epistatic network will be carried over from the previous population unless new QTLs are supplied.

Note that if broadH2 is equal to narrowh2, no epistatic effects will be present; if narrowh2 is 0, no additive effects will be present; if broadH2 is 1, no environmental effects will be present.

The h2est argument bypasses REML-based heritability estimates by supplying a user-defined heritability estimate for use in calculating estimated SNP effects.

Value

The constructor creates a new object of class 'Population'.

Author(s)

Dion Detterer, Paul Kwan, Cedric Gondro

See Also

addEffects, attachEpiNet, print.Population

Examples

# Construct a new population of size 500, with random allele
# frequencies and 20 QTLs chosen at random, broad-sense
# heritability set to 0.9, narrow-sense heritability set to 0.75
# and overall trait variance set to 40.

pop <- Population(
  popSize = 500, map = map100snp, QTL = 20,
  alleleFrequencies = runif(100), broadH2 = 0.9,
  narrowh2 = 0.75, traitVar = 40
)

# Construct a new population of size 500 using directly supplied
# genotypes and 20 QTLs chosen at random, broad-sense heritability
# set to 0.7, narrow-sense heritability set to 0.3 and overall
# trait variance set to 10.

pop2 <- Population(
  map = map100snp, genotypes = geno100snp,
  literal = TRUE, QTL = 20,
  broadH2 = 0.7, narrowh2 = 0.3, traitVar = 10
)

# Modify the previous population to have narrow-sense heritabilty
# set to 0.45 and overall trait variance set to 20.

pop2 <- Population(pop2, narrowh2 = 0.45, traitVar = 20)

epinetr documentation built on March 18, 2022, 7:01 p.m.