Create input files for DISTRUCT from a qlist.

distructExport(
  qlist = NULL,
  grplabbottom = NA,
  grplabtop = NA,
  grpmean = FALSE,
  overwritedirs = FALSE,
  printtitle = FALSE,
  clustercol = NA,
  grayscale = FALSE,
  printcolorbrewer = FALSE,
  sepline = TRUE,
  seplinewidth = 0.2,
  borderlinewidth = 1.2,
  indlinewidth = 0.2,
  fontsize = 6,
  topdist = 5,
  bottomdist = -7,
  figheight = 36,
  indwidth = 1,
  orientation = 0,
  xorigin = NA,
  yorigin = NA,
  xscale = 1,
  yscale = 1,
  toplabangle = 60,
  bottomlabangle = 60,
  echodata = TRUE,
  printdata = FALSE,
  exportpath = NULL,
  path = NULL
)

Arguments

qlist

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

grplabbottom

A character vector of group labels to be plotted below the plot. The vector must be the same length as number of individuals. See details.

grplabtop

An optional character vector of group labels to be plotted above the plot. The vector must be the same length as number of individuals. See details.

grpmean

A logical indicating if individual values are to be plotted (FALSE) or group means are to be plotted (TRUE).

overwritedirs

A logical indicating if existing directories must be overwritten (TRUE) automatically or not (FALSE).

printtitle

A logical indicating if the filename must be printed as the title on the plot.

clustercol

A character vector of colours equal to the number of clusters. Note these are not R colours. Use distructColours or refer to DISTRUCT manual for colours. With multiple files, number of colours must equal input file with highest number of clusters.

grayscale

A logical indicating if clusters must be shown in grayscale.

printcolorbrewer

A logical indicating if the colours provided in clustercol are ColorBrewer colours. See details.

sepline

A logical indicating if divider lines must be drawn between groups (TRUE).

seplinewidth

A numeric indicating width of sepline.

borderlinewidth

A numeric indicating width of border around the plot.

indlinewidth

A numeric indicating width of border around individual bars and ticks.

fontsize

A numeric indicating font size of group labels.

topdist

A numeric indicating distance of top labels from the top edge of the plot.

bottomdist

A numeric indicating distance of bottom labels from the bottom edge of the plot. Usually a negative number.

figheight

A numeric indicating height of the plot.

indwidth

A numeric indicating width of each individual bar. The width of the plot depends on this value.

orientation

An integer (0,1,2,3) indicating orientation of the plot. See details.

xorigin

A numeric indicating lower left x-coordinate of the plot. See details.

yorigin

A numeric indicating lower left y-coordinate of the plot. See details.

xscale

A numeric indicating scaling for the x direction.

yscale

A numeric indicating scaling for the y direction.

toplabangle

A numeric between 0 and 180 indicating angle of top labels.

bottomlabangle

A numeric between 0 and 180 indicating angle of bottom labels.

echodata

A logical. Not really sure what this does.

printdata

A logical indicating if head and tail of data must be shown in display on running DISTRUCT.

exportpath

A character denoting path to export output. To use current working directory, set exportpath=getwd().

path

Deprecated. Use exportpath.

Value

This function does not run DISTRUCT. It only generates the files necessary to run DISTRUCT. The DISTRUCT executable can be downloaded from here https://web.stanford.edu/group/rosenberglab/distruct.html. Please remember to cite DISTRUCT if this option is used.

The function does not return anything. The function creates directories for each input file and populates it with files necessary to run DISTRUCT. The files are individual q-matrix file (xx-indq.txt), population q-matrix file (xx-popq.txt), a cluster colour file (xx-colours.txt) and drawparams file. If group labels were defined, then (xx-poplab-bottom.txt) or (xx-poplab-top.txt) are also exported.

The DISTRUCT executable can be run in this directory to generate an xx.ps file.

Details

Orientation
0 for horizontal orientation (default)
1 for vertical orientation
2 for reverse horizontal orientation
3 for reverse vertical orientation

Origin
Default values of origin for a given orientation:
orientation, xorigin, yorigin
0,72,288
1,360,72
2,540,504
3,288,720
If plot exceeds canvas size, consider shifting xorigin to the left and/or decreasing indwidth.

Colorbrewer colours
Colorbrewer colours are not automatically generated for now. Refer to DISTRUCT manual for colour names.
Replace the colour names in xx-colours.txt output file with selected colorbrewer colours (ex: Accent_3_qual_1).

See the vignette for more details.

Examples

if (FALSE) { # read some data slist <- readQ(list.files(path=system.file("files/structure", package="pophelper"),full.names=TRUE)) grps1 <- read.delim(system.file("files/structuregrplabels.txt", package="pophelper"),header=FALSE, stringsAsFactor=FALSE) grps2 <- read.delim(system.file("files/structuregrplabels2.txt", package="pophelper"),header=FALSE, stringsAsFactor=FALSE) # plot without labels distructExport(slist[1],exportpath=getwd()) # plot with bottom group label distructExport(slist[1],grplabbottom=grps1$V1,exportpath=getwd()) # plot with top group label distructExport(slist[1],grplabtop=grps2$V1,exportpath=getwd()) # plot group mean values distructExport(slist[1],grplabbottom=grps1$V1,grpmean=TRUE,exportpath=getwd()) }