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 |
cluster_names |
character vector of names the same length as the number of clusters.
If |
boundary |
named numeric vector defining the map bounding. e.g. |
crs |
coordinate reference system. Default is the WGS 84 - World Geodetic System 1984 (EPSG: |
basemap |
SpatRaster or sf object to use as the basemap. A SpatRaster object can be created from a file
using the |
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 ( |
arrow |
show arrow ( |
arrow_size |
numeric value of zero or greater. |
arrow_position |
string defining the position of the arrow ( |
scalebar |
show scalebar ( |
scalebar_size |
numeric value of zero or greater. |
scalebar_position |
string defining the position of the scalebar ( |
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
)