gl.plot.popcluster: Plots PopCluster analysis results (Admixture Model)

View source: R/gl.plot.popcluster.r

gl.plot.popclusterR Documentation

Plots PopCluster analysis results (Admixture Model)

Description

This function takes a Q matrix (output from gl.run.popcluster) and plots the typical structure bar plot that visualize the Q matrix of a structure run.

Usage

gl.plot.popcluster(
  pop_cluster_result,
  border_ind = 0.25,
  plot.K,
  plot_theme = NULL,
  color_clusters = NULL,
  ind_name = T,
  plot.out = TRUE,
  plot.file = NULL,
  plot.dir = NULL,
  verbose = 2
)

Arguments

pop_cluster_result

run object from gl.run.popcluster [required].

border_ind

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

plot.K

The number for K of the q matrix that should be plotted. Needs to be within you simulated range of K's in your PopCluster run object. [required]

plot_theme

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

color_clusters

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

ind_name

Whether to plot individual names [default TRUE].

plot.out

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

plot.file

Name for the RDS binary file to save (base name only, exclude extension) [default NULL]

plot.dir

Directory in which to save files [default = working directory]

verbose

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

Details

The function outputs a barplot and Q matrix which is the typical output of PopCluster. Plots and table are saved to the working directory specified in plot.dir if plot.file is set.

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

The Q matrices can be input to other R packages for plotting ancestry proportion, e.g. FSTruct https://github.com/MaikeMorrison/FSTruct

Value

Q-matrix and structure plot

Author(s)

Ching Ching Lau (Post to https://groups.google.com/d/forum/dartr)

References

  • Wang, J. (2022). Fast and accurate population admixture inference from genotype data from a few microsatellites to millions of SNPs. Heredity, 129(2), 79-92.

See Also

gl.run.popcluster, gl.plot.popcluster

Examples

# examples need popcluster to be installed on the system (see above)
## Not run: 
m <- gl.run.popcluster(x=bandicoot.gl, popcluster.path="/User/PopCluster/Bin/",
output.path="/User/Documents/Output/",
minK=1, maxK=3, 
rep=10, PopData=1, location=1)
Q <- gl.plot.popcluster(pop_cluster_result=m, plot.K = 3, ind_name=T)
gl.map.popcluster(x = bandicoot.gl, qmat = Q)
# move population 4 (out of 5) 0.5 degrees to the right and populations 1
# 0.3 degree to the north of the map.
mp <- data.frame(lon=c(0,0,0,0.5,0), lat=c(-0.3,0,0,0,0))
gl.map.popcluster(bandicoot.gl, qmat=Q, movepops=mp)
## End(Not run)

dartR.popgen documentation built on March 16, 2026, 9:07 a.m.