Learn R Programming

pophelper (version 1.2.0)

plotRuns: Plot STRUCTURE, TESS, MATRIX or TAB files as barplots.

Description

Plot one or more STRUCTURE, TESS, MATRIX run files or TAB (aligned/combined/merged) files. The STRUCTURE, TESS and MATRIX files can be plotted individually or joined together. The TAB files will be plotted based on number of runs in each file.

Usage

plotRuns(files = NULL, imgoutput = "sep", poplab = NA, popcol = NA,
  sortind = NA, subsetpops = NA, popmean = FALSE, na.rm = TRUE,
  imgtype = "png", height = NA, width = NA, dpi = NA, units = NA,
  panelspacer = NA, flab = TRUE, flabsize = NA, flabcol = NA,
  flabbackcol = NA, labspacer = NA, labpanelheight = NA, labpos = NA,
  labsize = NA, labangle = NA, labjust = NA, labcol = NA,
  pointsize = NA, pointcol = NA, pointbgcol = NA, pointtype = NA,
  linepos = NA, linethick = NA, linecol = NA, linetype = NA,
  div = TRUE, divcol = NA, divtype = NA, divthick = NA)

Arguments

files

A character vector of one or more STRUCTURE/TESS/table files

imgoutput

A character with options: 'sep','join' or'tab'.If set to "sep", STRUCTURE/TESS/MATRIX run files are plotted as separate image files. If set to "join", STRUCTURE/TESS/MATRIX run files are joined into a single image. If set to "tab", combined/aligned/merged files are plotted into separate or joined plots based on number of tables within each file.

poplab

A character vector of population labels equal to length of individuals. Each pop name must repeat to the number of individuals present in each pop.

popcol

A vector of colours (representing populations) for colouring clusters. If NA, colours are automatically generated. K=1 to 12 are custom unique colours while K>12 are coloured by function gplots::rich.colors().

sortind

A character indicating how individuals are sorted. Default is NA. Other options are 'all' or any one cluster (eg. 'Cluster1'). See details.

subsetpops

A character or character vector with population names to subset or reorder populations. Only applicable when poplab is in use. Default is NA. See details.

popmean

A logical indicating if q-matrix must be converted from individual values to population mean values. Applicable only when poplab is in use.

na.rm

A logical indicating if NAs are removed from data, else ggplot prints warning messages for NAs. If set to TRUE, NAs are removed before plotting and ggplot NA warning is suppressed.

imgtype

A character indicating image file type. Possible options are "png","jpeg" or "pdf". For pdf, height and width are in inches and res does not apply.

height

A numeric indicating the height of individual run plot. By default, automatically generated based on number of Individuals. Ranges between 2.5cm and 4.6cm.

width

A numeric indicating the width of individual run plot. By default, automatically generated based on number of individuals. Ranges between 5cm and 30cm.

dpi

A numeric indicating the image resolution in pixels per inch (PPI). Defaults to 300.

units

A numeric indicating the units of height and width. Default set to "cm".

panelspacer

A numeric indicating the space at the bottom of one or more barplot panels.

flab

A logical indicating if strip panels on right side must be shown. Strip panels display file name and K value. Defaults to TRUE.

flabsize

A numeric indicating the size of the filename label. Defaults to 4. Applicable only if flab=T.

flabcol

A colour character indicating the colour of the filename label. Defaults to "grey10". Applicable only if flab=T.

flabbackcol

A colour character denoting the background colour of the filename label. Defaults to white. Applicable only if flab=T.

labspacer

A numeric indicating the space between the plots and the label area. Applicable only with population labels.

labpanelheight

A numeric indicating the height of the label area in cm. Default is 0.4 cm. If units are different, cm will be be converted automatically. Applicable only with population labels.

labpos

A numeric indicating the y position of the labels. Applicable only with population labels.

labsize

A numeric indicating the size of the labels.

labangle

A numeric indicating the angle/rotation of labels. 0 is horizontal while 90 is vertical.

labjust

A numeric indicating the justification of labels. Defaults to 0.5 if labangle = 0 or 1 if labangle between 20 and 135.

labcol

A colour character for the colour of labels. Defaults to "grey30".

pointsize

A numeric indicating the size of points on label marker line.

pointcol

A colour character for the colour of points on the label marker line. Defaults to "grey30".

pointbgcol

A colour character for the background of marker point for certain pointtypes.

pointtype

A character or number for the type of points on the label marker line. Defaults to |. Same as pch in standard R.

linepos

A numeric indicating the y position of the label marker line and the points.

linethick

A numeric indicating the thickness of the label marker line.

linecol

A colour character for the label marker line. Defaults to "grey30".

linetype

A numeric indicating the type of line for marker line. Same as lty in standard R. Default value is 1.

div

A logical indicating if divider lines between population clusters must be drawn. Applicable only with population labels.

divcol

A character or hexadecimal colour denoting the colour of the divider line. Default is white.

divtype

A numeric indicating the type of line for the divider line. Same as lty in standard R. Default value is 1.

divthick

A numeric indicating the thickness of the divider line. Default is 0.25

Value

Nothing is returned.

Details

It is possible to set either height or width and leave other as default. sortind This argument takes one character as input. Default NA means individuals are plotted in the same order as input. Individuals can be ordered by one cluster. For ex. sortind="Cluster1" or sortind="Cluster2". To order by all clusters as the 'Sort by Q' option in STRUCTURE software, use sortind="all". When using sortind with subsetpops, individuals are sorted within the population groups.

subsetpops This argument takes one or more characters as input. Use only populations labels used in the poplab vector. For ex. In case of two pops in order 'Pop A' and 'Pop B', use subsetpops=c("Pop B","Pop A") to change order of populations. Use subsetpops="Pop B" to subset only Pop B.

See Also

plotMultiline

Examples

Run this code
# NOT RUN {
slist <- list.files(path=system.file("files/structure",package="pophelper"),
full.names=TRUE)

#plot one separate figure
plotRuns(files=slist[1])

#plot two separate figures
plotRuns(files=slist[1:2])

#plot a joined figure with 3 plots
plotRuns(files=slist[1:2],imgoutput="join")

#sort individuals
plotRuns(files=slist[c(1,3)],sortind="all")
plotRuns(files=slist[c(1,3)],sortind="all",imgoutput="join")

pops <- read.delim(system.file("files/structurepoplabels.txt", 
package="pophelper"), header=F,stringsAsFactors=F)

#plot with labels
plotRuns(files=slist[1],poplab=pops$V1)
plotRuns(files=slist[1:2],poplab=pops$V1,imgoutput="join")

#sort within population groups
plotRuns(files=slist[1:2],poplab=pops$V1,imgoutput="join",sortind="Cluster1")

# }

Run the code above in your browser using DataLab