This script takes a G matrix generated by gl.grm
and represents
the relationship among the specimens as a network diagram. In order to use
this script, a decision is required on a threshold for relatedness to be
represented as link in the network, and on the layout used to create the
diagram.
gl.grm.network(
G,
x,
method = "fr",
node.size = 6,
node.label = TRUE,
node.label.size = 2,
node.label.color = "black",
relatedness_factor = 0.25,
title = "Network based on a genomic relationship matrix",
palette_discrete = discrete_palette,
save2tmp = FALSE,
verbose = NULL
)
A genomic relationship matrix (GRM) generated by
gl.grm
[required].
A genlight object from which the G matrix was generated [required].
One of 'fr', 'kk', 'gh' or 'mds' [default 'fr'].
Size of the symbols for the network nodes [default 6].
TRUE to display node labels [default TRUE].
Size of the node labels [default 3].
Color of the text of the node labels [default 'black'].
Factor of relatedness[default 0.5].
Title for the plot [default 'Network based on genomic relationship matrix'].
A discrete palette for the color of populations or a list with as many colors as there are populations in the dataset [default discrete_palette].
If TRUE, saves any ggplots and listings to the session temporary directory (tempdir) [default FALSE].
Verbosity: 0, silent or fatal errors; 1, begin and end; 2, progress log ; 3, progress and results summary; 5, full report [default 2 or as specified using gl.set.verbosity].
A network plot showing relatedness between individuals
As identity by descent is not an absolute state, but is relative to a reference population for which there is generally little information, we can estimate the kinship of a pair of individuals only relative to some other quantity (Goudet et al., 2018). In this script, we use the average inbreeding coefficient (1-f) of the diagonal elements as the reference value. This reference value is then subtracted from the inbreeding coefficient of each pair of distinct individuals. This approach is similar to the used by Goudet et al. (2018).
Four layout options are implemented in this function:
'fr' Fruchterman-Reingold layout layout_with_fr (package igraph)
'kk' Kamada-Kawai layout layout_with_kk (package igraph)
'gh' Graphopt layout layout_with_graphopt (package igraph)
'mds' Multidimensional scaling layout layout_with_mds (package igraph)
The threshold for relatedness to be represented as a link in the network is specified as a quantile. Those relatedness measures above the quantile are plotted as links, those below the quantile are not. Often you are looking for relatedness outliers in comparison with the overall relatedness among individuals, so a very conservative quantile is used (e.g. 0.004), but ultimately, this decision is made as a matter of trial and error. One way to approach this trial and error is to try to achieve a sparse set of links between unrelated 'background' individuals so that the stronger links are preferentially shown.
Goudet, J., Kay, T., & Weir, B. S. (2018). How to estimate kinship. Molecular Ecology, 27(20), 4121-4135.
Other inbreeding functions:
gl.grm()
# NOT RUN {
gl_test <- bandicoot.gl
# five populations in gl_test
nPop(gl_test)
# color list for population colors
pop_colors <- c('deepskyblue','green','gray','orange','deeppink')
G_out <- gl.grm(gl_test,plotheatmap=FALSE)
gl.grm.network(G_out, gl_test, palette_discrete = pop_colors, relatedness_factor = 0.25)
# }
Run the code above in your browser using DataLab