create_pop: Create a population object

View source: R/pop_functions.R

create_popR Documentation

Create a population object

Description

Assembles genotype data and into a pop object.

Usage

create_pop(genome, geno, ignore.gen.model = FALSE)

Arguments

genome

An object of class genome.

geno

Genotype data on a population to phenotype. If the genome type is "pbsim", must be a matrix of dimensions n.ind x n.loci, the elements of which must be z 0, 1, 2, or a list of such matrices. If the genome type is "hypred", must be an array of dimensions 2 x n.loci x n.ind, the elements of which must be z 0, 1.

ignore.gen.model

Logical - should any gene model be ignored when creating the population? Use this to force a population without a gene model.

Details

A pop is similar to a cross object in qtl-package (see read.cross). The pop object stores information on the genome, the genotypes at genetic markers, and phenotypes. The pop object is meant to be a bit more flexible, without the pedigree or family structure required in a cross object.

Value

An object of class pop with genotype information for the individuals in that population and the genotypic value of those individuals.

The genotypic value of individuals is calculcated as the sum of the QTL effects carried by each individual. The genetic variance is calculated as the variance of these genotypic values (V_G = var(g)).

Examples


## Not run: 

# Use data from the PopVar package
library(PopVar)
data("think_barley")

# Format the map correctly and simulate a genome
map_in <- map.in_ex[,-1]
row.names(map_in) <- map.in_ex$mkr
genome <- sim_genome(map = table_to_map(map_in))

genos <- apply(X = G.in_ex[-1,-1], MARGIN = 2, FUN = as.numeric)
dimnames(genos) <- list(as.character(G.in_ex$V1[-1]), as.character(unlist(G.in_ex[1,-1])))

# Impute with the rounded mean
genos1 <- apply(X = genos, MARGIN = 2, FUN = function(snp) {
  mean <- ifelse(mean(snp, na.rm = T) < 0, -1, 1)
  snp[is.na(snp)] <- mean
  return(snp) })

## Create a population without a genetic model
pop <- create_pop(genome = genome, geno = genos1 + 1, ignore.gen.model = T)

## Create a genetic model with 15 QTL
qtl.model <- matrix(NA, ncol = 4, nrow = 15)
genome <- sim_gen_model(genome = genome, qtl.model = qtl.model, add.dist = "geometric")

pop <- create_pop(genome = genome, geno = genos1 + 1)


## End(Not run)



neyhartj/pbsim documentation built on Nov. 11, 2023, 4:07 p.m.