strataG

Description

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.

Installation

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)

Compilation install error

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:

  1. Confirm that you have 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
  1. Locate your Makeconf file. Check /Library/Frameworks/R.framework/Resources/etc:
<me> ~ % ls /Library/Frameworks/R.framework/Resources/etc
Makeconf	Renviron	javaconf	ldpaths		repositories
  1. Open Makeconf in a text editor and find the lines labeled #Fortran.

  2. 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
  1. Search in the same 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

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().

Citation

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

Contact


Versions

2.5.5 (devel)

2.4.905

2.1

2.0.2

1.0.6

1.0.5

1.0