scatter_dist_g {graph4lg}R Documentation

Plot scatterplots of distances to visualize the graph pruning intensity

Description

The function enables to plot scatterplots of the relationship between two distances (often a genetic distance and a landscape distance between populations or sample sites), while highlighting the population pairs between which a link was conserved during the creation of a graph whose nodes are populations (or sample sites). It thereby allows to visualize the graph pruning intensity.

Usage

scatter_dist_g(
  mat_y,
  mat_x,
  graph,
  thr_y = NULL,
  thr_x = NULL,
  pts_col_1 = "#999999",
  pts_col_2 = "black"
)

Arguments

mat_y

A symmetric (complete) matrix or dist object with pairwise (genetic or landscape) distances between populations or sample sites. These values will be the point coordinates on the y axis. mat_y is the matrix used to weight the links of the graph x, whose nodes correspond to row and column names of mat_y.

mat_x

A symmetric (complete) matrix or dist object with pairwise (genetic or landscape) distances between populations or sample sites. These values will be the point coordinates on the x axis. mat_x and mat_y must have the same row and column names, ordered in the same way.

graph

A graph object of class igraph. Its nodes must have the same names as the row and column of mat_y and mat_x matrices. x must have weighted links. Link weights have to be values from mat_y matrix. graph must be an undirected graph.

thr_y

(optional) A numeric or integer value used to remove values from the data before to plot. All values from mat_y above thr_y are removed from the data.

thr_x

(optional) A numeric or integer value used to remove values from the data before to plot. All values from mat_x above thr_x are removed from the data.

pts_col_1

(optional) A character string indicating the color used to plot the points associated to all populations or sample sites pairs (default: "#999999"). It must be a hexadecimal color code or a color used by default in R.

pts_col_2

(optional) A character string indicating the color used to plot the points associated to populations or sample sites pairs connected on the graph (default: "black"). It must be a hexadecimal color code or a color used by default in R.

Details

IDs in mat_y and mat_x must be the same and refer to the same sampling sites or populations, and both matrices must be ordered in the same way. Matrices of genetic distance can be computed using mat_gen_dist. Matrices of landscape distance can be computed using mat_geo_dist when the landscape distance needed is a Euclidean geographical distance. This function is based upon scatter_dist function.

Value

A ggplot2 object to plot

Author(s)

P. Savary

Examples

data(data_tuto)
mat_gen <- data_tuto[[1]]
mat_dist <- suppressWarnings(mat_geo_dist(data=pts_pop_simul,
      ID = "ID",
      x = "x",
      y = "y"))
mat_dist <- mat_dist[order(as.character(row.names(mat_dist))),
                     order(as.character(colnames(mat_dist)))]
x <- gen_graph_topo(mat_w = mat_gen, mat_topo = mat_dist, topo = "gabriel")
scat <- scatter_dist_g(mat_y = mat_gen, mat_x = mat_dist,
                       graph = x)

[Package graph4lg version 1.8.0 Index]