Level 0 function that returns Genomic Relatedness Matrix (GRM) for honeybees from Identical By Descent genomic data (tracked alleles since the founders) - see references on the background theory.

calcBeeGRMIbd(x)

Arguments

x

matrix of haplotypes/genomes with allele indicators for the founders coded as 1, 2, ... Haplotypes/genome are in rows and sites are in columns; no missing values are allowed (this is not checked!). Row names are essential (formated as ind_genome as returned by AlphaSimR IBD functions) to infer the individual and their ploidy (see examples)!

Value

a list with a matrix of gametic relatedness coefficients (genome) and a matrix of individual relatedness coefficients (indiv)

References

Grossman and Eisen (1989) Inbreeding, coancestry, and covariance between relatives for X-chromosomal loci. The Journal of Heredity, doi:/10.1093/oxfordjournals.jhered.a110812

Fernando and Grossman (1989) Covariance between relatives for X-chromosomal loci in a population in disequilibrium. Theoretical and Applied Genetics, doi:/10.1007/bf00305821

Fernando and Grossman (1990) Genetic evaluation with autosomal and X-chromosomal inheritance. Theoretical and Applied Genetics, doi:/10.1007/bf00224018

Van Arendonk, Tier, and Kinghorn (1994) Use of multiple genetic markers in prediction of breeding values. Genetics, doi:/10.1093/genetics/137.1.319

Hill and Weir (2011) Variation in actual relationship as a consequence of Mendelian sampling and linkage. Genetics Research, doi:/10.1017/s0016672310000480

Examples

founderGenomes <- quickHaplo(nInd = 3, nChr = 1, segSites = 100)
SP <- SimParamBee$new(founderGenomes)
SP$setTrackRec(TRUE)
SP$setTrackPed(isTrackPed = TRUE)

basePop <- createVirginQueens(founderGenomes)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
drones <- createDrones(x = basePop[1], nInd = 1000)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
droneGroups <- pullDroneGroupsFromDCA(drones, n = 1, nDrones = nFathersPoisson)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
colony <- createColony(basePop[2])
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
colony <- cross(x = colony, drones = droneGroups[[1]])
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
colony <- buildUp(x = colony, nWorkers = 6, nDrones = 3)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found

haploQ <- getQueenIbdHaplo(colony)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
haploW <- getWorkersIbdHaplo(colony)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
haploD <- getDronesIbdHaplo(colony)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
SP$pedigree
#>      [,1] [,2] [,3]

haplo <- rbind(haploQ, haploW, haploD)
#> Error in rbind(haploQ, haploW, haploD): object 'haploQ' not found

GRMs <- calcBeeGRMIbd(x = haplo)
#> Error in calcBeeGRMIbd(x = haplo): object 'haplo' not found
# You can visualise this matrix with the image() functions from the "Matrix" package

# Inspect the diagonal of the relationship matrix between individuals
x <- diag(GRMs$indiv)
#> Error in diag(GRMs$indiv): object 'GRMs' not found
hist(x)
#> Error in hist(x): object 'x' not found
summary(x)
#> Error in summary(x): object 'x' not found

 # Inspect the off-diagonal of the relationship matrix between individuals
x <- GRMs$indiv[lower.tri(x = GRMs$indiv, diag = FALSE)]
#> Error in eval(expr, envir, enclos): object 'GRMs' not found
hist(x)
#> Error in hist(x): object 'x' not found
summary(x)
#> Error in summary(x): object 'x' not found

ids <- getCasteId(colony)
#> Error in get(x = "SP", envir = .GlobalEnv): object 'SP' not found
qI <- ids$queen
#> Error in eval(expr, envir, enclos): object 'ids' not found
wI <- sort(ids$workers)
#> Error in sort(ids$workers): object 'ids' not found
dI <- sort(ids$drones)
#> Error in sort(ids$drones): object 'ids' not found

qG <- c(t(outer(X = qI, Y = 1:2, FUN = paste, sep = "_")))
#> Error in outer(X = qI, Y = 1:2, FUN = paste, sep = "_"): object 'qI' not found
wG <- c(t(outer(X = wI, Y = 1:2, FUN = paste, sep = "_")))
#> Error in outer(X = wI, Y = 1:2, FUN = paste, sep = "_"): object 'wI' not found
dG <- paste(dI, 1, sep = "_")
#> Error in paste(dI, 1, sep = "_"): object 'dI' not found

# Queen vs workers
GRMs$genome[wG, qG]
#> Error in eval(expr, envir, enclos): object 'GRMs' not found
GRMs$indiv[wI, qI]
#> Error in eval(expr, envir, enclos): object 'GRMs' not found

# Queen vs drones
GRMs$genome[dG, qG]
#> Error in eval(expr, envir, enclos): object 'GRMs' not found
GRMs$indiv[dI, qI]
#> Error in eval(expr, envir, enclos): object 'GRMs' not found

# Workers vs workers
GRMs$genome[wG, wG]
#> Error in eval(expr, envir, enclos): object 'GRMs' not found
GRMs$indiv[wI, wI]
#> Error in eval(expr, envir, enclos): object 'GRMs' not found

# Workers vs drones
GRMs$genome[dG, wG]
#> Error in eval(expr, envir, enclos): object 'GRMs' not found
GRMs$indiv[dI, wI]
#> Error in eval(expr, envir, enclos): object 'GRMs' not found