gen_graph_topo {graph4lg} | R Documentation |
Create a graph of genetic differentiation with a specific topology
Description
The function constructs a genetic graph with a specific topology from genetic and/or geographical distance matrices
Usage
gen_graph_topo(mat_w, mat_topo = NULL, topo = "gabriel", k = NULL)
Arguments
mat_w |
A symmetric (pairwise) |
mat_topo |
(optional) A symmetric (pairwise) distance |
topo |
Which topology does the created graph have?
|
k |
(if 'topo = 'knn”) An integer which indicates the number of nearest neighbors considered to create the K-nearest neighbor graph. k must be lower than the total number of nodes minus 1. |
Details
If 'mat_topo' is not defined, 'mat_w' is used for the pruning. Matrices 'mat_w' and 'mat_topo' must have the same dimensions and the same rows' and columns' names. Values in 'mat_topo' matrix must be positive. Negative values from 'mat_w' are transformed into zeros. The function works only for undirected graphs. Note that the topology 'knn' works best when 'mat_topo' contains distance values from a continuous value range, thereby avoiding equal distances between a node and the others. are more than k nodes located at distances in the k-th smallest distances If dist objects are specified, it is assumed that colnames and row.names of mat_w and mat_topo refer to the same populations/locations.
Value
A graph object of class igraph
Author(s)
P. Savary
References
Gabriel KR, Sokal RR (1969). “A new statistical approach to geographic variation analysis.” Systematic zoology, 18(3), 259–278.
Examples
mat_w <- mat_gen_dist(x = data_ex_genind, dist = 'DPS')
suppressWarnings(mat_topo <- mat_geo_dist(pts_pop_ex,
ID = "ID",
x = "x",
y = "y"))
mat_topo <- mat_topo[row.names(mat_w), colnames(mat_w)]
graph <- gen_graph_topo(mat_w, mat_topo, topo = "mst")