<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/summer-of-data-science-1-genomic-prediction-machines-sods17/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://martinsbioblogg.wordpress.com/2017/07/09/summer-of-data-science-1-genomic-prediction-machines-sods17/"> R – On unicorns and genes</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>Genetics is a data science, right?</p>
<p>One of my <a rel="nofollow" href="https://www.becomingadatascientist.com/2017/05/29/summer-of-data-science-2017/" target="_blank">Summer of data science</a> learning points was to play with out of the box prediction tools. So let’s try out a few genomic prediction methods. The code is on <a rel="nofollow" href="https://github.com/mrtnj/sods17/tree/master/genomic_prediction" target="_blank">GitHub</a>, and the simulated data are on <a rel="nofollow" href="http://10.6084/m9.figshare.5142514" target="_blank">Figshare</a>.</p>
<p>Genomic selection is the happy melding of quantitative and molecular genetics. It means using genetic markers en masse to predict traits and and make breeding decisions. It can give you better accuracy in choosing the right plants or animals to pair, and it can allow you to take shortcuts by DNA testing individuals instead of having to test them or their offspring for the trait. There are a bunch of statistical models that can be used for genomic prediction. Now, the choice of prediction algorithm is probably not the most important part of genomic selection, but bear with me.</p>
<p>First, we need some data. For this example, I used <a rel="nofollow" href="http://www.alphagenes.roslin.ed.ac.uk/alphasuite-softwares/alphasim/" target="_blank">AlphaSim</a> (<a rel="nofollow" href="https://dl.sciencesocieties.org/publications/tpg/articles/0/0/plantgenome2016.02.0013" target="_blank">Faux &amp; al 2016</a>), and the AlphaSim graphical user interface, to simulate a toy breeding population. We simulate 10 chromosomes á 100 cM, with 100 additively acting causal variants and 2000 genetic markers per chromosome. The initial genotypes come from neutral simulations. We run one generation of random mating, then three generations of selection on trait values. Each generation has 1000 individuals, with 25 males and 500 females breeding.</p>
<p>So we’re talking a small-ish population with a lot of relatedness and reproductive skew on the male side. We will use the two first two generations of selection (2000 individuals) to train, and try to predict the breeding values of the fourth generation (1000 individuals). Let’s use two of the typical mixed models used for genomic selection, and two tree methods.</p>
<p>We start by splitting the dataset and centring the genotypes by subtracting the mean of each column. Centring will not change predictions, but it may help with fitting the models (<a rel="nofollow" href="https://gsejournal.biomedcentral.com/articles/10.1186/1297-9686-43-25" target="_blank">Strandén &amp; Christensen 2011</a>).</p>
<p>Let’s begin with the workhorse of genomic prediction: the linear mixed model where all marker coefficients are drawn from a normal distribution. This works out to be the same as GBLUP, the GCTA model, GREML, … a beloved child has many names. We can fit it with the R package <a rel="nofollow" href="https://github.com/gdlc/BGLR-R" target="_blank">BGLR</a>. If we predict values for the held-out testing generation and compare with the real (simulated) values, it looks like this. The first panel shows a comparison with phenotypes, and the second with breeding values.</p>
<p><a rel="nofollow" href="https://martinsbioblogg.files.wordpress.com/2017/07/ridge_prediction.png" target="_blank"><img data-orig-file="https://martinsbioblogg.files.wordpress.com/2017/07/ridge_prediction.png" data-orig-size="1386,1050" data-medium-file="https://martinsbioblogg.files.wordpress.com/2017/07/ridge_prediction.png?w=300" data-attachment-id="5330" data-image-meta="{" data-image-description="" src="https://martinsbioblogg.files.wordpress.com/2017/07/ridge_prediction.png?w=450&h=485&fit=640%2C485" data-permalink="https://martinsbioblogg.wordpress.com/2017/07/09/summer-of-data-science-1-genomic-prediction-machines-sods17/ridge_prediction/#main" data-large-file="https://martinsbioblogg.files.wordpress.com/2017/07/ridge_prediction.png?w=450&amp;h=485&amp;fit=640%2C485" alt="" data-image-title="ridge_prediction" sizes="(max-width: 640px) 100vw, 640px" data-comments-opened="1" class="wp-image-5330" data-recalc-dims="1"></a></p>
<p>This gives us correlations of 0.49 between prediction and phenotype, and 0.77 between prediction and breeding value.</p>
<p>This is a plot of the Markov chain Monte Carlo we use to sample from the model. If a chain behaves well, it is supposed to have converged on the target distribution, and there is supposed to be low autocorrelation. Here is a trace plot of four chains for the marker variance (with the <a rel="nofollow" href="https://cran.r-project.org/web/packages/coda/index.html" target="_blank">coda package</a>). We try to be responsible Bayesian citizens and run the analysis multiple times, and with four chains we get very similar results from each of them, and a potential scale reduction factor of 1.01 (it should be close to 1 when it works). But the autocorrelation is high, so the chains do not explore the posterior distribution very efficiently. </p>
<p><a rel="nofollow" href="https://martinsbioblogg.files.wordpress.com/2017/07/ridge_mcmc1.png" target="_blank"><img data-orig-file="https://martinsbioblogg.files.wordpress.com/2017/07/ridge_mcmc1.png" data-orig-size="1060,1050" data-medium-file="https://martinsbioblogg.files.wordpress.com/2017/07/ridge_mcmc1.png?w=300" data-attachment-id="5360" data-image-meta="{" data-image-description="" src="https://martinsbioblogg.files.wordpress.com/2017/07/ridge_mcmc1.png?w=450&h=634&fit=640%2C634" data-permalink="https://martinsbioblogg.wordpress.com/2017/07/09/summer-of-data-science-1-genomic-prediction-machines-sods17/ridge_mcmc-2/#main" data-large-file="https://martinsbioblogg.files.wordpress.com/2017/07/ridge_mcmc1.png?w=450&amp;h=634&amp;fit=640%2C634" alt="" data-image-title="ridge_mcmc" sizes="(max-width: 640px) 100vw, 640px" data-comments-opened="1" class="wp-image-5360" data-recalc-dims="1"></a></p>
<p>BGLR can also fit a few of the ”Bayesian alphabet” variants of the mixed model. They put different priors on the distribution of marker coefficients allow for large effect variants. BayesB uses a mixture prior, where a lot of effects are assumed to be zero (<a rel="nofollow" href="http://www.genetics.org/content/157/4/1819.full" target="_blank">Meuwissen, Hayes &amp; Goddard 2001</a>). The way we simulated the dataset is actually close to the BayesB model: a lot of variants have no effect. However, mixture models like BayesB are notoriously difficult to fit — and in this case, it clearly doesn’t work that well. The plots below show chains for two BayesB parameters, with potential scale reduction factors of 1.4 and 1.5. So, even if the model gives us the same accuracy as ridge regression (0.77), we can’t know if this reflects what BayesB could do.</p>
<p><a rel="nofollow" href="https://martinsbioblogg.files.wordpress.com/2017/07/bayesb_mcmc.png" target="_blank"><img data-orig-file="https://martinsbioblogg.files.wordpress.com/2017/07/bayesb_mcmc.png" data-orig-size="1050,1050" data-medium-file="https://martinsbioblogg.files.wordpress.com/2017/07/bayesb_mcmc.png?w=300" data-attachment-id="5361" data-image-meta="{" data-image-description="" src="https://martinsbioblogg.files.wordpress.com/2017/07/bayesb_mcmc.png?w=450&h=640&fit=640%2C640" data-permalink="https://martinsbioblogg.wordpress.com/2017/07/09/summer-of-data-science-1-genomic-prediction-machines-sods17/bayesb_mcmc/#main" data-large-file="https://martinsbioblogg.files.wordpress.com/2017/07/bayesb_mcmc.png?w=450&amp;h=640&amp;fit=640%2C640" alt="" data-image-title="bayesb_mcmc" sizes="(max-width: 640px) 100vw, 640px" data-comments-opened="1" class="wp-image-5361" data-recalc-dims="1"></a></p>
<p>On to the trees! Let’s try Random forest and Bayesian additive regression trees (BART). Regression trees make models as bifurcating trees. Something like the regression variant of: ”If the animal has a beak, check if it has a venomous spur. If it does, say that it’s a platypus. If it doesn’t, check whether it quacks like a duck …” The random forest makes a lot of trees on random subsets of the data, and combines the inferences from them. BART makes a sum of trees. Both a random forest (<a rel="nofollow" href="https://cran.r-project.org/web/packages/randomForest/index.html" target="_blank">randomForest</a> package) and a BART model on this dataset (fit with <a rel="nofollow" href="https://cran.r-project.org/web/packages/bartMachine/index.html" target="_blank">bartMachine</a> package), gives a lower accuracy — 0.66 for random forest and 0.72 for BART. This is not so unexpected, because the strength of tree models seems to lie in capturing non-additive effects. And this dataset, by construction, has purely additive inheritance. Both BART and random forest have hyperparameters that one needs to set. I used package defaults for random forest, values that worked well for Waldmann (<a rel="nofollow" href="https://gsejournal.biomedcentral.com/articles/10.1186/s12711-016-0219-8" target="_blank">2016</a>), but one probably should choose them by cross validation.</p>
<p>Finally, we can use classical quantitative genetics to estimate breeding values from the pedigree and relatives’ trait values. Fitting the so called animal model in two ways (<a rel="nofollow" href="https://cran.r-project.org/web/packages/pedigree/index.html" target="_blank">pedigree</a> package and <a rel="nofollow" href="https://cran.r-project.org/web/packages/MCMCglmm/index.html" target="_blank">MCMCglmm</a>) give accuracies of 0.59 and 0.60.</p>
<p>So, in summary, we recover the common wisdom that the linear mixed model does the job well. It was more accurate than just pedigree, and a bit better than BART. Of course, the point of this post is not to make a fair comparison of methods. Also, the real magic of genomic selection, presumably, happens on every step of the way. How do you get to that neat individual-by-marker matrix in the first place, how do you deal with missing data and data from different sources, what and when do you measure, what do you do with the predictions … But you knew that already.</p>
<p>Postat i:<a rel="nofollow" href="https://martinsbioblogg.wordpress.com/category/computer-stuff/" target="_blank">computer stuff</a>, <a rel="nofollow" href="https://martinsbioblogg.wordpress.com/category/data-analysis/" target="_blank">data analysis</a>, <a rel="nofollow" href="https://martinsbioblogg.wordpress.com/category/english/" target="_blank">english</a>, <a rel="nofollow" href="https://martinsbioblogg.wordpress.com/category/genetik/" target="_blank">genetik</a> Tagged: <a rel="nofollow" href="https://martinsbioblogg.wordpress.com/tag/sods17/" target="_blank">#SoDS17</a>, <a rel="nofollow" href="https://martinsbioblogg.wordpress.com/tag/genomic-prediction/" target="_blank">genomic prediction</a>, <a rel="nofollow" href="https://martinsbioblogg.wordpress.com/tag/genomic-selection/" target="_blank">genomic selection</a>, <a rel="nofollow" href="https://martinsbioblogg.wordpress.com/tag/r/" target="_blank">R</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/martinsbioblogg.wordpress.com/5285/" target="_blank"><img border="0" alt="" src="http://feeds.wordpress.com/1.0/delicious/martinsbioblogg.wordpress.com/5285/"></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/martinsbioblogg.wordpress.com/5285/" target="_blank"><img border="0" alt="" src="http://feeds.wordpress.com/1.0/facebook/martinsbioblogg.wordpress.com/5285/"></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/martinsbioblogg.wordpress.com/5285/" target="_blank"><img border="0" alt="" src="http://feeds.wordpress.com/1.0/twitter/martinsbioblogg.wordpress.com/5285/"></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/martinsbioblogg.wordpress.com/5285/" target="_blank"><img border="0" alt="" src="http://feeds.wordpress.com/1.0/stumble/martinsbioblogg.wordpress.com/5285/"></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/martinsbioblogg.wordpress.com/5285/" target="_blank"><img border="0" alt="" src="http://feeds.wordpress.com/1.0/digg/martinsbioblogg.wordpress.com/5285/"></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/martinsbioblogg.wordpress.com/5285/" target="_blank"><img border="0" alt="" src="http://feeds.wordpress.com/1.0/reddit/martinsbioblogg.wordpress.com/5285/"></a> <img border="0" alt="" src="https://i1.wp.com/pixel.wp.com/b.gif?resize=1%2C1&ssl=1" data-recalc-dims="1"></p>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://martinsbioblogg.wordpress.com/2017/07/09/summer-of-data-science-1-genomic-prediction-machines-sods17/"> R – On unicorns and genes</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/GNAu0aUGZ1Q" height="1"></a></div>