Poppr: an R package for genetic analysis of populations with clonal or partially clonal reproduction

Many microbial, fungal, or oomcyete populations violate assumptions for population genetic analysis because these populations are clonal or partially clonal. Furthermore, few tools exist that are specifically designed for analyzing data from clonal populations, making analysis difficult and haphazard. We developed the R package poppr providing unique tools for analysis of data from admixed, clonal, and/or mixed populations. Currently, poppr can be used for dominant/codominant and haploid/diploid genetic data. Data can be imported from several formats including GenAlEx formatted text files and can be analyzed on a user-defined hierarchy that includes unlimited levels of subpopulation structure and clone censoring. New functions include calculation of Bruvo’s distance for microsatellites, batchanalysis of the index of association with several indices of genotypic diversity, and graphing including dendrograms with bootstrap support and minimum spanning networks. A manual with documentation and examples is provided. Poppr is open source and major releases are available on CRAN: http://cran.r-project.org/package=poppr. More supporting documentation and tutorials can be found under ‘resources’ at: http://grunwaldlab.cgrb.oregonstate.edu/.

View the peer-reviewed version (peerj.com/articles/281),which is the preferred citable publication unless you specifically need to cite this preprint.

Introduction
The Wright-Fisher model of populations is one of the oldest models utilized in population genetic theory.Populations in this model are characterized as having non-overlapping generations with a constant size free from any selective pressures [1][2][3].Conceptually, these populations are represented as pools of alleles that are independently assorting where random mating is approximated by randomly sampling alleles with replacement from one generation to the next.Assumptions of this model, or related models, are implicitly assumed for common population genetic analysis tools.In clonal populations, however, alleles are not independently passed on from one generation to the next, and these assumptions are violated.Classical textbooks on population genetics do not provide much guidance on how to analyze clonal or mixed clonal and sexual populations.In reality, many populations are not strictly clonal or sexual, but can range from completely sexual to completely clonal and this is commonly observed for fungal, oomycete, or microbial populations [4,5].Currently, analysis of these populations is not straightforward as we lack the sophisticated tools and methods developed for model populations that are typically either haploid or diploid [6].
Inferring population structure with many commonly used model-based clustering approaches such as the program Structure [7] is inherently problematic for clonal populations.These approaches cannot be used as clonal populations violate basic assumptions of panmixia and Hardy-Weinberg equilibrium.Thus, model free methods such as those relying on k-means clustering, dendrograms including bootstrap support for clades, or minimum spanning networks are more appropriate [8][9][10].Furthermore, analysis of mixed or clonal populations traditionally relies on calculation of diversity of genotypes observed and analysis of clone-censored versus non-censored populations [5,11,12].Clone censoring involves reduction of any population sample to a single observation for each multilocus genotype (MLG) in a population thereby approximating panmictic populations and removing the effect of genetic linkage [5].Analysis of diversity, in turn, involves calculation of the number of genotypes observed (richness), diversity, and evenness [13].Typical measures of genotypic diversity are borrowed from ecology and use either the Shannon-Wiener or Stoddart and Taylor index [13][14][15].
A critical aspect of analyzing clonal or mixed populations is testing a null hypothesis of panmixia [5].Testing of this hypothesis for potentially clonal populations typically relies on assessment of linkage disequilibrium among loci [5].This is achieved via calculation of the index of association or related indices in combination with resampling of the data to obtain a null distribution for the expectation of random mating [5,[16][17][18].These approaches have, for example, been applied to Pyrenophora teres [19] and Aphanomyces euteiches [12] and are routinely used in the analyses of clonal populations although they are not easily calculated given available software including multilocus, which is no longer supported, and LIAN, which only works for haploids [20,21].
Hierarchical sampling adds another layer of complexity to analysis of clonal populations.With microbial populations, the geographic structure of each population is not entirely clear, and it is often important to sample temporally to see if clones persist over time [12].A common approach when faced with multiple levels of sampling is to create a separate data set for each level or combination of levels and to analyze them separately.However, the number of data sets undergo a factorial increase with each hierarchical level, therefore increasing the chances of human error in data reformatting or analysis.Thus, tools are needed for analysis of population data across hierarchies or subsets of data.
Here, we introduce the R package poppr that is specifically designed for analysis of populations that are clonal, admixed and/or sexual.Poppr complements and builds on previously existing R packages including adegenet and vegan [22][23][24] while implementing tools novel to R significantly facilitating data import, population genetic analyses, and graphing of clonal or partially clonal populations.These tools include among others: analysis across hierarchies of populations, subsetting of populations, clone-censoring, Bruvo's genetic distance [25], the index of association and related statistics [17,18], and bootstrap support for trees based on Bruvo's distance.By providing a centralized suite of tools appropriate for many data types, this package represents a novel and useful resource specifically tailored for analysis of clonal populations.

Data import
Poppr allows import of data in several formats for dominant/codominant, haploid/diploid and geographic data.The R package adegenet, that defines the genind data structure that poppr utilizes, allows support for importing data natively from Structure, Genetix, Genepop, and Fstat.While these formats are very common and widely supported, these do not allow for import of geographic and/or regional data.Furthermore, adegenet will only handle diploids with this format, though manual import is possible.To aid in importing data, poppr has newly added the function read.genalex(), to read data from GenAlEx formatted text files into the genind data object of the package adegenet [22,23,26].GenAlEx is a popular add-in for Microsoft Excel that can handle data including codominant/dominant and haploid/diploid markers as well as geographic and regional data.This function further facilitates the import of haploid, geographic, and regional data.
Transferring data to new formats and manipulating data by hand, such as collapsing data into clones or subsetting data into different hierarchical levels, is tedious, creates redundancy, and can result in lost or misrepresented data.Poppr includes tools to automate such repetitive tasks.Many currently available data formats and software implementations allow analysis of only one or two levels of a population hierarchy.With poppr the user can import a single data set with an unlimited number of hierarchical levels.This is achieved by having the user combine the levels using a common delimiter (e.g."Year Country City").These combined levels are then used as the defining population factor in the input file and can easily be manipulated within R.

Data analysis
Once data is imported into R, the user can dynamically access and manipulate the population hierarchy with the function splitcombine(), subset the data set by population with popsub(), and check for cloned multilocus genotypes using mlg().For data sets that include clones, the poppr function clonecorrect() will censor exact clones with respect to any level of a population hierarchy by creating a new data set that includes only unique multilocus genotypes (MLGs) per population.A full list of functions available in poppr is provided in table 1.
Typical analyses in poppr start with summary statistics for diversity, rarefaction, evenness, MLG counts, and calculation of distance measures such as Bruvo's distance, providing a suitable stepwise mutation model appropriate for microsatellite markers [25].Poppr will define MLGs in your data set, show where they cross populations, and can produce graphs and tables of MLGs by population that can be used for further analysis with the R package vegan [24].Many of the diversity indices calculated by the vegan function diversity() are useful in analyzing the diversity of partially clonal populations.For this reason, poppr features a quick summary table (Table 2) that incorporates these indices along with the index of association, I A [17,18], and its standardized form, rd , which accounts for the number of loci sampled [20].Both measures of association can detect signatures of multilocus linkage and values significantly departing from the null model of no linkage among markers are detected via permutation analysis utilizing one of four algorithms described in table 3 [20].The user can specify the number of samples taken from the observed data set to obtain the null distribution expected for a randomly mating population.Detailed examples of these analyses can be found in the poppr manual.

Visualizations
Poppr generates bar charts of MLG counts found within each population of your data set (Fig. 1).Histograms with rug plots for I A and rd allow visual assessment of the quality of the distribution derived from resampling to see if a higher number of replications are necessary (Fig. 2).Poppr automatically produces custom minimum spanning networks for Bruvo's or other distances using Prim's algorithm, as implemented in the package igraph [27], with the functions bruvo.msn()for Bruvo's distance (Fig. 3) and poppr.msn()for any distance matrix.The combination of data structures from adegenet and igraph allow graphing that is color coded by population with vertices grouped by MLG [22,23,27].Poppr also includes visualization of dendrograms using UPGMA [28] and Neighbor-Joining [29] algorithms with bootstrap support for Bruvo's distance using the function bruvo.boot()(Fig. 4).Neither graphing of minimum spanning networks or dendrograms with bootstrap support are currently possible for populations in any other R packages.

Performance
Most of the functions in Poppr were written and optimized for performance in R and are available for inspection and/or download at https://github.com/grunwaldlab/poppr.Algorithms of ≥ O(n 2 ) complexity were written in the byte-compiled C language to optimize runtime performance.
For comparisons of I A and Bruvo's distance, we utilized the data set 'nancycats' (237 diploid individuals genotyped at nine microsatellite loci) from the adegenet package.Calculations were run independently 10 times and then averaged.Bruvo's distance was calculated on a machine with OSX 10.8.4 and a 2.9 GHz intel processor.The I A and rd calculations were performed on a machine with OSX 10.5.

PrePrints
Citation of methods implemented in poppr.
Several of the methods implemented in poppr are described elsewhere.Users should refer to the original publications for interpretations and citation.See table 4 for a full list of citations.As with any R package, users should always cite the R Core Team [30].

Results and Discussion
Poppr provides significant, convenient tools for analysis of clonal and partially clonal populations available in one environment on all major operating systems.The ability to analyze data for multiple populations across a user-defined hierarchy and clone-censoring provide novel functionality in R. Combined with R's graphing abilities, publication-ready figures are thus obtained conveniently.

New functionalities
Poppr implements several new functionalities.As of this writing, aside from poppr, there exist two programs that calculate I A : LIAN [21] and multilocus [20].LIAN can calculate I A for haploid data and is only available online or for *nix systems with a C compiler such as OSX and Linux [21].Multilocus implemented rd , a novel correction for I A , but is no longer supported [20].Multilocus will only calculate index values for one data set at a time and LIAN requires the user to structure the data set with populations in contiguous blocks to analyze multiple populations within a single file.Thus poppr provides significant improvements for calculation of linkage disequilibrium, and handles both haploid and diploid data, works on all major operating systems, and is capable of batch analysis of multiple files and multiple populations defined within a file including the possibility of clone correction and sub-setting.A comparison of the capabilities of these programs are summarized in Table 5.
To test significance for I A and rd , poppr offers four permutation algorithms.Each one will randomly shuffle data at each locus, effectively unlinking the loci.The algorithm previously utilized by mutlilocus is included.The multilocus-style algorithm shuffles genotypes, maintaining the associations between alleles at each locus [20].More appropriately, alleles are expected to assort independently in panmictic populations.Poppr thus provides three new algorithms for permutation that allow for independent allele assortment at each locus.The default algorithm permutes the alleles at each locus and the remaining two will randomly sample alleles from a multinomial distribution parametrically and non-parametrically [1].Details of these algorithms are presented in table 3.Because the index of association is calculated using a binary measure of dissimilarity, we have also made this available as a distance measure called diss.dist().This pairwise distance is based on the percent allelic differences.
Poppr also newly implements Bruvo's genetic distance that utilizes a stepwise mutation model appropriate for microsatellite data [25].While this distance is implemented in the program GenoDive [31] and the R package polysat [32], there are a few caveats with these two implementations.GenoDive is closed-source, and only implemented in OSX.Both poppr and polysat are open-source and available on all platforms, but polysat, being optimized for polyploid individuals with ambiguous allelic dosage, is inappropriate for analyzing diploids.Polysat will collapse homozygous individuals into a single allele and attempt to infer the second allelic state in comparison with heterozygous individuals.Since haploid and diploid individuals show clear allelic dosage, this procedure creates a bias misrepresenting the true distance.Not only is poppr not subject to this bias, but it also newly introduces bootstrap support for this distance as shown in Figure 4. PrePrints association in C to improve performance.The polysat package calculation of Bruvo's distance took 58.3 seconds on average whereas poppr 's calculation was over 190 times faster, averaging 0.3 seconds (Table 6).For calculation of I A and rd with 100 permutations and Nei's genotypic diversity [33], multilocus required around 9.12 minutes on average, as compared to 13.4 seconds with poppr.

Conclusions
The R package poppr provides new functions and tools specifically tailored for analysis of data from clonal or partially clonal populations.No software currently available provides this set of tools.Novel capabilities include analysis across multiple populations at multiple levels of hierarchies, clone-censoring, and subsetting.These in combination with R's command line interface and scripting capabilities makes analyses of these populations more streamlined and tractable.By implementing computationally expensive algorithms such as Bruvo's distance and I A in C, analyses of multiple populations that would normally take hours to complete can now be finished in a matter of minutes.This allowed us to expand the utility of these measures to convenient new graphing abilities such as automatically creating dendrograms with bootstrap support for Bruvo's distance and minimum spanning networks.While major releases of poppr are available on CRAN, we are continuing to develop this package to be able to efficiently handle genomesized SNP data.Development versions are available on github at https://github.com/grunwaldlab/poppr.

Table 1 .
List of functions found in poppr and short descriptions.

Table 3 .
Permutation algorithms in poppr implemented in the calculation of I A and rd p-values, iterated over all loci independently.

Table 6 .
Comparison of performance on one data set of 237 individuals over nine loci.Each time point represents an average of 10 independent runs.Calculations of I A are based on 100 permutations.