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

pullQtlHaplo

Pull QTL haplotypes


Description

Retrieves QTL haplotype data

Usage

pullQtlHaplo(pop, trait = 1, haplo = "all", chr = NULL, simParam = NULL)

Arguments

pop

an object of Pop-class

trait

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

haplo

either "all" for all haplotypes or an integer for a single set of haplotypes. Use a value of 1 for female haplotyes and a value of 2 for male haplotypes.

chr

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

simParam

an object of SimParam

Details

#' @title Pull SNP haplotypes for multiple chips #' #' @description Retrieves SNP haplotype data for multiple snp #' #' @param pop an object of Pop-class #' @param chips a vector. For each animal indicates what snp #' chip to use #' @param haplo either "all" for all haplotypes or an integer #' for a single set of haplotypes. Use a value of 1 for female #' haplotyes and a value of 2 for male haplotypes. #' @param missing What value to use for missing #' @param simParam an object of SimParam #' #' @return Returns a matrix of SNP haplotypes. #' #' @export pullMultipleSnpHaplo = function(pop, chips, haplo="all", 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))

if (haplo == "all") output = matrix(pop@nInd*2,length(allSnps),data=missing) if(class(pop)=="Pop") rownames(output) = paste(rep(pop@id,each=pop@ploidy), rep(1:pop@ploidy,pop@nInd),sep="_") else rownames(output) = paste(rep(1:pop@nInd,each=pop@ploidy), rep(1:pop@ploidy,pop@nInd),sep="_") else output = matrix(pop@nInd,length(allSnps),data=missing) if(class(pop)=="Pop") rownames(output) = paste(pop@id,rep(haplo,pop@nInd),sep="_") else rownames(output) = paste(1:pop@nInd,rep(haplo,pop@nInd),sep="_") for (snpChip in uniqueChips) mask = allSnps if (haplo == "all") one = getHaplo(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*2-1,mask] = one[i*2-1,] output[i*2,mask] = one[i*2,] else one = getOneHaplo(pop@geno, simParam$snpChips[[snpChip]]@lociPerChr, simParam$snpChips[[snpChip]]@lociLoc, as.integer(haplo), 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 haplotypes.

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)
pullQtlHaplo(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.