gl.map.interactive: Creates an interactive map (based on latlon) from a genlight...

View source: R/gl.map.interactive.r

gl.map.interactiveR Documentation

Creates an interactive map (based on latlon) from a genlight object

Description

Plots the individuals of a genlight object on an interactive leaflet map, using the coordinates stored in x@other$latlon, with optional population labels and optional links between populations or individuals drawn from a distance matrix.

Usage

gl.map.interactive(
  x,
  matrix = NULL,
  standard = TRUE,
  symmetric = TRUE,
  pop.labels = TRUE,
  pop.labels.cex = 12,
  ind.circles = TRUE,
  ind.circle.cols = rainbow,
  ind.circle.cex = 10,
  ind.circle.transparency = 0.8,
  palette.links = NULL,
  legend.title = NULL,
  provider = "Esri.NatGeoWorldMap",
  scale.bar = TRUE,
  raster.image = NULL,
  raster.opacity = 0.5,
  raster.colors = (scales::viridis_pal(option = "D"))(255),
  verbose = NULL
)

Arguments

x

A genlight object (including coordinates within the latlon slot) [required].

matrix

A distance matrix between populations or individuals, either a square matrix or a dist object such as returned by gl.dist.pop or gl.dist.ind. The matrix is visualised as links between individuals/populations. If the matrix has row and column names matching the population or individual names they are used to align it to the object; otherwise rows and columns are assumed to follow the order of the populations/individuals in the object. If matrix is asymmetric two lines with arrows are plotted [default NULL].

standard

If a matrix is provided, values are standardised to be between 1 and 10 if set to TRUE, otherwise taken as given. Symmetric links use the value for line colour and width; asymmetric links use it for arrow thickness [default TRUE].

symmetric

If a symmetric matrix is provided only one line is drawn based on the lower triangle of the matrix. If set to false arrows indicating the direction are used instead [default TRUE].

pop.labels

Population labels at the center of the individuals of populations [default TRUE].

pop.labels.cex

Size of population labels [default 12].

ind.circles

Should individuals be plotted as circles [default TRUE].

ind.circle.cols

Colors of circles. A color palette or a vector with as many colors as there are populations in the dataset [default rainbow].

ind.circle.cex

Size of circles in pixels [default 10].

ind.circle.transparency

Transparency of circles between 0=invisible and 1=no transparency [default 0.8].

palette.links

Color palette for the symmetric links in case a matrix is provided. Ignored when symmetric = FALSE, where arrow colours encode the direction of the larger value [default NULL].

legend.title

Legend's title for the symmetric links in case a matrix is provided [default NULL].

provider

Passed to leaflet [default "Esri.NatGeoWorldMap"].

scale.bar

Whether to add a scale bar [default TRUE].

raster.image

Path to a georeferenced raster image to plot [default NULL].

raster.opacity

The opacity of the raster, expressed from 0 to 1 [default 0.5].

raster.colors

The color palette to use to color the raster values [default scales::viridis_pal(option = "D")(255)].

verbose

Verbosity: 0, silent or fatal errors; 1, begin and end; 2, brief progress messages; 3, progress and results summary; 5, full report [default 2, unless specified using gl.set.verbosity].

Details

A wrapper around the leaflet package. For possible background maps check as specified via the provider: http://leaflet-extras.github.io/leaflet-providers/preview/index.html

The palette.links argument can be any of the following: A character vector of RGB or named colors. Examples: palette(), c("#000000", "#0000FF", "#FFFFFF"), topo.colors(10)

The name of an RColorBrewer palette, e.g. "BuPu" or "Greens".

The full name of a viridis palette: "viridis", "magma", "inferno", or "plasma".

A function that receives a single value between 0 and 1 and returns a color. Examples: colorRamp(c("#000000", "#FFFFFF"), interpolate = "spline").

Symmetric links are drawn only for pairs whose value is above 0 and not missing; a pair with a missing value in an asymmetric matrix is skipped in that direction and drawn in grey in the other.

Value

A leaflet map (htmlwidget), displayed when printed.

Author(s)

Author(s): Bernd Gruber. Custodian: Bernd Gruber – Post to https://groups.google.com/d/forum/dartr

See Also

Other graphics: gl.colors(), gl.plot.heatmap(), gl.plot.snp.density(), gl.select.colors(), gl.select.shapes(), gl.smearplot(), gl.tree.nj()

Examples

require("dartR.data")
if (isTRUE(getOption("dartR_fbm"))) bandicoot.gl <- gl.gen2fbm(bandicoot.gl)
gl.map.interactive(bandicoot.gl)
cols <- c("red","blue","yellow")
if (isTRUE(getOption("dartR_fbm"))) platypus.gl <- gl.gen2fbm(platypus.gl)
gl.map.interactive(platypus.gl, ind.circle.cols=cols, ind.circle.cex=10, 
ind.circle.transparency=0.5)


dartR.base documentation built on Nov. 18, 2026, 9:06 a.m.