Plot STRUCTURE, TESS or MATRIX runs spatially and colour individuals by max assignment cluster.
plotRunsSpatial(datafile = NULL, coordsfile = NULL, popcol = NA,
exportplot = TRUE, imgtype = "png", height = NA, width = NA,
units = "cm", res = 200, showaxis = FALSE, pointcol = "grey10",
pointtype = "+", pointsize = 4, pointtransp = 0.9, chull = FALSE,
chulltransp = 0.02, chullsize = 0.4, chulltype = 1, ellipse = TRUE,
ellconf = 0.95, ellsize = 0.4, elltype = 1, ellpoints = 100,
legend = TRUE, legendlabels = NA, legendpos = c(1, 1),
legendjust = c(1, 1), legendsize = NA, legendtextsize = NA,
plottitle = NULL, filename = NA, setutm = FALSE, dataout = FALSE)
One STRUCTURE, TESS or MATRIX output file. Input is either a character
or a dataframe. If character, then a path pointing to location of the datafile. Can use
choose.files()
. If a dataframe, then an output from runsToDfStructure()
,
runsToDfTess()
or runsToDfMatrix
.
A character or a dataframe. If character, then a path pointing to location of the coordsfile. It must be a tab-delimited text file with x and y coordinates of the samples. The number of rows must be equal to the number of samples in datafile. The coordsfiles must have no header and 2 columns in the order: x (latitude) and then y (longitude). Coordinates must be in standard longitude latitude (LL) decimals.
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()
.
If set to FALSE, no image is exported.
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).
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.
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.
A character indicating the units of measurement for figure dimensions. "cm", "mm" or "in".
A numeric indicating the pixel resolution of the export image. Set to 200 by default.
A logical indicating if the axis text, axis ticks and plot border are plotted.
The colour character for sample points. An R colour or hexadecimal value.
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.
A numeric indicating the size of sample points. A number usually 0.4,0.8,1,3 etc.
A numeric between 0 and 1 indicating the transparency of points.
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.
A numeric between 0 and 1 indicating the transparency of the convex hull.
A numeric indicating the thickness of the convex hull border.
A numeric indicating the line type of the convex hull border. Option pch in standard R.
A logical indicating if an ellipse around the clusters. Set to F to supress ellipse.
A numeric indicating the confidence interval of the ellipse. Defaults to 0.95.
A numeric indicating the thickness of the ellipse line.
A numeric indicating the linetype for the ellipse. Option lty in standard R.
A numeric indicating the number of points on the ellipse.
A logical indicating if the legend for the colours is plotted.
A vector of labels for the legend denoting clusters. Defaults to cluster numbers.
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).
The x and y axis justification of the legend. A 2-value vector.
A numeric indicating the size of the legend in cm. Usually values like 0.5,0.7,1.2 etc. The legendsize does not control the text in the legend.
A numeric indicating the size of the text in the legend.
A character for the title of the plot. NULL by default.
A character name for the export figure. Automatically computed if NA.
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.
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.
If dataout = T
, a list of one or more ggplot
gtable output is returned for more theme
control if required.
The coordinates must always be provided as standard longitude-latitude (LL) decimal format.
# NOT RUN {
#structure file
s1 <- system.file("files/Structure239_4",package="pophelper")
cd2 <- system.file("files/coords239.txt",package="pophelper")
plotRunsSpatial(datafile=s1,coordsfile=cd2)
#set height
plotRunsSpatial(datafile=s1,coordsfile=cd2,height=12)
# }
Run the code above in your browser using DataLab