gen_graph_thr: Create a graph of genetic differentiation using a link weight...

View source: R/gen_graph_thr.R

gen_graph_thrR Documentation

Create a graph of genetic differentiation using a link weight threshold

Description

The function allows to construct a genetic graph whose links' weights are larger or lower than a specific threshold

Usage

gen_graph_thr(mat_w, mat_thr = NULL, thr, mode = "larger")

Arguments

mat_w

A symmetric (pairwise) matrix or a dist object whose elements will be the links' weights

mat_thr

(optional) A symmetric (pairwise) distance matrix or a dist object whose values will be used for the pruning based on the threshold value.

thr

The threshold value (logically between min(mat_thr) and max(mat_thr))(integer or numeric)

mode
  • If 'mode = 'larger” (default), all the links whose weight is larger than 'thr' are removed.

  • If 'mode = 'lower”, all the links whose weight is lower than 'thr' are removed.

Details

If 'mat_thr' is not defined, 'mat_w' is used for the pruning. Matrices 'mat_w' and 'mat_thr' must have the same dimensions and the same rows' and columns' names. Values in 'mat_thr' matrix must be positive. Negative values from 'mat_w' are transformed into zeros. The function works only for undirected graphs. If dist objects are specified, it is assumed that colnames and row.names of mat_w and mat_thr refer to the same populations/locations.

Value

A graph object of class igraph

Author(s)

P. Savary

Examples

mat_w <- mat_gen_dist(x = data_ex_genind, dist = 'DPS')
suppressWarnings(mat_thr <- mat_geo_dist(pts_pop_ex,
                 ID = "ID",
                 x = "x",
                y = "y"))
mat_thr <- mat_thr[row.names(mat_w), colnames(mat_w)]
graph <- gen_graph_thr(mat_w, mat_thr, thr = 6000, mode = "larger")

graph4lg documentation built on Feb. 16, 2023, 5:43 p.m.