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

pullQtlGeno

Pull QTL genotype


Description

Retrieves QTL genotype data

Usage

pullQtlGeno(pop, trait = 1, chr = NULL, simParam = NULL)

Arguments

pop

an object of Pop-class

trait

an integer. Indicates which trait's QTL genotypes to retrieve.

chr

a vector of chromosomes to retrieve. If NULL, all chromosome are retrieved.

simParam

an object of SimParam

Details

#' @title Pull SNP genotype for multiple snp chips #' #' @description Retrieves SNP genotype data for multiple snp chips #' #' @param pop an object of Pop-class #' @param chips a vector. For each animal indicates what snp #' chip to use #' @param missing What value to use for missing #' @param simParam an object of SimParam #' #' @return Returns a matrix of SNP genotypes. #' #' @export pullMultipleSnpGeno = function(pop, chips, missing=9, simParam=NULL) if(is.null(simParam)) simParam = get("SP",envir=.GlobalEnv) # I feel like the next line shouldn't be needed but I don't know # enough R! (dmoney) missing = as.integer(missing) allSnps = numeric(0) uniqueChips = unique(chips) for (c in uniqueChips) allSnps = sort(union(allSnps,simParam$snpChips[[c]]@lociLoc))

output = matrix(pop@nInd,length(allSnps),data=missing) if(class(pop)=="Pop") rownames(output) = pop@id else rownames(output) = as.character(1:pop@nInd)

for (snpChip in uniqueChips) mask = allSnps one = getGeno(pop@geno, simParam$snpChips[[snpChip]]@lociPerChr, simParam$snpChips[[snpChip]]@lociLoc, simParam$nThreads) one = convToImat(one) for (i in 1:pop@nInd) if (chips[i] == snpChip) output[i,mask] = one[i,] output[i,mask] = one[i,]

colnames(output) = paste("SNP",1:ncol(output),sep="_")

return(output)

Value

Returns a matrix of QTL genotypes.

Examples

#Create founder haplotypes
founderPop = quickHaplo(nInd=10, nChr=1, segSites=15)

#Set simulation parameters
SP = SimParam$new(founderPop)
SP$addTraitA(10)
SP$addSnpChip(5)

#Create population
pop = newPop(founderPop, simParam=SP)
pullQtlGeno(pop, simParam=SP)

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.