Poppr: an R package for genetic analysis of populations with clonal, partially clonal, and/or sexual reproduction

Many microbial, fungal, or oomcyete populations violate assumptions for population genetic analysis because these populations are clonal, admixed, partially clonal, and/or sexual. 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, mixed, and/or sexual 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, batch-analysis of the index of association with several indices of genotypic diversity, and graphing including dendrograms with bootstrap support and minimum spanning networks. While functions for genotypic diversity and clone censoring are specific for clonal populations, several functions found in poppr are also valuable to analysis of any populations. 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/.


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 (Weir, 1996;Hartl & Clark, 1997;Nielsen & Slatkin, 2013). 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 (Anderson & Kohn, 1995;Milgroom, 1996). 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 (Grünwald & Goss, 2011).
Inferring population structure with many commonly used model-based clustering approaches such as the program S (Pritchard, Stephens & Donnelly, 2000) 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 (Goss et al., 2009;Cooke et al., 2012;Mascheretti et al., 2008). 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 (McDonald, 1997;Milgroom, 1996;Grünwald & Hoheisel, 2006). 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 (Milgroom, 1996). Analysis of diversity, in turn, involves calculation of the number of genotypes observed (richness), diversity, and evenness (Grünwald et al., 2003). Typical measures of genotypic diversity are borrowed from ecology and use either the Shannon-Wiener or Stoddart and Taylor index (Stoddart & Taylor, 1988;Shannon, 1948;Grünwald et al., 2003).
A critical aspect of analyzing clonal or mixed populations is testing a null hypothesis of panmixia (Milgroom, 1996). Testing of this hypothesis for potentially clonal populations typically relies on assessment of linkage disequilibrium among loci (Milgroom, 1996). 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 (Burt et al., 1996;Brown, Feldman & Nevo, 1980;Smith et al., 1993;Milgroom, 1996). These approaches have, for example, been applied to Pyrenophora teres (Peever & Milgroom, 1994) and Aphanomyces euteiches (Grünwald & Hoheisel, 2006) and are routinely used in the analyses of clonal populations although they are not easily calculated given available software including , which is no longer supported, and LIAN, which only works for haploids (Agapow & Burt, 2001;Haubold & Hudson, 2000).
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 (Grünwald & Hoheisel, 2006). 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 (Jombart, 2008;Jombart & Ahmed, 2011;Oksanen et al., 2013) while implementing tools novel to R significantly facilitating data import, population genetic analyses, and graphing of populations. These tools include among others: analysis across hierarchies of populations, subsetting of populations, clone-censoring, Bruvo's genetic distance (Bruvo et al., 2004), the index of association and related statistics (Brown, Feldman & Nevo, 1980;Smith et al., 1993), 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 that is flexible enough for use in analysis of any population.

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 S, G, G, and F. 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 (Jombart, 2008;Jombart & Ahmed, 2011;Peakall & Smouse, 2006). GenAlEx is a popular add-in for M E 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 clones with respect to any level of a population hierarchy. In the case of missing data we use the commonly implemented, most parsimonious approach of treating missing states as novel alleles. This inherently makes analysis sensitive to missing data and genotyping error, but the user has tools available such as missingno() to filter out missing data at a per-individual or per-locus level. The user can also decide how uninformative loci (e.g., alleles occurring at minor frequencies; monomorphic loci; fixed heterozygous loci) are treated using the function informloci(). Thus, the user can specify a frequency for removal of uninformative loci. The user is encouraged to conduct analysis with and without missing data/uninformative loci to assess sensitivity to these issues when making inferences. 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 (Bruvo et al., 2004). 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 (Oksanen et al., 2013). 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 (Brown, Feldman & Nevo, 1980;Smith et al., 1993), and its standardized form,r d , which accounts for the number of loci sampled (Agapow & Burt, 2001). 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 (Agapow & Burt, 2001). 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 andr d 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 (Csardi & Nepusz, 2006), 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 (Jombart, 2008;Jombart & Ahmed, 2011;Csardi & Nepusz, 2006). The user can further customize the appearance of the graphs directly within R by utilizing igraph's layout() and plot() functions. Poppr also includes visualization   Grünwald et al. (2003).   (Jombart, 2008).
of dendrograms using UPGMA (Schliep, 2011) andNeighbor-Joining (Paradis, Claude &Strimmer, 2004) 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  Table 1. Results are shown for the sexual population 5 of the nancycats data set (Jombart, 2008) (A) and for the clonal Athena population of the Aeut data set (Grünwald et al., 2003) (B).

Figure 3 Minimum spanning network.
Example minimum spanning network using Bruvo's distance on a simulated partially clonal data set with 50 individuals genotyped over 10 microsatellite loci produced with the software SimuPOP v.1.0.8 (Peng & Amos, 2008). Each node represents a unique multilocus genotype. Node shading (colors) represent population membership, while edge widths and shading represent relatedness. Edge length is arbitrary. Figure 4 Dendrogram based on genetic distance. UPGMA tree produced from Bruvo's distance with 1000 bootstrap replicates (node values greater than 50% are shown). Data from population 9 of the nancycats data set (Jombart, 2008). calculated on a machine with OSX 10.8.4 and a 2.9 GHz intel processor. The I A andr d calculations were performed on a machine with OSX 10.5.8 and a 2.4 GHz intel processor due to the inability of the software  to work on any later version of OSX.

Example data sets
Along with example data sets preloaded into the adegenet package, poppr offers two data sets of clonal populations. The data set Aeut is comprised of 187 isolates of Table 4 Citation of methods and indices implemented in poppr.

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

RESULTS AND DISCUSSION
Poppr provides significant, convenient tools for analysis of clonal, partially clonal, and sexual 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 (Haubold & Hudson, 2000) and  (Agapow & Burt, 2001). 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 (Haubold & Hudson, 2000). M implementedr d , a novel correction for I A , but is no longer  (Agapow & Burt, 2001). M 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 andr d , poppr offers four permutation algorithms. Each one will randomly shuffle data at each locus, effectively unlinking the loci. The algorithm previously utilized by  is included. The -style algorithm shuffles genotypes, maintaining the associations between alleles at each locus (Agapow & Burt, 2001). 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 (Weir, 1996). 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 (Bruvo et al., 2004). While this distance is implemented in the program GD (Meirmans & Van Tienderen, 2004) and the R package polysat (Clark & Jasieniuk, 2011), there are a few caveats with these two implementations. GD 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 Fig. 4.

Performance
Poppr reduces the amount of intermediate files and repetitive tasks needed for basic population genetic analyses and implements computationally intensive functions, such  (Nei, 1978),  required around 9.12 min on average, as compared to 13.4 s 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. In addition to improved performance, many of the new tools in poppr may also be applied to non-clonal populations. While major releases of poppr are available on CRAN, we are continuing to develop this package to be able to efficiently handle genome-sized SNP data. Development versions are available on GitHub at https://github.com/grunwaldlab/poppr.