Learn R Programming

AlphaSimR (version 0.11.1)

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

Value

Returns a matrix of QTL genotypes.

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)

Examples

Run this code
# NOT RUN {
#Create founder haplotypes
founderPop = quickHaplo(nInd=10, nChr=1, segSites=10)

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

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

# }

Run the code above in your browser using DataLab