Skip to contents

This function takes a structure run object (output from and plots the typical structure bar plot that visualize the q matrix of a structure run.


  K = NULL,
  met_clumpp = "greedyLargeK",
  iter_clumpp = 100,
  clumpak = TRUE,
  plot_theme = NULL,
  colors_clusters = NULL,
  ind_name = TRUE,
  border_ind = 0.15,
  plot.out = TRUE,
  save2tmp = FALSE,
  verbose = NULL



Structure run object from [required].


The number for K of the q matrix that should be plotted. Needs to be within you simulated range of K's in your sr structure run object. If NULL, all the K's are plotted [default NULL].


The algorithm to use to infer the correct permutations. One of 'greedy' or 'greedyLargeK' or 'stephens' [default "greedyLargeK"].


The number of iterations to use if running either 'greedy' 'greedyLargeK' [default 100].


Whether use the Clumpak method (see details) [default TRUE].


Theme for the plot. See Details for options [default NULL].


A color palette for clusters (K) or a list with as many colors as there are clusters (K) [default NULL].


Whether to plot individual names [default TRUE].


The width of the border line between individuals [default 0.25].


Specify if plot is to be produced [default TRUE].


If TRUE, saves any ggplots and listings to the session temporary directory (tempdir) [default FALSE].


Verbosity: 0, silent or fatal errors; 1, begin and end; 2, progress log ; 3, progress and results summary; 5, full report [default NULL, unless specified using gl.set.verbosity]


List of Q-matrices


The function outputs a barplot which is the typical output of structure. For a Evanno plot use gl.evanno.

This function is based on the methods of CLUMPP and Clumpak as implemented in the R package starmie (

The Clumpak method identifies sets of highly similar runs among all the replicates of the same K. The method then separates the distinct groups of runs representing distinct modes in the space of possible solutions.

The CLUMPP method permutes the clusters output by independent runs of clustering programs such as structure, so that they match up as closely as possible.

This function averages the replicates within each mode identified by the Clumpak method.

Plots and table are saved to the temporal directory (tempdir) and can be accessed with the function gl.print.reports and listed with the function gl.list.reports. Note that they can be accessed only in the current R session because tempdir is cleared each time that the R session is closed.

Examples of other themes that can be used can be consulted in


  • Pritchard, J.K., Stephens, M., Donnelly, P. (2000) Inference of population structure using multilocus genotype data. Genetics 155, 945-959.

  • Kopelman, Naama M., et al. "Clumpak: a program for identifying clustering modes and packaging population structure inferences across K." Molecular ecology resources 15.5 (2015): 1179-1191.

  • Mattias Jakobsson and Noah A. Rosenberg. 2007. CLUMPP: a cluster matching and permutation program for dealing with label switching and multimodality in analysis of population structure. Bioinformatics 23(14):1801-1806. Available at clumpp

See also, gl.plot.structure


Bernd Gruber & Luis Mijangos (Post to


if (FALSE) {
#bc <-[,1:100]
#sr <-, k.range = 2:5, num.k.rep = 3, exec = './structure')
#ev <- gl.evanno(sr)
#qmat <- gl.plot.structure(sr, K=3)
#head(qmat), K=3, bc, scalex=1, scaley=0.5)