gl.run.structure {dartR} | R Documentation |
Runs a STRUCTURE analysis using a genlight object
Description
This function takes a genlight object and runs a STRUCTURE analysis based on
functions from strataG
Usage
gl.run.structure(
x,
...,
exec = ".",
plot.out = TRUE,
plot_theme = theme_dartR(),
save2tmp = FALSE,
verbose = NULL
)
Arguments
x |
Name of the genlight object containing the SNP data [required]. |
... |
Parameters to specify the STRUCTURE run (check |
exec |
Full path and name+extension where the structure executable is
located. E.g. |
plot.out |
Create an Evanno plot once finished. Be aware k.range needs to be at least three different k steps [default TRUE]. |
plot_theme |
Theme for the plot. See details for options [default theme_dartR()]. |
save2tmp |
If TRUE, saves any ggplots and listings to the session temporary directory (tempdir) [default FALSE]. |
verbose |
Set verbosity for this function (though structure output cannot be switched off currently) [default NULL] |
Details
The function is basically a convenient wrapper around the beautiful
strataG function structureRun
(Archer et al. 2016). For a detailed
description please refer to this package (see references below).
To make use of this function you need to download STRUCTURE for you system
(non GUI version) from here
STRUCTURE.
Format note
For this function to work, make sure that individual and population names
have no spaces. To substitute spaces by underscores you could use the R
function gsub
as below.
popNames(gl) <- gsub(" ","_",popNames(gl))
indNames(gl) <- gsub(" ","_",indNames(gl))
It's also worth noting that Structure truncates individual names at 11
characters. The function will fail if the names of individuals are not unique
after truncation. To avoid this possible problem, a number sequence, as
shown in the code below, might be used instead of individual names.
indNames(gl) <- as.character(1:length(indNames(gl)))
Value
An sr object (structure.result list output). Each list entry is a
single structurerun output (there are k.range * num.k.rep number of runs).
For example the summary output of the first run can be accessed via
sr[[1]]$summary
or the q-matrix of the third run via
sr[[3]]$q.mat
. To conveniently summarise the outputs across runs
(clumpp) you need to run gl.plot.structure on the returned sr object. For
Evanno plots run gl.evanno on your sr object.
Author(s)
Bernd Gruber (Post to https://groups.google.com/d/forum/dartr)
References
Pritchard, J.K., Stephens, M., Donnelly, P. (2000) Inference of population structure using multilocus genotype data. Genetics 155, 945-959.
Archer, F. I., Adams, P. E. and Schneiders, B. B. (2016) strataG: An R package for manipulating, summarizing and analysing population genetic data. Mol Ecol Resour. doi:10.1111/1755-0998.12559
Examples
## Not run:
#bc <- bandicoot.gl[,1:100]
#sr <- gl.run.structure(bc, k.range = 2:5, num.k.rep = 3,
# exec = './structure.exe')
#ev <- gl.evanno(sr)
#ev
#qmat <- gl.plot.structure(sr, K=3)
#head(qmat)
#gl.map.structure(qmat, bc, scalex=1, scaley=0.5)
## End(Not run)