strataG is a toolkit for haploid sequence and multilocus genetic data summaries, and analyses of population structure. One can select select specific individuals, loci, or strata using standard R '[' indexing methods. . The package contains functions for summarizing haploid and diploid loci (e.g., allelic richness, heterozygosity, haplotypic diversity, etc.), and haploid sequences by locus and by strata as well as functions for computing by-site base frequencies and identifying variable and fixed sites among strata. There are both overall and pairwise standard tests of population structure like PHIst, Fst, Gst, and Jost's D. If individuals are stratified according to multiple schemes, these stratifications can be changed with the stratify() function and summaries or tests can be re-run on the new object. The package also includes wrappers for several external programs like fastsimcoal2, STRUCTURE, and mafft. There are also multiple conversion functions for data objects for other population packages such as adegenet, pegas, and phangorn.
To install the latest version from GitHub:
# make sure you have devtools installed
if (!require('devtools')) install.packages('devtools')
# install strataG latest version
devtools::install_github('ericarcher/strataG', build_vignettes = TRUE)
When installing on a Mac or LINUX system, you may get errors when installing during the compilation phase that look like:
─ installing *source* package ‘strataG’ ...
** using staged installation
** libs
...
ld: warning: search path '/opt/gfortran/lib/gcc/aarch64-apple-darwin20.0/12.2.0' not found
ld: warning: search path '/opt/gfortran/lib' not found
ld: library 'gfortran' not found
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [strataG.so] Error 1
ERROR: compilation failed for package ‘strataG’
─ removing ‘/private/var/folders/rx/z5h877kx2rx_85q95ct3fdfr0000gn/T/RtmpgBBQQU/Rinstfc0912a21e41/strataG’
-----------------------------------
ERROR: package installation failed
Error: Failed to install 'strataG' from GitHub:
! System command 'R' failed
If you see this, follow these steps to update the compilation-related paths in your Makeconf file:
gfortran and gcc installed. Open Terminal and type<me> ~ % which gfortran
/usr/local/bin/gfortran
<me> ~ % which gcc
/usr/bin/gcc
If you see "gfortran not found", then you need to install it.
First, if you are on a Mac, make sure you have Xcode Command Line Tools installed:
xcode-select --install
If which gfortran still returns gfortran not found and you have homebrew then try:
brew install gcc
Makeconf file. Check /Library/Frameworks/R.framework/Resources/etc:<me> ~ % ls /Library/Frameworks/R.framework/Resources/etc
Makeconf Renviron javaconf ldpaths repositories
Open Makeconf in a text editor and find the lines labeled #Fortran.
Update the FC and F77 paths to match the location given in which gfortran:
FC = /usr/local/gfortran/bin/gfortran -arch arm64
F77 = /usr/local/gfortran/bin/gfortran
gfortran directory for gcc, perhaps in lib.
Update FLIBS to match the paths for the libraries as below:FLIBS = -L/usr/local/gfortran/lib/gcc/aarch64-apple-darwin23/14.1.0 -L/usr/local/gfortran/lib -lgfortran -lemutls_w -lquadmath
For more help, also check out this thread on Stack Overflow.
Vignettes are available on several topics:
To see the list of all available vignettes:
browseVignettes("strataG")
To open a specific vignette:
vignette("gtypes", "strataG")
There is also a tutorial detailing running fastsimcoal2 through strataG
available through the function fscTutorial().
The paper can be obtained here, and is cited as (preferred):
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
If desired, the current release version of the package can be cited as:
Archer, F. 2025. strataG: An R package for manipulating, summarizing and analysing population genetic data. R package version 1.0.6. Zenodo. http://doi.org/10.5281/zenodo.60416
heterozygosity, summarizeLoci(), and summarizeInds()) where the number of genotypes
missing data were not being taken into account. This would lead to an underestimate
in heterozygosity that was directly proportional to the amount of missing data.zygosity()
diagnosability()
microhaplot2rubias()
qual2prob()
rfPermute and rmetasim packages SuggestedreadGenData() not recognizing NAs.fs2gtypes() not formatting multi-block DNA sequence data as gtypes properlygtypesRF(), sequenceRF(), and gtypes2rfDF().alleleFreqFormat, as.array.gtypes
gtypes object, making it no longer compatible with previous versions
arlequinRead() so that it will read and parse all .arp files. Added arp2gtypes() to create gtypes object from parsed .arp files.dupGenotypes().strataGUI().na.rm = TRUE to calculation of mean locus summaries by strata in summary.gtypes. This avoids NaNs when there is a locus with genotypes missing for all samples.x to a data.frame in df2gtypes in case it is a data.table or tibble.gtypes object by replacing the @loci data.frame slot with a @data data.table slot. The data.table has a id character column, a strata character column, and every column afterwards represents one locus. The @strata slot has been removed.loci accessor has been removed.as.array which returns a 3-dimensional array with dimensions of [id, locus, allele].gtypes objects no longer shows a by-locus summary. The display was getting too slow for data sets with a large number of loci.summary function now includes by-sample results.maf to return minimum allele frequency for each locus.ldNe to calculate Ne.expandHaplotypes to expand the haplotypes in a gtypes object to one sequence per individual.read.arlequin back. Fixed missing function error with write.arlequin.summarizeSamples
evanno from base graphics to ggplot2labelHaplotypes to assign haplotypes if possible alternative site combinations match a present haplotypestrataGUI) for creating gtypes objects, QA/QC, and population structure analysestype argument to structurePlot to select between area and bar chartshaplotypeLikelihoods to sequenceLikelihoods
neiDa now creates haplotypes before calculating metricwritePhase that was creating improper input files for PHASE