Learn R Programming

pophelper (version 2.0.0)

plotQMultiline: Plot a qlist as individual-level multiline barplot

Description

Plot a qlist as individual-level barplot with multiple lines.

Usage

plotQMultiline(qlist = NULL, spl = NA, lpp = NA, clustercol = NA,
  indlab = TRUE, useindlab = FALSE, sortind = NA, na.rm = FALSE,
  barwidth = 0.9, ticks = FALSE, yaxislabs = FALSE, labsize = 5,
  labangle = 90, labvjust = 0.5, labhjust = 1, imgtype = "png",
  height = NA, width = NA, res = NA, units = NA)

Arguments

qlist

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

spl

An integer indicating samples per line. Defaults to 60.

lpp

An integer indicating lines per page. Defaults to 11.

clustercol

A character vector of colours for clusters.

indlab

A logical indicating if individual labels must be shown below the bars. To hide labels, set indlab=FALSE.

useindlab

A logical indicating if individual labels must be read from the rownames of qlist dataframes and used as labels.

sortind

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

na.rm

Default set to FALSE. NAs are not removed from data, therefore ggplot prints warning messages for NAs. If set to TRUE, NAs are removed before plotting and ggplot NA warning is suppressed.

barwidth

A numeric indicating the width of the bars. Defaults to 0.9.

ticks

A logical indicating if ticks on axis should be displayed or not.

yaxislabs

A logical indicating if y-axis labels should be displayed or not.

labsize

A numeric denoting size of the labels. Defaults to 5.

labangle

A numeric denoting the angle of the labels. Defaults to 90.

labvjust

A numeric denoting vertical justification of the labels. Defaults to 0.5.

labhjust

A numeric denoting the horizontal justification of the labels. Defaults to 1.

imgtype

A character denoting figure output format. Options are 'png', 'jpeg' or 'pdf'. If pdf, height and width must be in inches and res argument is ignored.

height

A numeric denoting height of the full figure. If NA, height is set to 29.7cm (A4 height).

width

A numeric denoting width of the full figure. If NA, width is set to 21cm (A4 width).

res

A numeric denoting resolution of the figure. Default is 300.

units

A character denoting the units of dimension of the figure. Default is "cm". Other options can be "in", "mm" or "px".

Details

Figures are always created to A4 size. Any plotted row will span the width of the figure. Note that this function is slow and may take several minutes when plotting mutiple runs.

See the vignette for more details.

Examples

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

# basic
plotQMultiline(slist[1])

# multiple files
plotQMultiline(slist[1:3])

# adjust samples per line and lines per page
plotQMultiline(slist[1],spl=75,lpp=10)

# sort individuals
plotQMultiline(slist[1],sortind="all")
plotQMultiline(slist[1],sortind="Cluster1")

# include labels from file
inds <- read.delim(system.file("files/structureindlabels.txt",package="pophelper"),header=FALSE,stringsAsFactors=FALSE)
rownames(slist[[1]]) <- inds$V1
plotQMultiline(slist[1],useindlab=T)

# change cluster colours
plotQMultiline(slist[1],clustercol=c("steelblue","coral"))

# change bar width and height
plotQMultiline(slist[1],barwidth=1,spl=149,labsize=3,height=5)

# }

Run the code above in your browser using DataLab