mapmixture {mapmixture}R Documentation

Plot Pie Charts on Map

Description

Plot admixture proportions as pie charts on a projected map. In data sets where there are multiple individuals per site, the function will calculate the mean average admixture proportion for each site.

Usage

mapmixture(
  admixture_df,
  coords_df,
  cluster_cols = NULL,
  cluster_names = NULL,
  boundary = NULL,
  crs = 4326,
  basemap = NULL,
  pie_size = 1,
  pie_border = 0.2,
  pie_border_col = "black",
  pie_opacity = 1,
  land_colour = "#d9d9d9",
  sea_colour = "#deebf7",
  expand = FALSE,
  arrow = TRUE,
  arrow_size = 1,
  arrow_position = "tl",
  scalebar = TRUE,
  scalebar_size = 1,
  scalebar_position = "tl",
  plot_title = "",
  plot_title_size = 12,
  axis_title_size = 10,
  axis_text_size = 8
)

Arguments

admixture_df

data.frame or tibble containing admixture data (see examples).

coords_df

data.frame or tibble containing coordinates data (see examples).

cluster_cols

character vector of colours the same length as the number of clusters. If NULL, a blue-green palette is used.

cluster_names

character vector of names the same length as the number of clusters. If NULL, the cluster column names are used.

boundary

named numeric vector defining the map bounding. e.g. c(xmin=-15, xmax=15, ymin=30, ymax=50). If NULL, a default bounding box is calculated.

crs

coordinate reference system. Default is the WGS 84 - World Geodetic System 1984 (EPSG:4326). See ?sf::st_crs for details.

basemap

SpatRaster or sf object to use as the basemap. A SpatRaster object can be created from a file using the terra::rast() function. A sf object can be created from a file using the sf::st_read() function. If NULL, world country boundaries are used.

pie_size

numeric value of zero or greater.

pie_border

numeric value of zero or greater.

pie_border_col

string denoting colour of pie border.

pie_opacity

numeric value of zero to one.

land_colour

string defining the colour of land.

sea_colour

string defining the colour of sea.

expand

expand axes (TRUE or FALSE).

arrow

show arrow (TRUE or FALSE). Added using the ggspatial::annotation_north_arrow() function.

arrow_size

numeric value of zero or greater.

arrow_position

string defining the position of the arrow ("tl", "tr", "bl", "br").

scalebar

show scalebar (TRUE or FALSE). Added using the ggspatial::annotation_scale() function.

scalebar_size

numeric value of zero or greater.

scalebar_position

string defining the position of the scalebar ("tl", "tr", "bl", "br").

plot_title

string defining the main title of the plot.

plot_title_size

numeric value of zero or greater.

axis_title_size

numeric value of zero or greater.

axis_text_size

numeric value of zero or greater.

Value

A ggplot object.

Examples

# Admixture Format 1
file <- system.file("extdata", "admixture1.csv", package = "mapmixture")
admixture1 <- read.csv(file)

# Admixture Format 2
file <- system.file("extdata", "admixture2.csv", package = "mapmixture")
admixture2 <- read.csv(file)

# Admixture Format 3
file <- system.file("extdata", "admixture3.csv", package = "mapmixture")
admixture3 <- read.csv(file)

# Coordinates Format
file <- system.file("extdata", "coordinates.csv", package = "mapmixture")
coordinates <- read.csv(file)

# Plot using default parameters
mapmixture(admixture1, coordinates)

# Plot using the ETRS89-extended / LAEA Europe coordinate reference system
mapmixture(admixture1, coordinates, crs = 3035)

# Plot using custom parameters
mapmixture(
  admixture_df = admixture1,
  coords_df = coordinates,
  cluster_cols = c("#f1a340","#998ec3"),
  cluster_names = c("Group 1","Group 2"),
  crs = "+proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +units=m",
  boundary = c(xmin=-15, xmax=16, ymin=40, ymax=62),
  pie_size = 1.5,
  pie_border = 0.2,
  pie_opacity = 1,
  land_colour = "#d9d9d9",
  sea_colour = "#deebf7",
  expand = FALSE,
  arrow = TRUE,
  arrow_size = 1,
  arrow_position = "tl",
  scalebar = TRUE,
  scalebar_size = 1,
  scalebar_position = "tl",
  plot_title = "Mapmixture Figure",
  plot_title_size = 15,
  axis_title_size = 12,
  axis_text_size = 10
)

[Package mapmixture version 1.1.3 Index]