plotQSpatial: Plot runs spatially and colour individuals by max assignment...

Description Usage Arguments Details Value Examples

View source: R/pophelperSpatial.R

Description

Plot runs spatially and colour individuals by max assignment cluster.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
plotQSpatial(qlist = NULL, coords = NULL, clustercol = NA,
  setutm = FALSE, imgtype = "png", height = NA, width = NA,
  units = "cm", res = 200, showaxis = FALSE, coordsratio = NA,
  plotcolour = "grey30", pointcol = "grey10", pointtype = "+",
  pointsize = 4, pointalpha = 0.9, chull = FALSE, chullalpha = 0.02,
  chullsize = 0.4, chulltype = 1, ellipse = TRUE, ellconf = 0.95,
  ellsize = 0.4, elltype = 1, ellpoints = 100, legend = TRUE,
  legendlab = NA, legendpos = c(0.99, 0.99), legendjust = c(1, 1),
  legendkeysize = NA, legendtextsize = NA, plottitle = NULL,
  exportplot = TRUE, exportfilename = NA, dataout = FALSE)

Arguments

qlist

A qlist (list of dataframes) with one element. An output from readQ with one element.

coords

A dataframe. The number of rows must be equal to the number of samples in qlist. The dataframe must have 2 columns in the order: x (latitude) and then y (longitude). Coordinates must be in standard longitude latitude (LL) decimals.

clustercol

A vector of colours for the clusters. R colour names or hexadecimal values. If NA, colours are automatically generated. K 1 to 12 are custom unique colours while K>12 are coloured by function rich.color().

setutm

A logical. If TRUE, then LL coordinates are converted to UTM coordinates. The midpoint of the longitude within the dataset is used to determine the UTM zone.

imgtype

A character indicating the export format for figures. Options are "png", "jpeg" or "pdf". If pdf, height and width must be in inches and res argument is ignored (set to 300).

height

A numeric indicating the height of export figure. Default in cm unless units are changed. If imgtype is pdf, then height must be in inches.

width

A numeric indicating the the width of export figure. Default in cm unless units are changed. If imgtype is pdf, then height must be in inches.

units

A character indicating the units of measurement for figure dimensions. "cm", "mm" or "in".

res

A numeric indicating the pixel resolution of the export image. Set to 200 by default.

showaxis

A logical indicating if the axis text, axis ticks and plot border are plotted.

coordsratio

A numeric indicating ratio between x and y axes. If set to 1, then 1 unit on x axis is the same as 1 unit on y axis.

plotcolour

A character R colour or hexadecimal denoting colour for plot elements. Defaults to "grey30".

pointcol

The colour character for sample points. An R colour or hexadecimal value.

pointtype

The shape/pch of sample points. A numeric or a character. By default, "+" is used for all points. If NA, then each cluster is plotted using a different shape. If a numeric or character of length one is used, then it is used for all points. If a vector is used, then it must be equal to number clusters.

pointsize

A numeric indicating the size of sample points. A number usually 0.4,0.8,1,3 etc.

pointalpha

A numeric between 0 and 1 indicating the transparency of points.

chull

A logical indicating if the convex hull is computed for each cluster. The outer points of each cluster are connected by lines. If less than 3 points are available in a cluster, then convex hull is not computed and a warning is shown.

chullalpha

A numeric between 0 and 1 indicating the transparency of the convex hull.

chullsize

A numeric indicating the thickness of the convex hull border.

chulltype

A numeric indicating the line type of the convex hull border. Option pch in standard R.

ellipse

A logical indicating if an ellipse around the clusters. Set to F to supress ellipse.

ellconf

A numeric indicating the confidence interval of the ellipse. Defaults to 0.95.

ellsize

A numeric indicating the thickness of the ellipse line.

elltype

A numeric indicating the linetype for the ellipse. Option lty in standard R.

ellpoints

A numeric indicating the number of points on the ellipse.

legend

A logical indicating if the legend for the colours is plotted.

legendlab

A vector of labels for the legend denoting clusters. Defaults to cluster numbers.

legendpos

A character or 2-value numeric vector indicating the position of the legend. If "right","left","top" or "bottom", then, legend is plotted outside the plot area. To plot inside plot area use a 2 vale vector. If a vector like c(1,1), first value denotes x-axis from 0 to 1 and second value denotes y-axis from 0 to 1. For ex. to plot in bottom left corner, use c(0,0).

legendjust

The x and y axis justification of the legend. A 2-value vector.

legendkeysize

A numeric indicating the size of the legend in cm. Usually values like 0.5,0.7,1.2 etc.

legendtextsize

A numeric indicating the size of the text in the legend.

plottitle

A character for the title of the plot. NULL by default.

exportplot

If set to FALSE, no image is exported.

exportfilename

A character name for the export figure. Automatically computed if NA.

dataout

A logical. If set to TRUE, a list of one or more ggplot gtable elements are returned. This output can be modified using ggplot themes() for more figure control if required.

Details

The coordinates must always be provided as standard longitude-latitude (LL) decimal format.

Value

If dataout=T, a list of one or more ggplot gtable output is returned for more theme control if required.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## Not run: 
#structure file
q <- readQ(system.file("files/Structure239_4",package="pophelperSpatial"))
xy <- read.delim(system.file("files/coords239.txt",package="pophelperSpatial"),header=F)

# basic usage
plotQSpatial(qlist=q,coords=xy)
# set UTM coordinates. Better geographic distance representation over a scale such as countries.
plotQSpatial(q,xy,height=12,setutm=T)
# without ellipses
plotQSpatial(q,xy,height=12,ellipse=F)
# show axis
plotQSpatial(q,xy,height=12,showaxis=T)
# change plot element colours
plotQSpatial(q,xy,height=12,showaxis=T,plotcolour="blue")

## End(Not run)

royfrancis/pophelperSpatial documentation built on May 27, 2019, 11:47 p.m.