scatter_dist {graph4lg} | R Documentation |
Plot scatterplots of genetic distance vs landscape distance
Description
The function enables to plot scatterplots to visualize the relationship between genetic distance (or differentiation) and landscape distance (Euclidean distance, cost-distance, etc.)between populations or sample sites.
Usage
scatter_dist(
mat_gd,
mat_ld,
method = "loess",
thr_gd = NULL,
thr_ld = NULL,
se = TRUE,
smooth_col = "black",
pts_col = "#999999"
)
Arguments
mat_gd |
A symmetric |
mat_ld |
A symmetric |
method |
A character string indicating the smoothing method used to fit a line on the scatterplot. Possible values are the same as with function 'geom_smooth()' from ggplot2 : 'lm', 'glm', 'gam', 'loess' (default). |
thr_gd |
(optional) A numeric or integer value used to remove values
from the data before to plot. All genetic distances values above
|
thr_ld |
(optional) A numeric or integer value used to remove values
from the data before to plot. All landscape distances values above
|
se |
Logical (optional, default = TRUE) indicating whether the confidence interval around the smooth line is displayed. |
smooth_col |
(optional) A character string indicating the color used to plot the smoothing line (default: "blue"). It must be a hexadecimal color code or a color used by default in R. |
pts_col |
(optional) Character string indicating the color used to plot the points (default: "#999999"). It must be a hexadecimal color code or a color used by default in R. |
Details
IDs in mat_gd
and mat_ld
must be the same and refer
to the same sampling sites or populations, and both matrices must be ordered
in the same way.
Matrix of genetic distance mat_gd
can be computed using
mat_gen_dist
.
Matrix of landscape distance mat_ld
can be computed using
mat_geo_dist
when the landscape distance needed is a
Euclidean geographical distance.
Value
A ggplot2 object to plot
Author(s)
P. Savary
Examples
data(data_tuto)
mat_dps <- 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)))]
scatterplot_ex <- scatter_dist(mat_gd = mat_dps,
mat_ld = mat_dist)