We present an open source package for performing evolutionary quantitative genetics analyses in the R environment for statistical computing. Evolutionary theory shows that evolution depends critically on the available variation in a given population. When dealing with many quantitative traits this variation is expressed in the form of a covariance matrix, particularly the additive genetic covariance matrix or sometimes the phenotypic matrix, when the genetic matrix is unavailable and there is evidence the phenotypic matrix is sufficiently similar to the genetic matrix. Given this mathematical representation of available variation, the \textbf{EvolQG} package provides functions for calculation of relevant evolutionary statistics; estimation of sampling error; corrections for this error; matrix comparison via correlations, distances and matrix decomposition; analysis of modularity patterns; and functions for testing evolutionary hypotheses on taxa diversification. Quantitative genetics has been successful in describing short term evolution, and is also useful in understanding diversification at a macroevolutionary level. The core development of modern evolutionary quantitative genetics started with the generalization of the univariate breeders equation to the multivariate response to selection equation, derived by Lande and also referred to as the Lande equation55. The Lande equation relates the evolutionary change in trait means of a given population (Δz) to the interaction between the additive genetic variation (G-matrix) of this population and the directional selection (β) acting on this population. The additive genetic variation of a population is represented by a symmetric square matrix called theG-matrix, which contains the additive genetic variance of each trait on the diagonal and the additive genetic covariance between traits on the off-diagonal elements. From the Lande equation, Δz =Gβ, we can see that different populations may present markedly different responses (Δz) to the same directional selection (β) simply because these populations have distinctG-matrices. Other evolutionary forces affecting populations are also influenced by available variation, e. g., based on theG-matrix it is possible to test if morphological differentiation of extant taxa is compatible with genetic drift or stabilizing selection  using an analysis of variance. The proportion of variance associated with among individual variation, and not within individual variation, is called the repeatability30. A repeatability of 1 means that no variation is associated with measurement error. The functionCalcRepeatability performs the calculation described inBefore estimating a34. TheEvolQG functionCalculateMatrix uses R’slm model object to calculate variance-covariance matrices adjusting for the proper degrees of freedom in a simple fixed-effects MANCOVA. More complicated methods may be used to obtainG-matrices, such as an animal model or a mixed model57, and these can be used for further analysis usingEvolQG.In the rest of this article we assume that the covariance matrix of interest has already been estimated by some procedure. This matrix can be a simple covariance of all the observed traits, or an estimated parameter from a more complicated linear model. The simplest case of a linear model approach would be using a multivariate analysis of covariance (MANCOVA) to control for differences in trait means that are not of immediate interest in the analyses . The residual pooled within-group covariance matrix can be used in subsequent analysisEvolQG also provides a simple Bayesian model for phenotypic matrix estimation using a conjugate inverse Wishart prior, implemented in the functionBayesianCalculateMatrix. The default behavior is to use a prior covariance matrix with the observed variances (from the data) on the diagonal and zeros in the off-diagonal elements. This method uses a type of regularization prior which provides a “shrinkage” posterior estimate which has some attractive properties when compared to the maximum likelihood estimate, such a lower mean squared error and a well behaved inverse59. The maximuma posteriori estimate is calculated analytically, and optionally the function also provides a sample from the posterior distribution and the median of these samples. These samples can be used in other Bayesian methods described in the next sections, or to calculate confidence intervals for any analysis using the covariance matrices.G-matrices, but accurateG-matrix estimation can be hard, requiring large sample sizes, many families and known genealogies60. One alternative we advocate for, which is usually more feasible, is to use the phenotypic covariance matrix (theP-matrix) as a proxy of the population’sG-matrix56. Conditions on where this approximation is reasonable depend on the structure of developmental and environmental effects, and testing for similarity is an empirical question that should be undertaken before using theP-matrix as a proxy for theG-matrix, ideally by direct comparison . However, due to error in estimating these matrices, their correlations will never be one, even if the actual population parameter values are identical8. Thus, matrix repeatabilities are used to correct matrix correlations by taking sampling error into account. The basic premise of all the methods is that taking repeated samples from the same population and comparing the resulting matrices would still give correlations that are lower than 1. We estimate the maximum correlation between matrices taken from the same population and correct the observed correlation by this maximum value. The corrected correlation between two observed matrices will be given by the original correlation divided by the geometric mean of their repeatabilities. If the repeatability of both matrices is one, the observed correlation does not change under the correction, and lower repeatabilities yield larger corrections. Estimating error forG- andP-matrices require different methods. The objective when estimating error is usually to create a sample of matrices that reflects our uncertainty regarding the estimated matrix. BecauseG-matrix are estimated using mixed models or animal models57 this model structure must be taken into account, and sampling strategies that work in P-matrices will severely underestimate error inG-matrices. Given these restrictions, we can generate a distribution ofG-matrices in several ways: (i) mixed model packages often provide the functionality of bootstrapping over the exchangeable units in the design  and generate error estimates using these samples; (ii) Houle & Meyer23 use an asymptotic approximation for the the parametric sampling distribution of the estimatedG-matrix to generate samples and estimate error, a method called MVN-REML available in the program WOMBAT40; (iii) in a fully Bayesian context, samples from the posterior distribution of theG-matrix can be used. These samples can then be used to calculate repeatabilities or confidence intervals for derived quantities. Using any of these sampling methods the repeatability can be estimated as the average comparison value for all pairs of sampled matrices or as the average comparison of the estimated matrix and the sampled matrices. AP-matrices things are simpler, and repeatabilities are straight forward to calculate usingEvolQG. We provide a number of methods for estimating repeatability inP-matrices, and their results can be passed on to the functions that calculate matrix correlations (sectionMatrix Comparison):When working withAlphaRep: Cheverud8 describes an analytical expression for the repeatability of a correlation matrix. This expression is asymptotically convergent, so it should be used only when sample sizes are large, at least larger than the number of traits.BootstrapRep: We may estimate the repeatability of the covariance (or correlation) structure of a given data set using a bootstrap procedure, sampling individuals with replacement from the data set and calculating a covariance (or correlation) matrix from each sample. The mean value of the correlation between the random sample matrix and the original estimated matrix is an estimate of the repeatability. This method has the advantage of not assuming any distribution on the data, but does provide inflated estimates of repeatabilities for small data sets. Even so, upwardly biased matrix repeatabilities are not so problematic, because they lead to conservative corrections of matrix correlations. However, users should be aware of this bias and should not interpret a high repeatability obtained from a small data set as indicating that the parameter is well estimated.MonteCarloRep: We can use the observed covariance matrix as the Σ parameter in a multivariate normal distribution, and produce samples from this distribution, using a fixed sample size. The covariance (or correlation) matrix for each sample is compared to the observed matrix, and the mean of these comparisons is an estimate of the repeatability34. This method has the advantage of being easy to apply to matrices coming from linear models with many fixed effects, and not requiring the original data; but can also lead to inflated repeatabilities for small samples.MonteCarloRep andBootstrapRep are based on generic functions (MonteCarloStat andBootstrapStat) which can be used for general sampling from covariance matrices using normal distributions or to generate bootstrap samples from a set of individuals, respectively. These functions can be used to generate confidence intervals forP-matrices for any of the evolutionary statistics described below, or any user defined function.BothSometimes the question we are trying to answer does not involve matrix comparisons, so other methods of assessing and correcting for error are needed.Rarefaction: Rarefaction consists of taking progressively smaller samples with replacement from the original data set, calculating some statistic on each data set and comparing this with the full data set. These comparisons gives a general idea of how the inferences would change if we had smaller sample sizes, and how robust our data set is with respect to sampling, given that an appropriately large initial sample is available. The default operation is to calculate the covariance or correlation matrices and compare them using any of the matrix comparison methods (see sectionMatrix Comparison). The genericRarefaction-Stat can also be used to generate rarefaction curves for any user defined function.ExtendMatrix: Marroiget al.37 showed that sampling error on covariance matrix estimation can have a dramatic effect on the reconstruction of net selection gradients using the multivariate response to selection equation28. One way to improve estimates is the simple procedure of "extending" the eigenvalues of the covariance matrix, where all the eigenvalues lower than a certain threshold are substituted by the smallest eigenvalue above the threshold. This substitution causes minimal changes in the distribution of phenotypes, but improves dramatically the estimates of net selection gradients. Alternatives to the extension method involve using regularized estimators for the covariance matrix, like Bayesian or shrinkage estimators59, available from packagecorpcor. See19 provide a suite of statistics that have fairly good biological interpretations for a givenG- orP-matrix. Marroiget al.38 is a comprehensive example of how these statistics may be used for interpreting morphological data.Hansen & HouleMeanMatrixStatistics calculates most of these statistics and their distributions, as shown below.MonteCarloStat andBootstrapStat can be used to generate confidence intervals for these statistics when usingP-matrices. Also, the previously available R packageevolvability5 implements some of these functions and provides confidence intervals.The functionE[·]β represents the expected value over many randomβ vectors with unit norm, < ·, · > represents the dot product between two vectors,cos is the cosine between two vectors,G is an arbitrary covariance matrix,G−1 is the inverseG,tr(G) is the trace ofG, and ॥ · ॥ the Euclidean norm of a vector.MeanMatrixStatistics calculates:•r2): Given a correlation matrix, the elements below the diagonal are squared and averaged resulting in a measure of integration, that is, overall association between traits : A measure of integration that is suitable for covariance matrices, as it takes the amount of variation into account. Notice that at least for mammals, mean squared correlations and ICV generally have high correlation, but can lead to different conclusions if the traits included in the analysis have very different variances . If σ•G, we calculate this percentage as:Percent of variation in first principal component: If•19.Evolvability : The mea•38.Flexibility : The mea•38.Respondability : Mean no•β when other directions are under stabilizing selection19.Conditional Evolvability: Measures the mean response to selection in the direction of a given•β that is independent from variation in other directions. Therefore, mean Autonomy can also be calculated as the mean ratio between Conditional Evolvability19.Autonomy: Measures the proportion of variance in the direction of a given•38. IfG, constraints are measured as:Constraints: The mean correlation between the response vector to random selection gradients and the matrix’s first principal componentIn the following,G-matrix describes how the variation in particular populations is structured, but frequently the relevant question is how similar or dissimilar two populations are with respect to this standing variation. Because no two populations are identical, different patterns of variation are the norm. Depending on the evolutionary question at hand, different methods of comparing variation may be required. One possible application of matrix comparisons is when we wish to apply the Lande equation to micro and macroevolution, because doing so requires some additional assumptions, such as a relative stability of theG-matrix over generations24. Comparing extant covariance matrices is a test of this required stability  method makes use of the Lande equation28, Δz =Gβ, where Δz represents the vector of response to selection,G theG-matrix andβ the directional selection vector, or selection gradient. In the RS method, the two matrices being compared are multiplied by a large number of normalized random selection vectors, and the resulting response vectors to the same selection vector are compared via a vector correlation (the cosine between the two vectors). The mean value of the correlation between the responses to the same selective pressure is used as a simple statistic of how often two populations respond similarly (in the same direction) to the same selective pressure:E[·]β is the expected value over random selection vectorsβ. Significance in the random skewers comparison can be determined using a null expectation of correlation between random vectors. If the observed correlation between two matrices is above the 95% percentile of the distribution of correlations between random vectors, we consider the correlation significant and infer that there is evidence the two populations behave similarly under directional selection. Other implementations of the RS method sometimes resort to other forms of calculating significance, such as generating random matrices and creating a random distribution of correlations between matrices. Generating this distribution is difficult to do because generating random matrices with the properties of biological covariance structures is hard, see theRandomMatrix function for a quick discussion on this problem. But perhaps more important than the significance test, the RS method measure the overall similarity of the responses predicted by the two matrices under directional selection, a property that is at the core of applications of quantitative genetics theory to evolutionary problems. In this sense, a significant similarity measure by Random Skewers might still be low for a given application, when small differences in the direction of response are important. The RS values range between -1 (the matrices have opposite structures) and 1 (the matrices share the same structure), and zero means the matrices have distinct structures.WhereMantelCor: Correlation between matrices can be done using a simple Pearson correlation between the corresponding elements. Significance of this comparison must take the structure into account, so it is calculated by a permutation scheme, in which a null distribution is generated by permutation of rows and columns in one of the matrices and repeating the element-by-element correlation (i.e. Mantel test). The observed correlation is significant when it is larger than the 95% quantile of the permuted distribution. This method should only be used in correlation matrices, and cannot be used on covariance matrices because the variances might be very different, leading to large differences in the scale of the covariances. This scale difference can lead to a massive inflation in the correlation between matrices. The correlation between matrices range between -1 and 1, and higher correlations indicate matrices have more similar structures, null correlations indicate the matrices have distinct correlation structures. Correlations near zero can also occur if the elements of the matrices have nonlinear relations between them, as in all Pearson correlations. Negative correlations indicate the pattern of association between traits is reversed in the two matrices.KzrCor: The Krzanowski shared space, or Krzanowski correlation, measures the degree to which the first principal components (eigenvectors) span the same subspace26, and is suitable for covariance or correlation matrices. If twon × n matrices are being compared, the firstk principal components of the other matrix using the square of the vector correlations, and the sum of the correlations is a measure of how congruent the spanned subspaces are. We can write the Krzanowski correlation in terms of the matrices’ principal components :The Krzanowski correlation values range between 0 (two subspaces are dissimilar) and 1 .PCAsimilarity: The Krzanowski correlation compares only the subspace shared by roughly the first half of the principal components, but does not consider the amount of variation each population has in these directions of the morphological space62. In order to take the variation into account, we can add the eigenvalue associated with each principal component into the calculation, effectively weighting each correlation by the variance in the associated directions. Ifth eigenvalue of matrix A, we have:k as in the Krzanowski correlation method. This method gives correlations that are very similar to the RS method, but is much faster. The PCA similarity values range between 0 (the shared subspaces have no common variation) and 1 .Note the sum spans all the principal components, not just the firstEvolQG provides efficient implementations of some of these methods.Some methods attempt to characterize how a set of matrices differ, going beyond simple correlations.SRD: The RS method can be extended to give information into which traits contribute to differences in terms of the pattern of correlated selection due to covariation between traits in two populations36. The Selection Response Decomposition does this by treating the terms of correlated response in the Lande equation as separate entities. Writing out the terms in the multivariate response to selection equation:Separating the terms in the sums of the right hand side:β on traiti. The termiiβiA represents the response to direct selection on traiti, and the terms (ijβjA)i≠j represent the response to indirect selection due to correlation with the other traits. Given two matrices,A andB, we can measure how similar they are in their pattern of correlated selection on each trait by calculating the correlation between the vectorsir for each trait for random selection vectors of unit norm. The mean SRD score for traiti is then:Each of these row vectorsAnd the standard deviation of the correlations gives the variation in SRD scores:µSRD is high andσSRD is low; if the correlated response pattern is different,µSRD is low andσSRD is high. SeeWhen the same trait in different matrices share a correlated response pattern,RSprojection: Aguirreet al.3 used a modification of the Random Skewers method to examine differences in the magnitude of variation in different directions in a set of covariance matrices. This method is most useful when a posterior sample of covariance matrices is available, as this sample allows us to identify directions in the morphospace that show relevant differences in the amount of variation between any two matrices. The functionRSprojection uses a set of posterior samples to identify the directions that represent the most significant differences in variance, and to compare the amount of variation in each matrix for each of these directions. The posterior samples of covariance matrices can be obtained using any Bayesian linear model package, such as MCMCglmm17, or, for simple cases,BayesianCalculateMatrix. This method identifies directions where there is a significant difference in the amount of variation, so it is most useful when the matrices being compared have similar scales, since matrices with identical structure might have different amounts of variation in all directions simply because the total amount of variation is larger in one of the matrices.EigenTensorDecomposition: Hineet al.21 proposes using covariance tensors for characterizing covariance matrix variation, based on Basser & Pajevic4. Covariance tensors can be further decomposed into orthogonal eigentensors and eigenvalues; each covariance matrix in the sample can thus be represented as a combination of such eigentensors, in a manner analogous to Principal Component Analysis. Considering the non-Euclidean (Riemannian) nature of the space of symmetric positive-definite matrices  and mapping such observations into an actual Euclidean space using the functionatrices , the impM refers to the estimated geometric mean matrix andLog refers to the matrix logarithm operator. Only then a covariance tensor can be estimated, considering that the estimation of orthogonal eigentensors assumes that observations are contained within an Euclidean space, equipped with definitions for both angle and distance. The functionEigenTensorDecomposition implements these steps; furthermore, given an eigentensor decomposition estimated using this function, it is possible to project other covariance matrices of the same size as the original sample onto the obtained eigentensors (ProjectMatrix), and also reconstruct covariance matrices based on their scores over eigentensors (RevertMatrix), which may be useful for observing the direction associated with each eigentensor as actual covariance matrices. This function uses the inverse operation toExp refers to the matrix exponential operator. This operation maps the matrixX back onto the non-Euclidean space of symmetric positive-definite matrices. If a posterior sample of covariances matrices is available, this function can be used to implement the hypothesis-testing method described in Aguirreet al.3 using covariance tensors, but this test also requires a null distribution of matrices that has to be tailored to the data at hand. Also, since the covariance tensor is calculated using the covariation between elements in the covariance matrix, these methods require two levels of replication in the data: individuals within populations for the calculation of the covariance matrices, and several populations for the calculation of the covariance tensor. This requirement should be kept in mind when interpreting the results, as small samples at either level can lead to poorly estimated parameters and misleading results.whereMatrixDistance.Another approach to estimate the similarity or dissimilarity between matrices is to calculate the distance between a pair of matrices. Matrices distances are different from correlations in that correlations are limited to , while distances must only be positive. Also, smaller values of distances mean more similarity. Two distances are in use in the current evolutionary literature, and are implemented in the functionet al.48 proposed a distance based on probability distributions, where two covariance matrices would have a distance proportional to how distinguishable they are. This distance is natural if we think of covariance matrices as describing the probability distribution of phenotypes or additive values in the population. The higher the probability of a random draw coming from the distribution defined by one of the matrices being misclassified as coming from the distribution defined by the other, the lower the distance. For two probability distributionsf andg, the probability of misclassifying a draw fromf as coming fromg is:n is the dimensionality of the space in which the distributions are defined. If the distributions are indistinguishable,q = 1/2, if they are completely distinguishableq = 0. We can then define the distance as:Overlap distance: Ovaskainenq is symmetrical,d is also symmetrical, and the square root guaranties thatd satisfies the triangle inequality48. Calculation is straight forward and can be done with a simple sampling Monte Carlo scheme, seeSince42 use a Riemannian metric in the space of positive definite matrices (either covariance or correlation matrices), based on exponential mapping43 to quantify transition in the ontogenetic trajectory of phenotypic covariance matrices. This metric is based on the eigenvalues of the product of one matrix to the inverse of the other. Ifiλ are the eigenvalues ofA−1B (orAB−1), we have:Riemann distance: Mitteroecker and BooksteinThis distance has the advantage of being invariable under changes in the base used to represent the matrices. SeePhyloW: Given a set of covariance matrices for the terminal taxa in a phylogeny, we can estimate the covariance matrix for internal nodes by taking means over sister taxa, weighted by sample size. The mean matrix at the root node is the within-group covariance matrix in a MANCOVA with the terminal clades as the fixed effects.PhyloW does this estimation by taking a tree and a set of measurements (covariance matrices) and returns means weighted by sample size for internal nodes. The implementation is generic, so this function can also be used to calculate weighted means for any numerical measurement with an addition operation implemented in R.For G-matrices it might not be clear what the appropriate weight to use in each node, as the linear mixed models used in G-matrix estimation do not assign a clear degree of freedom for the covariance matrix. Number of families could plausibly be a good weighing factor, but one should proceed with caution, or use a more direct approach of including the phylogeny in G-matrix estimation.While using the within-group covariance matrix is a reasonable alternative as the estimator of an ancestral covariance matrix, it ignores branch lengths, and so should be used carefully when matrix differences are correlated to phylogenetic distance. An alternative when matrix evolution depends of branch lengths is to reconstruct every position of the covariance matrix independently via maximum likelihood, but this method can result in non positive-definite estimates.PhyloCompare: Sometimes it is not practical to pairwise compare every single population in a study, since for a large number of populations these results can be difficult to interpret. In these cases, comparing populations in a phylogeneticaly structured way can be helpful in detecting major transitions or differences between clades.PhyloCompare takes estimates for all the nodes in a tree and compares sister groups by any comparison method, providing comparison values for every inner node.61. In the context of morphological traits, variational modularity is associated with the concept of integration47, that is, the tendency of morphological systems to exhibit correlations due to common developmental factors and functional demands18.Modularity is a general concept in biology, and refers to a pattern of organization that is widespread in many biological systems. In modular systems, we find that some components of a given structure are more related or interact more between themselves than with other components. These highly related groups are termed modules. The nature of this interaction will depend on the components being considered, but may be of any kind, like physical contact between proteins, joint participation of enzymes in given biochemical pathways, or high correlation between quantitative traits in a population. This last kind of modularity is called variational modularity, and is characterized by high correlations between traits belonging to the same module and low correlation between traits in different modules38. At the same time, selection can alter existing patterns of integration and modularity, leading to traits becoming more or less correlated39. The correlations between traits in aG-matrix then carries important information on the expected response to selection and on the history of evolutionary change of a given population.Both modularity and integration may have important evolutionary consequences, since sets of integrated traits will tend to respond to directional selection in an orchestrated fashion due to genetic correlations between them; if these sets are organized in a modular fashion, they will also respond to selection independently of one anotherTestModularity: Variational modularity can be assessed by comparing a modularity hypothesis  with the observed correlation matrix. If two traits are in the same variational module, we expect the correlation between them to be higher than between traits belonging to different modules. We test this partition by creating a modularity hypothesis matrix and comparing it via Pearson correlation between the corresponding elements in the observed correlation matrix. The modularity hypothesis matrix consists of a binary matrix where each row and column corresponds to a trait. If the trait in rowi is in the same module of the trait in columnj, position  in the modularity hypothesis matrix is set to one, if these traits are not in the same module, position  is set to zero. Significant correlation between the hypothetical matrix representing a modularity hypothesis and the observed correlation matrix represents evidence of the existence of this variational module in the population. We also measure the ratio between correlations within a module (AVG+) and outside the module (AVG-). This ratio (AVG+/AVG-) is called the AVG Ratio, and measures the strength of the within-module association compared to the overall association for traits outside the module. The higher the AVG Ratio, the bigger the correlations within a module in relation to all other traits associations in the matrix  than the Modularity Hypothesis Index, the AVG Ratio cannot be used when the observed correlation matrix presents correlations that differ in sign, and this is usually the case for residual matrices after size removal  is the Kronecker delta, where:The termsL. The termik represent the total amount of correlation attributed to traiti, or the sum of the correlation with traiti:This means only traits in the same module contribute to the value ofm is the sum of alli andj. This choice for the null expectation is natural when we impose that it must depend on the values ofik andjk and must be symmetrical45. So, traits in the same module with correlations higher than the null expectation will contribute to increase the value ofL, while traits in the same module with correlation less than the null expectation will contribute to decreaseL. With this definition ofL, we use an optimization procedure to find the partition of traits  that maximizesL. This partition corresponds to the modularity hypothesis inferred from the correlation matrix, and the value ofL is a measure of modularity comparable to the AVG Ratio. The igraph package10 provides a number of community detection algorithms that can be used on correlation matrices using this function.AndRemoveSize: If the first principal component of a covariance or correlation matrix corresponds to a very large portion of its variation, and all (or most) of the entries of the first principal component are of the same sign  and one derived. Letz0 represent a vector of means fromm traits in an ancestral population. Aftert generations, the expected traits mean forn populations under drift would correspond toz0 with variance given byB = (et/N)W, whereB represents the expected between group covariance matrix,W is the genetic covariance matrix from the ancestral (or reference) population, andeN is the effective population size28. So, given the ancestral population mean andG-matrix, we can use this model to estimate theB-matrix expected under drift. We can then use thisB-matrix as the Σ parameter in a multivariate normal distribution and samplen populations from this distribution. Using this sample of random populations, we can assess the amount of divergence expected by drift, estimated as the norm of the difference vectors between ancestral (or reference) and simulated population means. Then, we can compare the observed amount of divergence between the ancestral and derived populations, calculated as the norm of the difference vector between them, taking into account the standard error of traits means. An observed divergence higher than the expectations under drift indicates that genetic drift is not sufficient to explain currently observed divergence, suggesting a selective scenario.PCScoreCorrelation: This test of drift relies on the correlation between principal component scores of different populations. Under drift alone, we expect the mean scores of different populations in the principal components of the within-group covariance matrix to be uncorrelated35. Significant correlations between the scores of the means on any two principal components is an indication of correlated directional selection12.RandomMatrix: Generating realistic random covariance matrices for null hypothesis testing is a challenging task, because random matrices must adequately sample the space of biologically plausible evolutionary parameters, like integration and flexibility. Most common covariance and correlation matrix sampling schemes fail at this, producing matrices with unrealistically low levels of integration, unless the level of integration is supplieda priori >                     install_                    github ("lem-usp/evolqg")                                    A less up-to-date version is also available from CRAN:>                     install.packages                    ("evolqg")                                    1.http://cran.r-project.org/web/packages/evolqg/Software available from:2.https://github.com/lem-usp/EvolQGLatest source code:3.http://dx.doi.org/10.5281/zenodo.5512163Archived source code as at time of publication:4.https://opensource.org/licenses/MIT)License: The MIT License ( Thank you for the opportunity to review the article “EvolQG - An R package for evolutionary quantitative genetics.” I am reviewing the version of 27 June 2016 (V.2). My overall impression of the paper and the associated package, which I have gone through in some detail, is that it makes a useful contribution to the study of the evolution of complex traits. Having many of these techniques available in an easily useable form will be a a boon to many researchers. I have some reservations that echo those of reviewers of previous and current versions of this manuscript. I think that a useful revision to the paper might be to clearly distinguish between applications and treatments of the P and G matrices. For morphological characteristics, I concur that there are good reasons to believe that P and G will be roughly proportional to one another , but handling errors in either case are rather different. The BootStrapRep and MonteCarloRep functions will work as described for a phenotypic correlation matrix, but not for a genetic correlation matrix, which would require some kind of resampling or simulation procedure that considered relatedness among individuals. This is not easy even in simple circumstances like those found in experimental studies (full-sib designs and the like) and very taxing in the kinds of pedigree based studies of wild organisms that are becoming the norm in the field.  A work-around that I would accept only for analysis of legacy results from the literature would be to include a way to include effective sample sizes . This would give an estimate of the number of effectively independently estimated breeding values worth of information in a sample and would be a better reflection of the errors in the genetic quantities. In the absence of this, adding explicit ways of working with the posterior distributions or estimated matrix of errors from the estimate of the G matrix would be welcome in your package. At the very least, you should make the distinction between these cases clearer in the text. I think the random skewers procedure should be revisited in one respect. The Marroig and Cheverud (2007) procedure describes drawing random selection gradient values from a uniform distribution and then standardizing the resulting vector to unit length. This is meant to provide random directions in the phenotypic space. This procedure, however, does not achieve this as the distribution of random points before standardization is from a hypercube of the same dimensionality as the number of traits. This will lead to an uneven distribution of points around the hypersphere on which the unit length vectors of standardized simulated selection gradients would occupy. In effect, the extra space in the corners of the hypersphere cause patches of excess vectors. This could cause considerable mischief if, for example, the first principal component of a covariance matrix was oriented directly at  corner of the hypercube. It might be worth modifying the procedure to draw random Gaussian variables, which are then standardized to unit length following Muller (1959) and Marsaglia (1972). This would ensure truly random simulated directional selection. I would like to second Prof. Houle’s point that there are many aspects of the different techniques that do not have much to do with evolution in an explicit way. Many of the matrix comparisons don’t have much to do with the degree to which responses to evolution might differ given a difference in the matrices. We could easily extend this critique to the parts of the package linking covariation to development. Phenotypic covariance/correlation matrices underdetermine the developmental processes through which covariation is generated and without some kind of independent assessment of developmental process. LModularity arbitrarily assumes a lot about how organisms work. Without some extra information about the perturbations to developmental process, we have no idea what the biological meaning resulting clusters of traits might be or whether they relate to development at all. That said, I do think most of the techniques contained in the package will be very useful for many people. On balance, I regard EvolQG as a welcome contribution to the toolkit available to scholars interested in the evolution of complex traits. I would like to see the issues dealing with the errors in G and P to be clarified and the correction to the sampling in the random skewers to be implemented. Some smaller comments: “The Krzanowski shared space, or Krzanowski correlation, measures the degree to which the first principal components (eigenvectors) span the same subspace” This sentence and the section in which it is nested is a little opaque. Please reword so that it is clear how many principal components we need to consider. “transposing these methods efficiently to multiple traits, and the many different robust packages for performing some of these analyses..” “Transposing” does not strike me as the right word here. Please reword.I have read this submission. I believe that I have an appropriate level of expertise to confirm that it is of an acceptable scientific standard, however I have significant reservations, as outlined above. Thank you for the careful review! We respond to some of the specific comments below:I think that a useful revision to the paper might be to clearly distinguish between applications and treatments of the P and G matrices. For morphological characteristics, I concur that there are good reasons to believe that P and G will be roughly proportional to one another , but handling errors in either case are rather different. The BootStrapRep and MonteCarloRep functions will work as described for a phenotypic correlation matrix, but not for a genetic correlation matrix, which would require some kind of resampling or simulation procedure that considered relatedness among individuals. This is not easy even in simple circumstances like those found in experimental studies (full-sib designs and the like) and very taxing in the kinds of pedigree based studies of wild organisms that are becoming the norm in the field. This is correct, and we have modified the text to make this clear.A work-around that I would accept only for analysis of legacy results from the literature would be to include a way to include effective sample sizes . This would give an estimate of the number of effectively independently estimated breeding values worth of information in a sample and would be a better reflection of the errors in the genetic quantities.  I believe this is already possible in the package, if I understood correctly. Both BootstrapRep and MonteCarloRep have sample size arguments. In the absence of this, adding explicit ways of working with the posterior distributions or estimated matrix of errors from the estimate of the G matrix would be welcome in your package. At the very least, you should make the distinction between these cases clearer in the text. As much as we would like to provide general methods for G matrix error estimation, the current available mixed model packages in R for ML estimation make this difficult. We recommend using MCMCglmm or some other Bayesian framework to incorporate uncertainty, and the posterior samples can be trivially used with the functions in the package.I think the random skewers procedure should be revisited in one respect. The Marroig and Cheverud (2007) procedure describes drawing random selection gradient values from a uniform distribution and then standardizing the resulting vector to unit length. This is meant to provide random directions in the phenotypic space. This procedure, however, does not achieve this as the distribution of random points before standardization is from a hypercube of the same dimensionality as the number of traits. This will lead to an uneven distribution of points around the hypersphere on which the unit length vectors of standardized simulated selection gradients would occupy. In effect, the extra space in the corners of the hypersphere cause patches of excess vectors. This could cause considerable mischief if, for example, the first principal component of a covariance matrix was oriented directly at  corner of the hypercube. It might be worth modifying the procedure to draw random Gaussian variables, which are then standardized to unit length following Muller (1959) and Marsaglia (1972). This would ensure truly random simulated directional selection. We generate random vectors using normal distributions for the elements to avoid this problem. Since the multivariate normal is spherically symmetrical, there are no privileged directions. This article has been improved in response to the previous comments of the reviewers.  The authors have added several important and difficult-to-implement new analyses to the package, especially those discussed in Aguirre et al. 2014. The text  has been altered to make clearer the limitations of some of the procedures.   On the other hand, many of my more general comments about the shortcomings of the package still hold, and I refer the reader to my first set of comments.  One problem has, however, gotten worse, and that is how the package discusses the estimation of errors in G matrices and other variance component matrices. The text and code does not properly distinguish between sampling error of estimates of G matrices and sampling error of  simple statistics based directly on the data.   Consequently at many points the package could be used to produce misleading estimates of error in evolutionary statistics.  The section on matrix error and repeatability is the locus of this problem.  The opening paragraph in this section is about error in the G matrices, but none of the methods in that section actually apply to G matrices.  In particular  the text equates the REML-MVN method  with this package's MonteCarloRep, but this is incorrect.  REML-MVN requires you to have an estimate of the sampling variance-covariance of matrix elements, but the software implements the assumption that the only parameter that is needed to construct an estimate of error is the sample size.  This works for a P matrix of multivariate normal data, but is NOT the REML-MVN method. "MonteCarloStat and BootstrapStat can be used to generate confidence intervals for these statistics" is incorrect. To properly deal with this problem all of the routines should allow the user to furnish samples of matrices from the sampling distributions (e.g. samples from the posterior distribution), and then produce measures of uncertainty from those.   Similarly, the bootstrap routine seems only to bootstrap at the level of individuals.  Bootstrapping over individuals will always severely underestimate the error in G. For a designed experiment like a full and half-sib estimation of G, one could get proper estimates of error in G by bootstrapping over sires, which are the exchangeable units in that design.  A pedigree cannot be effectively bootstrapped as individuals are not exchangeable.  For a G matrix, you need additional estimates of error from either the posterior distribution of matrices, the variance-covariance matrix of estimates from a ML procedure, or  samples drawn from such a distribution.   Consequently the statement at the start of the Evolutionary Statistics section that It would be ideal for the package to implement the ability to utilize such samples in every procedure.I have read this submission. I believe that I have an appropriate level of expertise to confirm that it is of an acceptable scientific standard, however I have significant reservations, as outlined above. Thank you for the second careful review! We agree completely with the problems regarding G-matrix error and have modified the text to make these limitations clear. As much as we would like to provide general methods for G matrix error estimation, the current available mixed model packages in R for ML estimation make this difficult. We recommend using MCMCglmm or some other Bayesian framework to incorporate uncertainty. This paper describes the functions implemented in the R package “evolvqg.”  This package implements a large set of methods for characterizing and comparing variance-covariance matrices. A compendium of such methods is useful, but the user should be aware of shortcomings in this package. First, the authors justify grouping these methods together under the umbrella of “evolutionary quantitative genetics.” Under this label, the very diversity of methods is a bit misleading - the majority of implemented methods have no explicit relationship to evolution, and this is not clear in the paper. To a large degree this confusion reflects the state of the field. A great many ad hoc methods are proposed and widely applied, such as the popular Mantel test. For example, this package implements methods for quantifying repeatability of the phenotypic covariance and correlation matrices, which is a fine thing to do, but has little relevance to the genetic matrices that underlie evolution. For those matrices, any procedure for estimating them will partition out the non-genetic factors as part of the hierarchical model fitting. Repeatability is usually the least of our estimation problems. Other methods that are in this not-really-evolutionary category include, matrix correlations, the ‘modularity’ analyses. et al. 2009, Houle and Fierst 2013; Aguirreet al. 2014). Programming time is of course a limitation, and no one is under obligation to implement everything. However, it is deficient scholarship that this paper makes no mention of these approaches, or of the availability of software that does these analyses.  A related issue is that this package does not include state-of-the-art techniques. In particular, the advent of MCMC methods (plus other methods for getting sampling variation of matrices: Houle and Meyer 2015) provides proper measures of uncertainty for the evolutionarily relevant G matrices. The previously available R package “evolvability” uses the posterior distributions for G matrices as well as selection gradients, when available, to place confidence intervals on the Hansen and Houle measures of evolvabilities. The “evolqg” package under review here primarily implements methods developed and used by the Marroig group, lacking some of the most promising approaches and metrics developed by others  provides proper measures of uncertainty for the evolutionarily relevant G matrices. The previously available R package “evolvability” uses the posterior distributions for G matrices as well as selection gradients, when available, to place confidence intervals on the Hansen and Houle measures of evolvabilities. The “evolqg” package under review here primarily implements methods developed and used by the Marroig group, lacking some of the most promising approaches and metrics developed by others . Programming time is of course a limitation, and no one is under obligation to implement everything. However, it is deficient scholarship that this paper makes no mention of these approaches, or of the availability of software that does these analyses.   While we challenge the reviewer's assertion that we fail to mention these methods , the point is well taken. Another reason for choosing F1000Research was the ease of updating the manuscript as we add new functionality to the EvolQG package. In this spirit of continuous development, we added in the revised version of the package three of the methods described in Aguirre et al. 2014, including the eigentensor decomposition described by Hine et al. 2009, using fast and flexible implementations in R.- Based on their descriptions here, the phylogenetic comparison methods implemented in this package seem to be quite deficient.  We would argue that the available methods in the literature are deficient in dealing with multivariate correlated traits, and we provide the rather simple available methods.- AncestralStates is contradictorily described as dealing with multivariate data, but reconstructs each character independently. It appears to implement an interface to a univariate method, and is not actually a multivariate approach. We clearly stated that AncestralStates is not a multivariate approach. Indeed AncestralStates is just a wrapper to facilitate reconstructing multiple traits independently. If the reviewer has a suggestion on how to implement this taking the multivariate covariance structure into account for many traits we would be very interested, but this remains an active research topic, and we have not found a satisfactory solution for this problem. Since this seems to be more misleading than helpful, we have removed this function from the package and manuscript.- PhyloW and PhyloCompare compute “weighted” estimates of matrices at internal nodes, but the proper weight to apply to a G matrix is not clear at all. This appears to only deal with sampling variance at the individual level, neglecting the more important sources of matrix variation.  This is another unambitious method, and was intended only to calculate within-group phenotypic covariance matrices in a phylogenetically structured way. The use with G-matrices coming from more complex linear models would indeed be non-trivial, and we now make this explicit in the description.- This disconnect appears to rest on the author's assumption that “As a general rule, high similarity between populations’ P-matrices is a good indicator of high similarity between P and G”. This is certainly not a general rule, as P and G matrices for traits with low heritability can be very different from each other. The classic examples are life history traits. We would argue that in the case of low heritability the P-matrices between populations would also be dissimilar. The point here is not that P and G are always similar, but that similar Ps between populations are a fair indication of similar Gs and Ps, at least in the groups we have worked with. In mammals, this conclusion is supported empirically by the comparisons of 5 different G-matrices with P-matrices of several groups, which indicate similar responses to random selection on average . In any event, we add a caveat on the function description that structurally similar matrices are a key component of the methods implemented here.- For drift models, this implementation shares a major deficiency with previous work, in assuming that the expectation is that matrices will remain proportional. This is indeed the large-sample expectation, but any actual population will deviate from that expectation in ways that depend on the unknown parameters of the underlying system – the number of loci, their relative mutability, the underlying M matrix, and of course the effective population size of each part of the genome. For example, Griswold et al. 2007 show that even when the underlying M matrix is spherical, realizations based on this will have substantial deviations from sphericity. There is no general treatment of this problem, so all results from such analyses need to be treated with caution. A failure to reject a departure from proportionality is meaningful, but rejections of proportionality do not necessarily indicate that drift is not responsible. This is indeed a problem, and we try to remedy this by ensuring the matrices share some minimum level of similarity before using these drift models. Proa et al. 2013 analysed the type I error rate in the DriftTest method, and found that if matrices are similar the test is well behaved. This similarity must be tested on a case by case basis. Error rate analysis of the other tests is an open problem. Another option is to repeat the analysis using different matrices from the terminal taxa that represent extremes of variability, and check if the results are robust to this. We make these caveats and problems clear in the revised manuscript. This paragraph now reads: "Since both these tests use drift as a null hypothesis, failure to reject the null hypothesis is not evidence that selection was not involved in the observed pattern of diversification, only that the observed pattern is compatible with drift. Also, these methods assume that the matrices involved share some degree of similarity, and should ideally be proportional to each other. We would be very weary of using these methods if the matrices are too dissimilar, or if the results change radically if different matrices are used as the ancestral matrix. Also, these tests rely on two levels of replication, taxa and traits. As a general guideline, at least 20 traits and at least 8 taxa should be sampled for using these methods with any confidence, and results should be analyzed in conjunction with other lines of evidence." With regards to Griswold et al. 2007, we believe that verifying the extant matrices are similar somewhat sidesteps these problems, and in any event their simulations do not include stabilizing selection on covariance patterns, which is very likely to exist if matrices are stable in evolutionary timescales. It’s important to realize that the methods we describe are for identifying drift on species means, not covariances. Evolution of covariance patterns is a different matter altogether.- Finally, like much of the software being made freely available, there is no description of what the authors did to validate their implementation of these techniques, and no comparisons with previous analyses to indirectly validate them. One or both of these should really be standard with new software. I know that it is not standard, and do not want to single these authors out on that account. The user, however, should be aware of all unvalidated software, and should perform their own checks. Unfortunately, this is only easy for simple procedures for which a package is not really necessary. We agree entirely, and feel that the bar for scientific software should be high, and so we took additional steps in this direction. While no implementation is bug free, we compared all results from our initial set of functions between different implementations done by members of our lab and available implementations in the literature. Also, all development for the package was done in a test driven development framework, and all functions have unit tests for the most or all of their functionality, that is run every time the package is built. This insures modifications do not alter previous results. The implementations in the package follow a modular design for most functionality, minimizing code duplication and reducing the chance of bugs. We also have a fast and constantly maintained issue and bug tracker in github, where users can ask questions, request new functionality, and report bugs.- Some very specific issues:- Errors: “The proportion of variance not associated with the individuals is called the repeatability.” Changed to something clearer. Now reads: "The proportion of variance associated with among individual variation, and not within individual variation, is called the repeatability"- The description of Mantel tests is misleading, as a high correlation does not mean that matrices are the “same,” nor does a negative correlation mean that matrices are “opposite.”  We chose a more cautious wording of these general guidelines. Now reads: "The correlation between matrices range between -1 and 1, and higher correlations indicate matrices have more similar structures, while null correlations indicate the matrices have very distinct correlation structures. Correlations near zero can also occur if the elements of the matrices have nonlinear relationships between them, as in all Pearson correlations. Negative correlations indicate the pattern of association between traits is reversed in the two matrices."- The description of the PCA similarity algorithm is opaque. What is “pondering”? Sorry, this was a rather hard false cognate with portuguese for us to catch, and now reads:  "In order to take the variation into account, we can add the eigenvalue associated with each principal component into the calculation, effectively weighting each correlation by the variance in the associated directions"Cheverud, J. M. (1996). Quantitative genetic analysis of cranial morphology in the cotton‐top (Saguinus oedipus) and saddle‐back (S. fuscicollis) tamarins. Journal of Evolutionary Biology, 9(1), 5-42.Marroig, G., & Cheverud, J. M. (2001). A comparison of phenotypic variation and covariation patterns and the role of phylogeny, ecology, and ontogeny during cranial evolution of New World monkeys. Evolution, 55(12), 2576-2600.Prôa, M., O'Higgins, P., & Monteiro, L. R. (2013). Type I error rates for testing genetic drift with phenotypic covariance matrices: a simulation study. Evolution, 67(1), 185-195.Porto, A., de Oliveira, F. B., Shirai, L. T., De Conto, V., Marroig, G., (2009). The Evolution of Modularity in the Mammalian Skull I: Morphological Integration Patterns and Magnitudes. Evolutionary Biology, 36(1), 118–135. doi:10.1007/s11692-008-9038-3 Literature cited This Software Tool is an open source R package for performing a wide variety of evolutionary genetic analyses. It comes at a particularly useful time when large data sets required to use these analytical techniques are more and more available. I predict this package will be used to a greater and greater extent over time.The team, with lead author Diogo Melo, has made a number of major innovations in the field of evolutionary quantitative genetics and this software tool is well within their purview.The group describes the potential application of the new software well, cites the sources for the development of the different methods included, and briefly explains each function with an adequate level of discussion. I found the section on Phylogenetic Comparisons most interesting, and would have liked more discussion of these points.It would be nice to include data for which the tools could be tried out on and examples of the output included in the text.I also worry about the power of some of these tests, and would appreciate if the authors were to think about adding in caveats where available. There are a few papers out currently that address these issues . For example, I have both heard and performed some analyses using another version of the DriftTest function and it appears about 20 traits are required to ever reject the null hypothesis. As this package is sure to be used by researchers who are less acquainted with these issues they may be unaware of issues with sample sizes, etc.Issues:I have read this submission. I believe that I have an appropriate level of expertise to confirm that it is of an acceptable scientific standard. Thank you for your kind comments. We have included some additional caveats in relation to the power and level of replication required for some of the tests. With regards to examples, we fell a package vignette tutorial is much more suited to this, and we are working on more documentation to be distributed with the package.


A better understanding of the genetic architecture underlying complex traits  may aid in the genomic prediction. Here, we hypothesized that the genomic variants of complex traits might be enriched in a subset of genomic regions defined by genes grouped on the basis of “Gene Ontology” (GO), and that incorporating this independent biological information into genomic prediction models might improve their predictive ability.Four complex traits  together with imputed sequence variants in Holstein (HOL) and Jersey (JER) cattle were analysed. We first carried out a post-GWAS analysis in a HOL training population to assess the degree of enrichment of the association signals in the gene regions defined by each GO term. We then extended the genomic best linear unbiased prediction model (GBLUP) to a genomic feature BLUP (GFBLUP) model, including an additional genomic effect quantifying the joint effect of a group of variants located in a genomic feature. The GBLUP model using a single random effect assumes that all genomic variants contribute to the genomic relationship equally, whereas GFBLUP attributes different weights to the individual genomic relationships in the prediction equation based on the estimated genomic parameters. Our results demonstrate that the immune-relevant GO terms were more associated with mastitis than milk production, and several biologically meaningful GO terms improved the prediction accuracy with GFBLUP for the four traits, as compared with GBLUP. The improvement of the genomic prediction between breeds (the average increase across the four traits was 0.161) was more apparent than that it was within the HOL (the average increase across the four traits was 0.020).Our genomic feature modelling approaches provide a framework to simultaneously explore the genetic architecture and genomic prediction of complex traits by taking advantage of independent biological knowledge.The online version of this article (doi:10.1186/s12864-017-4004-z) contains supplementary material, which is available to authorized users. Studying the genetic architecture  and predicting future individual phenotypes for complex traits and diseases on the basis of genomic polymorphism data are very important in the fields of human medicine, adaptive evolution, and plant and animal breeding. Genomic predictions for such traits have been most often conducted by assuming that all of the genomic variants have a small effect drawn from the same prior distribution , such asDrosophila melanogaster Genetic Reference Panel (DGRP), and its prediction accuracy can be substantially improved by several Gene Ontology (GO) [It has been proposed that shifting the focus from millions of whole genome sequence variants to those more likely to have functional effects might improve the accuracy of genomic predictions, especially in populations of not closely related individuals –12. Howeogy (GO)  terms thogy (GO) . However, milk, fat and protein yields, and mastitis) together with the imputed sequence variants in two dairy cattle breeds, Holstein  and Jersey , were analysed. We hypothesized that the associated variants of these traits were likely to be clustered in genes belonging to GO terms of biological relevance and that this pattern might be consistent between breeds, although different breeds might have different mutations. The objectives of this study were 1) to explore the genetic and biological basis underlying milk production and mastitis by using post-GWAS analysis in the HOL training population (n = 4002), 2) to improve the prediction accuracy for these complex traits within and between breeds by using GFBLUP instead of GBLUP, and 3) to investigate the relationship between the degree of enrichment of association signals  in a genomic feature based on post-GWAS in the HOL training population and its predictive ability with GFBLUP in the HOL validation population.In this study, four complex traits  and mastitis in a HOL training population using imputed sequence variants. The -log10(P) value of each tested variant for the four traits is shown in a Manhattan plot : immune system process (n = 12), response to stimulus (n = 66), cellular process (n = 50), localization (n = 40), behaviour (n = 4), metabolic process (n = 87), cellular component biogenesis (n = 32), developmental process (n = 62), biological regulation (n = 84), biological adhesion (n = 5), and reproduction (n = 7). The enrichment degree of the association signals in each of these GO families was compared between milk production and mastitis based on the post-GWAS analysis.A total of 449 GO terms annotated for 4216 unique genes  were analysed. The average number of mapped variants in each of the studied GO terms was 2560 . In total, the 449 GO terms could be grouped into 11 GO families  correlated with the degree of enrichment of association signals based on post-GWAS for all 449 GO terms across four traits  GO terms based on post-GWAS resulted in no or negative improvement in the accuracy of genomic prediction. Therefore, alternative post-GWAS methods should be developed to be better predictors of the genomic prediction improvement with GFBLUP. The top five predictive GO terms for each trait are summarized in Table DGAT1 was included in this GO term. Compared to GBLUP, several GO terms relevant to the immune response led to the increased prediction accuracies with GFBLUP for milk production traits, such as “response to lipopolysaccharides”, with the increases of 0.013 and 0.028 in prediction accuracy for milk and fat yield, respectively, and “defence response to bacteria”, with a increase of 0.006 in prediction accuracy for protein yield (Table The prediction accuracy of the GBLUP model was 0.635 (bias = 0.862) for milk yield, 0.607 (bias = 0.808) for fat yield, 0.602 (bias = 0.775) for protein yield, and 0.504 (bias = 0.864) for mastitis. With the GFBLUP model, compared with the GBLUP model, 53, 64, 47, and 78 out of the 449 GO terms led to an increase of at least 0.001 in prediction accuracy for milk, fat and protein yields and mastitis, respectively, and these were considered predictive GO terms for each trait. Detailed information on the GFBLUP analyses for the four traits is summarized in Additional file SNPf) for milk yield, 0.003–0.025% for fat yield, 0.003–0.057% for protein yield, and 0.001–0.047% for mastitis  was used as a training set to validate JER individuals: 0.160 (bias = 0.762) for milk yield, 0.070 (bias = 0.482) for fat yield, 0.098 (bias = 0.622) for protein yield, and −0.058 (bias = −0.343) for mastitis. In total, 30 of the 53 predictive GO terms detected within the HOL breed were also identified as predictive (Δr ≥ 0.001) between breeds for milk yield, 38 of 64 for fat yield, 29 of 47 for protein yield, and 46 of 78 for mastitis. Several GO terms led to decreases in the prediction accuracy with GFBLUP relative to GBLUP, probably because differently segregated QTLs or LD patterns between breeds led to “incorrect” weights being placed on the genomic variants in the features. The details of the GFBLUP analyses between breeds are summarized in Additional file The prediction accuracies with the GBLUP model were very low when the entire HOL population  and the imputation accuracy of sequence genotypes are limited , our resHere, we took the high-ranking predictive GO terms detected between breeds as examples of the power of our GFBLUP model to reveal biological processes associated with complex traits. For milk production, five GO terms, “positive regulation of multicellular organism growth”, “retinol metabolic process”, “response to lipopolysaccharides”, “positive regulation of transcription from RNA polymerase II promoter” and “cellular response to heat”, were highly predictive Table . The firFor mastitis, all of the top five predictive GO terms, “negative regulation of apoptotic process”, “response to lipopolysaccharides”, “negative regulation of protein binding”, “positive regulation of cysteine-type endopeptidase activity involved in apoptotic process”, and “cellular response to interferon-gamma”, have previously been suggested to be associated with mastitis in transcriptome studies on specific tissues  of cows with and without intra-mammary infection –25. Of mThe genomic feature modelling approaches can be easily extended to integrate different sources of prior information, such as biological pathways, sequence ontologies, conservative genomic regions across species, and other types of evidence from functional experimental studies . The biological interpretation can become informative when additional layers of biological knowledge are included in the modelling approaches. However, a proportion of genes have not yet been functionally characterized or mapped to any manually curated or predicted pathways , 26–28, Post-GWAS using prior biological knowledge may be a computationally simple approach to help open the “black box” of the genetic architecture underlying complex traits and to simultaneously offer novel insights into biological mechanisms. Multiple methods have been developed to implement this strategy, and the statistical properties of most of them have been thoroughly reviewed . Our preWe hypothesize that the difference in prediction accuracy between GFBLUP and GBLUP is because the assumption of GBLUP  does not match the genetic architecture of the traits. Instead, the genomic variants of complex traits seem to be enriched in certain genome regions. The genomic variants located in these enriched regions have greater weights than the remaining variants in GFBLUP, on the basis of their estimated genomic parameters, thus resulting in greater prediction accuracy. However, if the estimated genomic parameters deviate from their true values, less accurate predictions will result, because too much weight is placed on the “incorrect” genomic relationships in the prediction equations, as shown in Fig. When the validation populations are very closely related to the training populations, the increase in prediction accuracy with GFBLUP may be limited compared to that achieved with GBLUP. In such populations with a high degree of LD, the determined genomic relationship in GBLUP  may provide accurate information about the causal genomic variants. A recent study has demonstrated that in a purebred Danish Duroc pig population, the increase in prediction accuracy with GFBLUP relative to GBLUP for complex traits , incorporating prior information of QTL regions, ranges from very small to zero . HoweverOur GFBLUP is implemented in a linear mixed-modelling framework, in which the known genetic and environmental factors can easily be adjusted , 32. In This study demonstrated that integrating prior biological knowledge on GO categories with whole-sequence variants can help to elucidate the genetic architecture and improve the genomic prediction of milk production and mastitis in dairy cattle, especially in between-breed prediction. The GFBLUP model is a flexible framework to simultaneously improve the understanding of the genetic architecture and the accuracy of the genomic prediction for complex traits, through taking advantage of independent biological priors, such as Gene Ontology and KEGG pathways. With the accumulation of biological knowledge regarding the functional annotation of the genome for a range of species, approaches such as GFBLUP will be increasingly useful, in particular for genomic prediction in validation populations that are not closely related to the training populations.http://www.nordicebv.info/) and were available for 5056 HOL and 1231 JER cattle. All of the known fixed effects were corrected. Detailed information on these phenotypes has been previously described in [The phenotypes used in this study were de-regressed proofs (DRP) of milk production traits  and mastitis from a routine genetic evaluation by Nordic Cattle Genetic Evaluation  together. The details of the imputation accuracy were described in [−6. Finally, 15,355,382 and 13,403,916 SNPs remained for further analysis in HOL and JER cattle, respectively. It has been suggested this two-step imputation strategy is more accurate than the one-step strategy  due to the complex LD pattern in dairy cattle, in particular when using individuals from multiple breeds as reference population [Details of the imputation from the 50 K or High Density (HD) genotypes of these cattle to whole genome sequence data have been described previously , 37. BriMinimac2  on the bMinimac2  and addiMinimac2 . A totalpulation .n = 4002) and validation (n = 1054) sets on the basis of the animals’ birth years. The birth year cut-off was 2006, and the younger animals were assigned to the validation set. This validation strategy was chosen because it is the most meaningful in the context of dairy cattle breeding, in which young bulls are selected for breeding on the basis of their estimated genomic values, which are predicted using a training population of older animals with phenotypes. For the between-breed prediction, the entire HOL population (n = 5056) was used as training data to predict the genomic values of JER individuals (n = 1231).For the within-HOL prediction, the dataset was separated into training . Finally, a total of 615,329 genomic variants were linked to 4216 unique genes belonging to 449 GO terms.Genes grouped into a specific GO term were considered to be genomic features. The Bioconductor package “v. 3.3.0  was usedy is a vector of the phenotype ; 1 is a vector of ones; μ is the overall mean; Z is a design matrix connecting phenotypes to random polygenic effects; α is a vector of random polygenic effects , in which α ~ N [e is the vector of residuals, where e ~N, b is the allele substitution effect , and η is a vector of random residual deviates with (co)variance structure −9, on the basis of Bonferroni multiple testing correction. Manhattan plots were generated using qqman v.0.1.2 in the R package [The association signals for the imputed sequence variants were assessed by using a two-step variance component-based method accounting for population stratification that was implemented in EMMAX . The detciation) , and \do package . The genf is the number of variants located in a genomic feature, and t2 is the square of t, which was calculated as the estimated effect of a variant divided by its standard error. The cyclical permutation strategy applied to test the association between a phenotype and a genomic feature was described previously [t2) of each variant was ranked according to the chromosome position of the variant . A test statistic  was randomly chosen from this vector. All test statistics were then shifted to the new positions, where the selected one  became the first, and the statistics of the other variants were shifted to new positions, but retained their original order . Any association between the variants and genomic features was uncoupled while maintaining the correlation structure among test statistics. Afterward, a new summary statistic of a genomic feature was calculated according to the original chromosome position of the feature. This permutation was repeated 1000 times for each tested genomic feature, and an empirical P-value was calculated on the basis of one-tailed tests of the proportion of randomly sampled summary statistics larger than that observed.Because the genomic variance of the milk production and mastitis has been generally considered to be governed by many genes, each having small to moderate effects, the following summary test statistic of a genomic feature  was used, which may be more powerful than the commonly used count-based methods described previously , 31:\docmentclasspt{minimay is the vector of phenotypic observations , 1 is a vector of ones, μ is the overall mean, gf is the vector of genetic values captured by variants in the genomic feature, gR is the vector of genomic values captured by variants in the remaining genome, and e is the vector of residuals. The assumptions for all of the random effects are given byFor each of the 449 genomic features, a separate analysis was conducted. By partitioning the genomic variants into two sets (within the genomic feature and the remaining genome), in each of the GFBLUP analyses, the collective contribution of a genomic feature to the trait was evaluated. The GFBLUP model isGf and GR are genomic relationship matrices, built using the variants in the genomic feature and the remaining genome, respectively. Both G were calculated using the second method described by VanRaden (2008) [D is a diagonal matrix with diagonal elements equal to r2 is the reliability of a DRP. n (2008) . D is a rocedure , as implrocedure .The proportion of the genomic variance explained by the genomic feature was calculated asThe proportion of SNPs in the genomic feature was calculated asmf is the number of variants in the genomic feature, and mR is the number of variants in the remaining genome.where GBLUP uses only one random genomic effect,y = 1μ + g + e,g, which is the vector of genomic values captured by all of the genomic variants. The random genomic values and the residuals were assumed to be independently distributed: with the same notation as above except for Inferences on the genomic heritability for GFBLUP and GBLUP were calculated asGenomic prediction accuracy: In the GFBLUP model, the total genomic value (GEBV) is r) is calculated as the correlation between GEBV and DRP in the validation populations. The bias of genomic predictions was measured as the regression coefficient of DRP on the GEBV, i.e. Additional file 1: Fig. S1.Manhattan plots of sequence-based genome-wide association analyses in the Holstein (HOL) training population. (TIFF 602 kb)Additional file 2: Table S1.Results of Post-GWAS and GFBLUP analyses for milk yield within the Holstein (HOL) breed. (XLSX 82 kb)Additional file 3: Table S2.Results of Post-GWAS and GFBLUP analyses for fat yield within the Holstein (HOL) breed. (XLSX 60 kb)Additional file 4: Table S3.Results of Post-GWAS and GFBLUP analyses for protein yield within the Holstein (HOL) breed. (XLSX 60 kb)Additional file 5: Table S4.Results of Post-GWAS and GFBLUP analyses for mastitis within the Holstein (HOL) breed. (XLSX 119 kb)Additional file 6: Fig. S2.10P is from post-GWAS analysis. The significant levels were determined with paired Student’s t-test. The significance levels of the comparisons are not shown, as P ≥ 0.1. (TIFF 149 kb)Comparisons of enrichment degrees of association signals in the remaining Gene Ontology (GO) super-families between milk production and mastitis in the Holstein (HOL) training population. Each point is a GO term. –logAdditional file 7: Table S5.Results of GFBLUP analyses for milk yield between Holstein (HOL) and Jersey (JER) breeds. (XLSX 32 kb)Additional file 8: Table S6.Results of GFBLUP analyses for fat yield between Holstein (HOL) and Jersey (JER) breeds. (XLSX 33 kb)Additional file 9:: Table S7.Results of GFBLUP analyses for protein yield between Holstein (HOL) and Jersey (JER) breeds. (XLSX 32 kb)Additional file 10: Table S8.Results of GFBLUP analyses for mastitis between Holstein (HOL) and Jersey (JER) breeds. (XLSX 34 kb)


Factor V Leiden and Factor II G20210A variants. Thus, clinical and notably genetic risk factors specific to the development of thrombosis associated with the use of CC in particular should be identified.Venous thromboembolism (VTE) is a complex multifactorial disease influenced by genetic and environmental risk factors. An example for the latter is the regular use of combined oral contraceptives (CC), which increases the risk to develop VTE by 3 to 7 fold, depending on estrogen dosage and the type of progestin present in the pill. One out of 1'000 women using CC develops thrombosis, often with life-long consequences; a risk assessment is therefore necessary prior to such treatment. Currently known clinical risk factors associated with VTE development in general are routinely checked by medical doctors, however they are far from being sufficient for risk prediction, even when combined with genetic tests for Step-wise (logistic) model selection was applied to a population of 1622 women using CC, half of whom (794) had developed a thromboembolic event while using contraceptives. 46 polymorphisms and clinical parameters were tested in the model selection and a specific combination of 4 clinical risk factors and 9 polymorphisms were identified. Among the 9 polymorphisms, there are two novel genetic polymorphisms (rs1799853 and rs4379368) that had not been previously associated with the development of thromboembolic event. This new prediction model outperforms  previously published models for general thromboembolic events in a cross-validation setting. Further validation in independent populations should be envisaged.We identified two new genetic variants associated to VTE development, as well as a robust prediction model to assess the risk of thrombosis for women using combined oral contraceptives. This model outperforms current medical practice as well as previously published models and is the first model specific to CC use. Venous thromboembolism (VTE), which includes deep vein thrombosis (DVT) and pulmonary embolism (PE), occurs in 1–2 per 1'000 individuals per year. The incidence increases with age, from 1 in 100'000 in children to 1 in 10'000 individuals in the reproductive age, 1 in 1'000 individuals at the age 50 to 60 and 1 in 100 over 75 years old .–20.F5-LeF5-Leiden and F2 mutations (rs6025 and rs1799963). We, therefore, also compared our model to a model that contains the previous clinical variables and coefficients for these two SNPs obtained from the literature . The ROC curves for the clinical, genetic and combined models are represented in terature .Previous studies have modelled VTE risk using different combinations of parameters although none are specific to the use of CC. Because the whole set of clinical parameters used by the other models was not available, we compared only the genetic models. The genetic score described by De Haan et al.  is basedIn this study, we determined a new combination of parameters that predicts the risk of VTE in women using CC. This combination outperformed significantly previously published models as well as the clinical evaluation currently used by medical doctors. We also identified two new genetic markers associated with the development of VTE in our population.Protein S, Protein C or Antithrombin genes.The risk of VTE development upon CC use is presently assessed by an oral anamnesis and based on physician’s experience. In the presence of clinical risk factors and/or family history, some medical doctors may request a thrombophilia status that tests for the well-established markers FV-Leiden and Prothrombin. The current incidence of 1‰ of VTE per year in CC users indicates that the risk assessement needs to be improved. Analysing genetic and clinical data for a population of women using CC, we were able to calculate a risk score that outperfoms a model that simulates the current empirical approach even when combined with additional information on FV-Leiden and Prothrombin. Our predictor Pill Protect®, including 9 genetic markers in combination with 4 clinical factors, was able to reach an out-of-sample AUC of 0.71. The use of these 9 genetic markers also outperformed the combination of markers previously published by others , 15. A tOur study presents some limitations regarding the identification of rare polymorphisms and rare mutations due to the size of the population and the limited genotyping approach which was not genome-wide. The combination of the 13 genetic and clinical parameters improves the current methodology. Further investigation using a genome-wide approach on a larger cohort would be necessary to capture additional weaker effects.We identified two polymorphisms that had not previously been associated with the development of VTE. We demonstrated that they are key in the development of VTE in CC users and future studies will address their role in the general population. The first one (rs1799853) is an established genetic markers in the field of pharmacogenetics also called *2. It affects the activity of the enzyme CYP2C9 encoded by the corresponding gene. The cytochrome CYP2C9 is involved in the metabolism of ethynyl estradiol present in most of the combined pills . We hypoThe second novel polymorphism (rs4379368) is present in the gene coding for another enzyme SUGCT. This transferase has been previously associated with migraine susceptibility using genome-wide association study . It is wThe combination of the nine SNPs identified here as well as the identification of two SNPs newly associated with VTE is specific to women who use CC due to the study design. Hence further studies will be performed to confirm that these two novel SNPs and their combination would also associate with VTE in the general population.Our model selection has three key aspects: (1) Excluding individuals with missing values would have drastically reduced the available sample size. Hence, we chose to perform 10,000 random imputations of the missing data and averaged results over the various randomly filled data sets. One could have envisioned more sophisticated data imputation, but multivariate linear imputation of the missing data would not have improved the multivariate predictive model performance. (2) To perform out-of-sample evaluation we used a cross-validation framework, where for each of the 10,000 sets we split the data into two equally-sized groups and used one group (‘training set’) to estimate the coefficients and the other group (‘test set’) to provide predictions for the AUC. We could have reported the results from a single data split, however that would not have used optimally the available data and would be prone to random fluctuations depending on the split. (3) The individual p-values of the selected 13 variables survive 5% FDR control ; hence less than one of them is expected to be a false positive finding. Our cross-validation framework (with zeroing out the coefficients of unselected variables) was designed to protect our coefficient estimates from winners curse. Further work will establish meaningful clinical thresholds in order to translate this model into a clinical test.In conclusion, we identified new genetic markers for VTE development among CC users and determined a new and robust combination of clinical and genetic parameters to predict VTE risk in CC users. Although further validation in independent populations should be envisaged, this combination outperforms all previously published genetic risk score in our cross-validation setting.S1 TableMAF stands for Minor Allele Frequency. MAF in the 1000 genomes project is indicated as MAF 1000K. MAF in the studied population with missing values is indicated as MAF controls. Fisher test was used to estimate the deviation between both frequencies. Two SNPs present significant differences between both frequencies, they are indicated in bold.(DOCX)Click here for additional data file.S2 TableThe coefficients for each indicated variable are coming from a meta-analysis of the literature.(DOCX)Click here for additional data file.


Mendelian randomization-Egger (MR-Egger) is an analysis method for Mendelian randomization using summarized genetic data. MR-Egger consists of three parts: (1) a test for directional pleiotropy, (2) a test for a causal effect, and (3) an estimate of the causal effect. While conventional analysis methods for Mendelian randomization assume that all genetic variants satisfy the instrumental variable assumptions, the MR-Egger method is able to assess whether genetic variants have pleiotropic effects on the outcome that differ on average from zero , as well as to provide a consistent estimate of the causal effect, under a weaker assumption—the InSIDE (INstrument Strength Independent of Direct Effect) assumption. In this paper, we provide a critical assessment of the MR-Egger method with regard to its implementation and interpretation. While the MR-Egger method is a worthwhile sensitivity analysis for detecting violations of the instrumental variable assumptions, there are several reasons why causal estimates from the MR-Egger method may be biased and have inflated Type 1 error rates in practice, including violations of the InSIDE assumption and the influence of outlying variants. The issues raised in this paper have potentially serious consequences for causal inferences from the MR-Egger approach. We give examples of scenarios in which the estimates from conventional Mendelian randomization methods and MR-Egger differ, and discuss how to interpret findings in such cases.The online version of this article (doi:10.1007/s10654-017-0255-x) contains supplementary material, which is available to authorized users. Althk factor . These ak factor , 8.Mendelian randomization-Egger (MR-Egger) is a statistical method that can be employed when the instrumental variable assumptions do not hold, but a weaker assumption is satisfied . The metMR-Egger consists of three parts: (1) a test that indicates both violations of the instrumental variable assumptions and bias in conventional instrumental variable analysis methods; (2) a test for a causal effect; and (3) an estimate of the causal effect. Software code in R for implementing all of the analyses in this paper is provided in “Appendix A.1” in supplementary material.We assume that all relationships between variables  are linear with no effect modification. We also assume that all genetic variants are uncorrelated , although conventional instrumental variable methods for analysing summarized data from correlated variants have been developed , and simThe genetic association with the outcome can be decomposed into the sum of a direct (pleiotropic) effect and an indirect  effect: outcome ; see Fig outcome . Any sucjth genetic variant, and likewise jth genetic variant. With multiple genetic variants, the ratio estimates from each genetic variant can be averaged using an inverse-variance weighted formula taken from the meta-analysis literature to provide an overall causal estimate known as the inverse-variance weighted (IVW) estimate [With a single genetic variant β^Yjβ^Xj , where \estimate . This asestimate ), then testimate :2\documerrelated . The samon model :3\documequal one .j; in other words, if all genetic variants are valid instrumental variables), then each of the If the pleiotropic effects of the genetic variants are all zero  of genetic variants are associated with the outcome. In comparison, MR-Egger assesses whether there is a dose–response relationship between the genetic associations with the risk factor and those with the outcome.Genetic associations are usually the per allele associations of the genetic variants with the risk factor and with the outcome. Associations of genetic variants  can be quoted with respect to either the major or the minor allele. For example, if a genetic variant has a C allele and a T allele, the association could equivalently be given as (say) 0.243 units per additional copy of the C allele, or as Figure mentclass2pt{minimTo address this issue, we orientate the genetic variants so that the associations with the risk factor all have the same sign. This means that directional pleiotropy is defined with respect to the risk factor-increasing allele . Orientating the genetic variants in this way means that the MR-Egger analysis does not depend on the original coding of the genetic variants, and directional pleiotropy is perhaps more likely to be detected. It will be detected if pleiotropic effects tend to act in a consistent direction that corresponds to increases (or decreases) in the risk factor .As genetic variants included in a Mendelian randomization analysis are usually chosen as those having statistically robust associations with the risk factor, it is unlikely that the identity of the risk factor-increasing allele for a genetic variant is uncertain. However, if a genetic variant has a weak association with the risk factor, then a small change in its association with the risk factor from positive to negative will change its orientation in the MR-Egger analysis, thus potentially having a large impact on the MR-Egger causal estimate and intercept terms. This situation may arise if the genetic variants are chosen with respect to one variable, but associations are estimated with respect to a related variable  or are estimated in another population . It may be prudent in such a situation to orientate variants according to their associations in the larger dataset.In this section, we present issues relating to the interpretation of results from the MR-Egger method, including the precision of estimates, influence of outlying variants, violations of the InSIDE assumption, and situations where the MR-Egger and conventional methods give differing results.In the IVW method, the estimated variance of the causal estimate from the regression analysis is proportional to the weighted sum of the squares of the from Eq. ; this isIn the MR-Egger method, the variance of the causal estimate is inversely proportional to the weighted variance of the from Eq. , and \doβ^Yj)-2) . As pleiWhile the precision of the IVW estimate depends on the proportion of variance in the risk factor explained by the genetic variants  , the preatistic) . In a hyn et al. . The BowAs an illustration of this, despite broad consistency of the causal estimates across the genetic variants in Fig. The standard error of the causal estimate from the MR-Egger method will typically be larger than that from the IVW method; this will always be the case for fixed-effect analyses. A precise MR-Egger estimate requires genetic variants having a wide range of associations with the risk factor. However, as we discuss next, if one genetic variant has a much stronger association with the risk factor than others, then this variant will have a large influence on the coefficients in the MR-Egger regression.FTO gene region) has a much stronger association with the risk factor than other variants [J analyses each with In any regression model, an individual datapoint can have a large influence on the regression coefficients. In Fig. variants . Influenvariants , and pervariants . Cook’s ATXN2). However, the omission of this variant did not substantially affect the MR-Egger analysis .We calculated Cook’s distances and Studentized residuals for all the variants included in the MR-Egger analysis of plasma urate and CHD risk presented in Fig. While the MR-Egger intercept test does not require the InSIDE assumption to be satisfied to detect violations of the instrumental variable assumptions, the interpretation of the intercept as an average pleiotropic effect, as well as the assessment and estimation of a causal effect using MR-Egger, do rely on the InSIDE assumption. Equally, although the primary assumption for the IVW method is that all variants are valid instruments, it also provides consistent estimates when the average pleiotropic effect is zero and the InSIDE assumption is satisfied. Although the initial presentation of the MR-Egger method  gave biaSome general plausibility of the InSIDE assumption can be inferred from the observation that genetic associations with different measured variables tend to be uncorrelated with each other, as demonstrated in empirical studies . If all Some general plausibility of the InSIDE assumption can be inferred from the observation that genetic associations with different measured variables tend to be uncorrelated with each other, as demonstrated in empirical studies . If all It has been claimed that the InSIDE assumption can be empirically tested by assessing the correlation between the ratio estimates for the individual variants and their associations with the risk factor . HoweverAn important practical issue for the MR-Egger method is the interpretation of a discordant result from a conventional Mendelian randomization analysis. We have already seen examples in which this can occur: Fig. Additionally, if the MR-Egger intercept is larger than the association of any of the individual genetic variants  can be Two assumptions that we have made in the specification of the analysis models for both conventional and MR-Egger methods are those of linearity and homogeneity of the causal effect. These assumptions are not necessary to estimate a causal effect; weaker assumptions  as first-order concerns, while violations of assumptions that lead only to inappropriate causal estimates  are viewed as second-order concerns  for Mendelian randomization, and one of many sensitivity analyses that can (and should) be used to assess the plausibility of any finding from an applied Mendelian randomization investigation.Supplementary material 1 (pdf 114 KB)Below is the link to the electronic supplementary material.