<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="https://www.r-bloggers.com/conditional-ggplot2-geoms-in-functions-qtl-plots/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://shiring.github.io/ggplot2/2017/02/12/qtl_plots"> Shirin's playgRound</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>When running an analysis, I am usually combining functions from multiple packages. Most of these packages come with their own plotting functions. And while they are certainly convenient in that they allow me to get a quick glance at the data or the output, they all have their own style. If I want to prepare a report, proposal or a paper though, I want all my plots to come from a single cast so that they give a consistent feel to the story I want to tell with my data.</p>
<p>I have grown very fond of ggplot2 for producing plots, because of it’s tidy grammar, flexibility and easy customization. Here, I want to show an example of my own ggplot2 function to produce QTL plots for <a target="_blank" rel="nofollow" href="http://www.rqtl.org/">Karl Broman’s qtl package</a>.</p>
<p>Specifically, I want to show how to incorporate conditional geoms when using ggplot2 in a function call.</p>
<p>I will show how my function can be used with the output from qtl’s <strong>scanone()</strong> function by following the examples from the <a target="_blank" rel="nofollow" href="http://www.rqtl.org/tutorials/rqtltour.pdf">package tutorial</a>. The tutorial does an excellent job describing the workflow, so I am not going to explain it here.</p>
<div>
<pre><code><span>library</span><span>(</span><span>qtl</span><span>)</span><span>
</span></code></pre>
</div>
<p></p>
<p>For defining the function and preparing the data for plotting, I am working with ggplot2, ggrepel (for adding text labels that don’t overlap), tidyr and dplyr. This is my function code:</p>
<div>
<pre><code><span>library</span><span>(</span><span>ggplot2</span><span>)</span><span>
</span><span>library</span><span>(</span><span>ggrepel</span><span>)</span><span>
</span><span>library</span><span>(</span><span>tidyr</span><span>)</span><span>
</span><span>library</span><span>(</span><span>dplyr</span><span>)</span><span>
</span><span>qtl_plot</span><span> </span><span>&lt;-</span><span> </span><span>function</span><span>(</span><span>input</span><span>,</span><span> </span><span># data frame input from scanone
</span><span> </span><span>mult.pheno</span><span> </span><span>=</span><span> </span><span>FALSE</span><span>,</span><span> </span><span># multiple phenotypes?
</span><span> </span><span>model</span><span> </span><span>=</span><span> </span><span>&quot;normal&quot;</span><span>,</span><span> </span><span># model used in scanone
</span><span> </span><span>chrs</span><span> </span><span>=</span><span> </span><span>NA</span><span>,</span><span> </span><span># chromosomes to display
</span><span> </span><span>lod</span><span> </span><span>=</span><span> </span><span>NA</span><span>,</span><span> </span><span># LOD threshold
</span><span> </span><span>rug</span><span> </span><span>=</span><span> </span><span>FALSE</span><span>,</span><span> </span><span># plot marker positions as rug?
</span><span> </span><span>ncol</span><span> </span><span>=</span><span> </span><span>NA</span><span>,</span><span> </span><span># number of columns for facetting
</span><span> </span><span>labels</span><span> </span><span>=</span><span> </span><span>NA</span><span> </span><span># optional dataframe to plot QTL labels
</span><span> </span><span>)</span><span> </span><span>{</span><span>
</span><span># if we have multiple phenotypes and/or a 2part model, gather input
</span><span> </span><span>if</span><span> </span><span>(</span><span>mult.pheno</span><span> </span><span>&amp;</span><span> </span><span>model</span><span> </span><span>==</span><span> </span><span>&quot;2part&quot;</span><span>)</span><span> </span><span>{</span><span>
</span><span>input</span><span> </span><span>&lt;-</span><span> </span><span>gather</span><span>(</span><span>input</span><span>,</span><span> </span><span>group</span><span>,</span><span> </span><span>lod</span><span>,</span><span> </span><span>grep</span><span>(</span><span>&quot;pheno&quot;</span><span>,</span><span> </span><span>colnames</span><span>(</span><span>input</span><span>)))</span><span>
</span><span>}</span><span> </span><span>else</span><span> </span><span>if</span><span> </span><span>(</span><span>mult.pheno</span><span>)</span><span> </span><span>{</span><span>
</span><span>input</span><span> </span><span>&lt;-</span><span> </span><span>gather</span><span>(</span><span>input</span><span>,</span><span> </span><span>group</span><span>,</span><span> </span><span>lod</span><span>,</span><span> </span><span>grep</span><span>(</span><span>&quot;pheno&quot;</span><span>,</span><span> </span><span>colnames</span><span>(</span><span>input</span><span>)))</span><span>
</span><span>}</span><span> </span><span>else</span><span> </span><span>if</span><span> </span><span>(</span><span>model</span><span> </span><span>==</span><span> </span><span>&quot;2part&quot;</span><span>)</span><span> </span><span>{</span><span>
</span><span>input</span><span> </span><span>&lt;-</span><span> </span><span>gather</span><span>(</span><span>input</span><span>,</span><span> </span><span>method</span><span>,</span><span> </span><span>lod</span><span>,</span><span> </span><span>lod.p.mu</span><span>:</span><span>lod.mu</span><span>)</span><span>
</span><span>}</span><span>
</span><span># if not all chromosomes should be displayed, subset input
</span><span> </span><span>if</span><span> </span><span>(</span><span>!</span><span>is.na</span><span>(</span><span>chrs</span><span>)[</span><span>1</span><span>])</span><span> </span><span>{</span><span>
</span><span>input</span><span> </span><span>&lt;-</span><span> </span><span>input</span><span>[</span><span>as.character</span><span>(</span><span>input</span><span>$</span><span>chr</span><span>)</span><span> </span><span>%in%</span><span> </span><span>chrs</span><span>,</span><span> </span><span>]</span><span>
</span><span>}</span><span>
</span><span># if there is more than one LOD column, gather input
</span><span> </span><span>if</span><span> </span><span>(</span><span>!</span><span>any</span><span>(</span><span>colnames</span><span>(</span><span>input</span><span>)</span><span> </span><span>==</span><span> </span><span>&quot;lod&quot;</span><span>))</span><span> </span><span>{</span><span>
</span><span>input</span><span>$</span><span>lod</span><span> </span><span>&lt;-</span><span> </span><span>input</span><span>[,</span><span> </span><span>grep</span><span>(</span><span>&quot;lod&quot;</span><span>,</span><span> </span><span>colnames</span><span>(</span><span>input</span><span>))]</span><span>
</span><span>}</span><span>
</span><span># if no number of columns for facetting is defined, plot all in one row
</span><span> </span><span>if</span><span> </span><span>(</span><span>is.na</span><span>(</span><span>ncol</span><span>))</span><span> </span><span>{</span><span>
</span><span>ncol</span><span> </span><span>&lt;-</span><span> </span><span>length</span><span>(</span><span>unique</span><span>(</span><span>input</span><span>$</span><span>chr</span><span>))</span><span>
</span><span>}</span><span>
</span><span># if labels are set and there is no name column, set from rownames
</span><span> </span><span>if</span><span> </span><span>(</span><span>!</span><span>is.na</span><span>(</span><span>labels</span><span>)[</span><span>1</span><span>])</span><span> </span><span>{</span><span>
</span><span>if</span><span> </span><span>(</span><span>is.null</span><span>(</span><span>labels</span><span>$</span><span>name</span><span>))</span><span> </span><span>{</span><span>
</span><span>labels</span><span>$</span><span>name</span><span> </span><span>&lt;-</span><span> </span><span>rownames</span><span>(</span><span>labels</span><span>)</span><span>
</span><span>}</span><span>
</span><span>}</span><span>
</span><span># plot input data frame position and LOD score
</span><span> </span><span>plot</span><span> </span><span>&lt;-</span><span> </span><span>ggplot</span><span>(</span><span>input</span><span>,</span><span> </span><span>aes</span><span>(</span><span>x</span><span> </span><span>=</span><span> </span><span>pos</span><span>,</span><span> </span><span>y</span><span> </span><span>=</span><span> </span><span>lod</span><span>))</span><span> </span><span>+</span><span> </span><span>{</span><span>
</span><span># if LOD threshold is given, plot as horizontal line
</span><span> </span><span>if</span><span> </span><span>(</span><span>!</span><span>is.na</span><span>(</span><span>lod</span><span>)[</span><span>1</span><span>]</span><span> </span><span>&amp;</span><span> </span><span>length</span><span>(</span><span>lod</span><span>)</span><span> </span><span>==</span><span> </span><span>1</span><span>)</span><span> </span><span>geom_hline</span><span>(</span><span>yintercept</span><span> </span><span>=</span><span> </span><span>lod</span><span>,</span><span> </span><span>linetype</span><span> </span><span>=</span><span> </span><span>&quot;dashed&quot;</span><span>)</span><span>
</span><span>}</span><span> </span><span>+</span><span> </span><span>{</span><span>
</span><span>if</span><span> </span><span>(</span><span>!</span><span>is.na</span><span>(</span><span>lod</span><span>)[</span><span>1</span><span>]</span><span> </span><span>&amp;</span><span> </span><span>length</span><span>(</span><span>lod</span><span>)</span><span> </span><span>></span><span> </span><span>1</span><span>)</span><span> </span><span>geom_hline</span><span>(</span><span>data</span><span> </span><span>=</span><span> </span><span>lod</span><span>,</span><span> </span><span>aes</span><span>(</span><span>yintercept</span><span> </span><span>=</span><span> </span><span>lod</span><span>,</span><span> </span><span>linetype</span><span> </span><span>=</span><span> </span><span>group</span><span>))</span><span>
</span><span>}</span><span> </span><span>+</span><span> </span><span>{</span><span>
</span><span># plot rug on bottom, if TRUE
</span><span> </span><span>if</span><span> </span><span>(</span><span>rug</span><span>)</span><span> </span><span>geom_rug</span><span>(</span><span>size</span><span> </span><span>=</span><span> </span><span>0.1</span><span>,</span><span> </span><span>sides</span><span> </span><span>=</span><span> </span><span>&quot;b&quot;</span><span>)</span><span>
</span><span>}</span><span> </span><span>+</span><span> </span><span>{</span><span>
</span><span># if input has column method but not group, plot line and color by method
</span><span> </span><span>if</span><span> </span><span>(</span><span>!</span><span>is.null</span><span>(</span><span>input</span><span>$</span><span>method</span><span>)</span><span> </span><span>&amp;</span><span> </span><span>is.null</span><span>(</span><span>input</span><span>$</span><span>group</span><span>))</span><span> </span><span>geom_line</span><span>(</span><span>aes</span><span>(</span><span>color</span><span> </span><span>=</span><span> </span><span>method</span><span>),</span><span> </span><span>size</span><span> </span><span>=</span><span> </span><span>2</span><span>,</span><span> </span><span>alpha</span><span> </span><span>=</span><span> </span><span>0.6</span><span>)</span><span>
</span><span>}</span><span> </span><span>+</span><span> </span><span>{</span><span>
</span><span># if input has column group but not method, plot line and color by group
</span><span> </span><span>if</span><span> </span><span>(</span><span>!</span><span>is.null</span><span>(</span><span>input</span><span>$</span><span>group</span><span>)</span><span> </span><span>&amp;</span><span> </span><span>is.null</span><span>(</span><span>input</span><span>$</span><span>method</span><span>))</span><span> </span><span>geom_line</span><span>(</span><span>aes</span><span>(</span><span>color</span><span> </span><span>=</span><span> </span><span>group</span><span>),</span><span> </span><span>size</span><span> </span><span>=</span><span> </span><span>2</span><span>,</span><span> </span><span>alpha</span><span> </span><span>=</span><span> </span><span>0.6</span><span>)</span><span>
</span><span>}</span><span> </span><span>+</span><span> </span><span>{</span><span>
</span><span># if input has columns method and group, plot line and color by method &amp; linetype by group
</span><span> </span><span>if</span><span> </span><span>(</span><span>!</span><span>is.null</span><span>(</span><span>input</span><span>$</span><span>group</span><span>)</span><span> </span><span>&amp;</span><span> </span><span>!</span><span>is.null</span><span>(</span><span>input</span><span>$</span><span>method</span><span>))</span><span> </span><span>geom_line</span><span>(</span><span>aes</span><span>(</span><span>color</span><span> </span><span>=</span><span> </span><span>method</span><span>,</span><span> </span><span>linetype</span><span> </span><span>=</span><span> </span><span>group</span><span>),</span><span> </span><span>size</span><span> </span><span>=</span><span> </span><span>2</span><span>,</span><span> </span><span>alpha</span><span> </span><span>=</span><span> </span><span>0.6</span><span>)</span><span>
</span><span>}</span><span> </span><span>+</span><span> </span><span>{</span><span>
</span><span># set linetype, if input has columns method and group
</span><span> </span><span>if</span><span> </span><span>(</span><span>!</span><span>is.null</span><span>(</span><span>input</span><span>$</span><span>group</span><span>)</span><span> </span><span>&amp;</span><span> </span><span>!</span><span>is.null</span><span>(</span><span>input</span><span>$</span><span>method</span><span>))</span><span> </span><span>scale_linetype_manual</span><span>(</span><span>values</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>&quot;solid&quot;</span><span>,</span><span> </span><span>&quot;twodash&quot;</span><span>,</span><span> </span><span>&quot;dotted&quot;</span><span>))</span><span>
</span><span>}</span><span> </span><span>+</span><span> </span><span>{</span><span>
</span><span># if input has neither columns method nor group, plot black line
</span><span> </span><span>if</span><span> </span><span>(</span><span>is.null</span><span>(</span><span>input</span><span>$</span><span>group</span><span>)</span><span> </span><span>&amp;</span><span> </span><span>is.null</span><span>(</span><span>input</span><span>$</span><span>method</span><span>))</span><span> </span><span>geom_line</span><span>(</span><span>size</span><span> </span><span>=</span><span> </span><span>2</span><span>,</span><span> </span><span>alpha</span><span> </span><span>=</span><span> </span><span>0.6</span><span>)</span><span>
</span><span>}</span><span> </span><span>+</span><span> </span><span>{</span><span>
</span><span># if QTL positions are given in labels df, plot as point...
</span><span> </span><span>if</span><span> </span><span>(</span><span>!</span><span>is.na</span><span>(</span><span>labels</span><span>)[</span><span>1</span><span>])</span><span> </span><span>geom_point</span><span>(</span><span>data</span><span> </span><span>=</span><span> </span><span>labels</span><span>,</span><span> </span><span>aes</span><span>(</span><span>x</span><span> </span><span>=</span><span> </span><span>pos</span><span>,</span><span> </span><span>y</span><span> </span><span>=</span><span> </span><span>lod</span><span>))</span><span>
</span><span>}</span><span> </span><span>+</span><span> </span><span>{</span><span>
</span><span># ... and plot name as text with ggrepel to avoid overlapping
</span><span> </span><span>if</span><span> </span><span>(</span><span>!</span><span>is.na</span><span>(</span><span>labels</span><span>)[</span><span>1</span><span>])</span><span> </span><span>geom_text_repel</span><span>(</span><span>data</span><span> </span><span>=</span><span> </span><span>labels</span><span>,</span><span> </span><span>aes</span><span>(</span><span>x</span><span> </span><span>=</span><span> </span><span>pos</span><span>,</span><span> </span><span>y</span><span> </span><span>=</span><span> </span><span>lod</span><span>,</span><span> </span><span>label</span><span> </span><span>=</span><span> </span><span>name</span><span>),</span><span> </span><span>nudge_y</span><span> </span><span>=</span><span> </span><span>0.5</span><span>)</span><span>
</span><span>}</span><span> </span><span>+</span><span> </span><span># facet by chromosome
</span><span> </span><span>facet_wrap</span><span>(</span><span>~</span><span> </span><span>chr</span><span>,</span><span> </span><span>ncol</span><span> </span><span>=</span><span> </span><span>ncol</span><span>,</span><span> </span><span>scales</span><span> </span><span>=</span><span> </span><span>&quot;free_x&quot;</span><span>)</span><span> </span><span>+</span><span>
</span><span># minimal plotting theme
</span><span> </span><span>theme_minimal</span><span>()</span><span> </span><span>+</span><span>
</span><span># increase strip title size
</span><span> </span><span>theme</span><span>(</span><span>strip.text</span><span> </span><span>=</span><span> </span><span>element_text</span><span>(</span><span>face</span><span> </span><span>=</span><span> </span><span>&quot;bold&quot;</span><span>,</span><span> </span><span>size</span><span> </span><span>=</span><span> </span><span>12</span><span>))</span><span> </span><span>+</span><span>
</span><span># use RcolorBrewer palette
</span><span> </span><span>scale_color_brewer</span><span>(</span><span>palette</span><span> </span><span>=</span><span> </span><span>&quot;Set1&quot;</span><span>)</span><span> </span><span>+</span><span>
</span><span># Change plot labels
</span><span> </span><span>labs</span><span>(</span><span>x</span><span> </span><span>=</span><span> </span><span>&quot;Chromosome&quot;</span><span>,</span><span>
</span><span>y</span><span> </span><span>=</span><span> </span><span>&quot;LOD&quot;</span><span>,</span><span>
</span><span>color</span><span> </span><span>=</span><span> </span><span>&quot;&quot;</span><span>,</span><span>
</span><span>linetype</span><span> </span><span>=</span><span> </span><span>&quot;&quot;</span><span>)</span><span>
</span><span>print</span><span>(</span><span>plot</span><span>)</span><span>
</span><span>}</span><span>
</span></code></pre>
</div>
<p></p>
<p>The first example uses the <em>hyper</em> data set and builds a simple QTL model with three modeling functions: the EM algorithm, Haley-Knott regression and multiple imputation. The genome wide LOD threshold is calculated with permutation. Feeding this LOD threshold into the summary output gives us the markers with a significant phenotype association (i.e. the QTL).</p>
<div>
<pre><code><span>data</span><span>(</span><span>hyper</span><span>)</span><span>
</span><span>hyper</span><span> </span><span>&lt;-</span><span> </span><span>est.rf</span><span>(</span><span>hyper</span><span>)</span><span>
</span><span>hyper</span><span> </span><span>&lt;-</span><span> </span><span>calc.genoprob</span><span>(</span><span>hyper</span><span>,</span><span> </span><span>step</span><span> </span><span>=</span><span> </span><span>1</span><span>,</span><span> </span><span>error.prob</span><span> </span><span>=</span><span> </span><span>0.01</span><span>)</span><span>
</span><span>out.em</span><span> </span><span>&lt;-</span><span> </span><span>scanone</span><span>(</span><span>hyper</span><span>,</span><span> </span><span>model</span><span> </span><span>=</span><span> </span><span>&quot;normal&quot;</span><span>)</span><span>
</span><span>out.hk</span><span> </span><span>&lt;-</span><span> </span><span>scanone</span><span>(</span><span>hyper</span><span>,</span><span> </span><span>method</span><span> </span><span>=</span><span> </span><span>&quot;hk&quot;</span><span>,</span><span> </span><span>model</span><span> </span><span>=</span><span> </span><span>&quot;normal&quot;</span><span>)</span><span>
</span><span>hyper</span><span> </span><span>&lt;-</span><span> </span><span>sim.geno</span><span>(</span><span>hyper</span><span>,</span><span> </span><span>step</span><span> </span><span>=</span><span> </span><span>2</span><span>,</span><span> </span><span>n.draws</span><span> </span><span>=</span><span> </span><span>16</span><span>,</span><span> </span><span>error.prob</span><span> </span><span>=</span><span> </span><span>0.01</span><span>)</span><span>
</span><span>out.imp</span><span> </span><span>&lt;-</span><span> </span><span>scanone</span><span>(</span><span>hyper</span><span>,</span><span> </span><span>method</span><span> </span><span>=</span><span> </span><span>&quot;imp&quot;</span><span>,</span><span> </span><span>model</span><span> </span><span>=</span><span> </span><span>&quot;normal&quot;</span><span>)</span><span>
</span><span>operm.hk</span><span> </span><span>&lt;-</span><span> </span><span>scanone</span><span>(</span><span>hyper</span><span>,</span><span> </span><span>pheno.col</span><span> </span><span>=</span><span> </span><span>1</span><span>,</span><span> </span><span>model</span><span> </span><span>=</span><span> </span><span>&quot;normal&quot;</span><span>,</span><span> </span><span>method</span><span> </span><span>=</span><span> </span><span>&quot;hk&quot;</span><span>,</span><span> </span><span>n.perm</span><span> </span><span>=</span><span> </span><span>1000</span><span>,</span><span> </span><span>verbose</span><span> </span><span>=</span><span> </span><span>FALSE</span><span>)</span><span>
</span><span>lod_threshold</span><span> </span><span>&lt;-</span><span> </span><span>summary</span><span>(</span><span>operm.hk</span><span>,</span><span> </span><span>alpha</span><span> </span><span>=</span><span> </span><span>0.05</span><span>)</span><span>
</span><span>labels_df</span><span> </span><span>&lt;-</span><span> </span><span>as.data.frame</span><span>(</span><span>summary</span><span>(</span><span>out.hk</span><span>,</span><span> </span><span>perms</span><span> </span><span>=</span><span> </span><span>operm.hk</span><span>,</span><span> </span><span>alpha</span><span> </span><span>=</span><span> </span><span>0.05</span><span>,</span><span> </span><span>pvalues</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>))</span><span>
</span></code></pre>
</div>
<p>The most basic version of my plotting function takes as input a data frame from the <strong>scanone()</strong> function: It needs to have a column with chromosome information, position and LOD score. Without defining anything else, the function will return a line plot of the LOD scores for each marker position on each chromosome in the input data.</p>
<div>
<pre><code><span>qtl_plot</span><span>(</span><span>input</span><span> </span><span>=</span><span> </span><span>out.hk</span><span>)</span><span>
</span></code></pre>
</div>
<p><img alt="" src="https://i0.wp.com/shiring.github.io/ggplot2/2017/02/12/qtl_plots_files/figure-markdown_github/unnamed-chunk-4-1.png?w=456&ssl=1" data-recalc-dims="1"></p>
<p>If we want to compare the output from e.g. different QTL models, we can follow the tidyverse principle by combining the output data frames in long format and adding a column with the respective method names. If the input has a <em>method</em> column, it will color the lines accordingly. We can also specify, which chromosomes to display (here, 1 and 4) and give a LOD threshold to plot as a horizontal dashed line. If we want to see each marker position, we can specify <em>rug = TRUE</em> to plot them underneath the line plots.</p>
<p>And we can also plot the markers with a significant phenotype association (the QTL) by adding a data frame with the labeling information to the function call. This data frame needs to contain the chromosome, position and LOD score information. If there is no <em>name</em> column, it will take the row names (which usually give the marker name) as labels.</p>
<div>
<pre><code><span>qtl_plot</span><span>(</span><span>input</span><span> </span><span>=</span><span> </span><span>rbind</span><span>(</span><span>data.frame</span><span>(</span><span>out.em</span><span>,</span><span> </span><span>method</span><span> </span><span>=</span><span> </span><span>&quot;EM algorithm&quot;</span><span>),</span><span> </span><span>data.frame</span><span>(</span><span>out.hk</span><span>,</span><span> </span><span>method</span><span> </span><span>=</span><span> </span><span>&quot;Haley-Knott regression&quot;</span><span>),</span><span> </span><span>data.frame</span><span>(</span><span>out.imp</span><span>,</span><span> </span><span>method</span><span> </span><span>=</span><span> </span><span>&quot;Multiple imputation&quot;</span><span>)),</span><span> </span><span>chrs</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>1</span><span>,</span><span> </span><span>4</span><span>),</span><span> </span><span>lod</span><span> </span><span>=</span><span> </span><span>lod_threshold</span><span>[</span><span>1</span><span>],</span><span> </span><span>rug</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>,</span><span> </span><span>labels</span><span> </span><span>=</span><span> </span><span>labels_df</span><span>)</span><span>
</span></code></pre>
</div>
<p><img alt="" src="https://i1.wp.com/shiring.github.io/ggplot2/2017/02/12/qtl_plots_files/figure-markdown_github/unnamed-chunk-5-1.png?w=456&ssl=1" data-recalc-dims="1"></p>
<p></p>
<p>The second example I want to show is from the <em>listeria</em> data. This time, a slightly more complex <em>2-part</em> model is built.</p>
<div>
<pre><code><span>data</span><span>(</span><span>listeria</span><span>)</span><span>
</span><span>listeria</span><span>$</span><span>pheno</span><span>$</span><span>logSurv</span><span> </span><span>&lt;-</span><span> </span><span>log</span><span>(</span><span>listeria</span><span>$</span><span>pheno</span><span>[,</span><span>1</span><span>])</span><span>
</span><span>listeria</span><span> </span><span>&lt;-</span><span> </span><span>est.rf</span><span>(</span><span>listeria</span><span>)</span><span>
</span><span>newmap</span><span> </span><span>&lt;-</span><span> </span><span>est.map</span><span>(</span><span>listeria</span><span>,</span><span> </span><span>error.prob</span><span> </span><span>=</span><span> </span><span>0.01</span><span>)</span><span>
</span><span>listeria</span><span> </span><span>&lt;-</span><span> </span><span>replace.map</span><span>(</span><span>listeria</span><span>,</span><span> </span><span>newmap</span><span>)</span><span>
</span><span>listeria</span><span> </span><span>&lt;-</span><span> </span><span>calc.errorlod</span><span>(</span><span>listeria</span><span>,</span><span> </span><span>error.prob</span><span> </span><span>=</span><span> </span><span>0.01</span><span>)</span><span>
</span><span>listeria</span><span> </span><span>&lt;-</span><span> </span><span>calc.genoprob</span><span>(</span><span>listeria</span><span>,</span><span> </span><span>step</span><span> </span><span>=</span><span> </span><span>2</span><span>)</span><span>
</span><span>out.2p</span><span> </span><span>&lt;-</span><span> </span><span>scanone</span><span>(</span><span>listeria</span><span>,</span><span> </span><span>pheno.col</span><span> </span><span>=</span><span> </span><span>3</span><span>,</span><span> </span><span>model</span><span> </span><span>=</span><span> </span><span>&quot;2part&quot;</span><span>,</span><span> </span><span>upper</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>)</span><span>
</span><span>operm.2p</span><span> </span><span>&lt;-</span><span> </span><span>scanone</span><span>(</span><span>listeria</span><span>,</span><span> </span><span>model</span><span> </span><span>=</span><span> </span><span>&quot;2part&quot;</span><span>,</span><span> </span><span>pheno.col</span><span> </span><span>=</span><span> </span><span>3</span><span>,</span><span> </span><span>upper</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>,</span><span> </span><span>n.perm</span><span> </span><span>=</span><span> </span><span>25</span><span>,</span><span> </span><span>verbose</span><span> </span><span>=</span><span> </span><span>FALSE</span><span>)</span><span>
</span><span>lod_threshold</span><span> </span><span>&lt;-</span><span> </span><span>summary</span><span>(</span><span>operm.2p</span><span>,</span><span> </span><span>alpha</span><span> </span><span>=</span><span> </span><span>0.05</span><span>)</span><span>
</span><span>labels_df</span><span> </span><span>&lt;-</span><span> </span><span>as.data.frame</span><span>(</span><span>summary</span><span>(</span><span>out.2p</span><span>,</span><span> </span><span>format</span><span> </span><span>=</span><span> </span><span>&quot;allpeaks&quot;</span><span>,</span><span> </span><span>perms</span><span> </span><span>=</span><span> </span><span>operm.2p</span><span>,</span><span> </span><span>alpha</span><span> </span><span>=</span><span> </span><span>0.05</span><span>,</span><span> </span><span>pvalues</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>))</span><span>
</span></code></pre>
</div>
<p>The output from a 2-part model looks different than from the other model functions: Instead of only one LOD score column, we now get three columns named <em>lod.pu.mu</em>, <em>lod.p</em> and <em>lod.mu</em> (check back with the tutorial if you want to know what they mean). The plotting function is built so that if you define the model parameter as <em>“2part”</em>, each of the three LOD columns will be plotted in a different color.</p>
<p>If we also want to plot the QTL labels, we need to prepare the label data frame before feeding it into the plotting function:</p>
<div>
<pre><code><span>p.mu</span><span> </span><span>&lt;-</span><span> </span><span>labels_df</span><span>[,</span><span> </span><span>1</span><span>:</span><span>4</span><span>]</span><span>
</span><span>colnames</span><span>(</span><span>p.mu</span><span>)[</span><span>3</span><span>]</span><span> </span><span>&lt;-</span><span> </span><span>&quot;lod&quot;</span><span>
</span><span>p.mu</span><span>$</span><span>name</span><span> </span><span>&lt;-</span><span> </span><span>&quot;p.mu&quot;</span><span>
</span><span>p</span><span> </span><span>&lt;-</span><span> </span><span>labels_df</span><span>[,</span><span> </span><span>c</span><span>(</span><span>1</span><span>,</span><span> </span><span>5</span><span>:</span><span>7</span><span>)]</span><span>
</span><span>colnames</span><span>(</span><span>p</span><span>)[</span><span>3</span><span>]</span><span> </span><span>&lt;-</span><span> </span><span>&quot;lod&quot;</span><span>
</span><span>p</span><span>$</span><span>name</span><span> </span><span>&lt;-</span><span> </span><span>&quot;p&quot;</span><span>
</span><span>mu</span><span> </span><span>&lt;-</span><span> </span><span>labels_df</span><span>[,</span><span> </span><span>c</span><span>(</span><span>1</span><span>,</span><span> </span><span>8</span><span>:</span><span>10</span><span>)]</span><span>
</span><span>colnames</span><span>(</span><span>mu</span><span>)[</span><span>3</span><span>]</span><span> </span><span>&lt;-</span><span> </span><span>&quot;lod&quot;</span><span>
</span><span>mu</span><span>$</span><span>name</span><span> </span><span>&lt;-</span><span> </span><span>&quot;mu&quot;</span><span>
</span><span>labels_df</span><span> </span><span>&lt;-</span><span> </span><span>rbind</span><span>(</span><span>p.mu</span><span>,</span><span> </span><span>p</span><span>,</span><span> </span><span>mu</span><span>)</span><span>
</span></code></pre>
</div>
<p>If the chromosomes are not in the right order, we can reorder the factor labels:</p>
<div>
<pre><code><span>f</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>&quot;1&quot;</span><span>,</span><span> </span><span>&quot;2&quot;</span><span>,</span><span> </span><span>&quot;3&quot;</span><span>,</span><span> </span><span>&quot;4&quot;</span><span>,</span><span> </span><span>&quot;5&quot;</span><span>,</span><span> </span><span>&quot;6&quot;</span><span>,</span><span> </span><span>&quot;7&quot;</span><span>,</span><span> </span><span>&quot;8&quot;</span><span>,</span><span> </span><span>&quot;9&quot;</span><span>,</span><span> </span><span>&quot;10&quot;</span><span>,</span><span> </span><span>&quot;11&quot;</span><span>,</span><span> </span><span>&quot;12&quot;</span><span>,</span><span> </span><span>&quot;13&quot;</span><span>,</span><span> </span><span>&quot;14&quot;</span><span>,</span><span> </span><span>&quot;15&quot;</span><span>,</span><span> </span><span>&quot;16&quot;</span><span>,</span><span> </span><span>&quot;17&quot;</span><span>,</span><span> </span><span>&quot;18&quot;</span><span>,</span><span> </span><span>&quot;19&quot;</span><span>,</span><span> </span><span>&quot;X&quot;</span><span>)</span><span>
</span><span>out.2p</span><span>$</span><span>chr</span><span> </span><span>&lt;-</span><span> </span><span>factor</span><span>(</span><span>out.2p</span><span>$</span><span>chr</span><span>,</span><span> </span><span>levels</span><span> </span><span>=</span><span> </span><span>f</span><span>)</span><span>
</span><span>labels_df</span><span>$</span><span>chr</span><span> </span><span>&lt;-</span><span> </span><span>factor</span><span>(</span><span>labels_df</span><span>$</span><span>chr</span><span>,</span><span> </span><span>levels</span><span> </span><span>=</span><span> </span><span>f</span><span>)</span><span>
</span></code></pre>
</div>
<p>The parameter <em>ncol</em> let’s you define how many facet columns you want to have. Here, I want two rows and three columns to display the six chromosomes I chose for plotting:</p>
<div>
<pre><code><span>qtl_plot</span><span>(</span><span>input</span><span> </span><span>=</span><span> </span><span>out.2p</span><span>,</span><span> </span><span>model</span><span> </span><span>=</span><span> </span><span>&quot;2part&quot;</span><span>,</span><span>
</span><span>chrs</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>1</span><span>,</span><span> </span><span>3</span><span>,</span><span> </span><span>5</span><span>:</span><span>6</span><span>,</span><span> </span><span>13</span><span>,</span><span> </span><span>15</span><span>),</span><span>
</span><span>lod</span><span> </span><span>=</span><span> </span><span>lod_threshold</span><span>[</span><span>1</span><span>],</span><span> </span><span>rug</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>,</span><span> </span><span>ncol</span><span> </span><span>=</span><span> </span><span>3</span><span>,</span><span>
</span><span>labels</span><span> </span><span>=</span><span> </span><span>labels_df</span><span>)</span><span>
</span></code></pre>
</div>
<p><img alt="" src="https://i0.wp.com/shiring.github.io/ggplot2/2017/02/12/qtl_plots_files/figure-markdown_github/unnamed-chunk-9-1.png?w=456&ssl=1" data-recalc-dims="1"></p>
<p></p>
<p>Binary models are again treated the same way as e.g. normal models:</p>
<div>
<pre><code><span>y</span><span> </span><span>&lt;-</span><span> </span><span>listeria</span><span>$</span><span>pheno</span><span>$</span><span>logSurv</span><span>
</span><span>my</span><span> </span><span>&lt;-</span><span> </span><span>max</span><span>(</span><span>y</span><span>,</span><span> </span><span>na.rm</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>)</span><span>
</span><span>z</span><span> </span><span>&lt;-</span><span> </span><span>as.numeric</span><span>(</span><span>y</span><span> </span><span>==</span><span> </span><span>my</span><span>)</span><span>
</span><span>y</span><span>[</span><span>y</span><span> </span><span>==</span><span> </span><span>my</span><span>]</span><span> </span><span>&lt;-</span><span> </span><span>NA</span><span>
</span><span>listeria</span><span>$</span><span>pheno</span><span>$</span><span>logSurv2</span><span> </span><span>&lt;-</span><span> </span><span>y</span><span>
</span><span>listeria</span><span>$</span><span>pheno</span><span>$</span><span>binary</span><span> </span><span>&lt;-</span><span> </span><span>z</span><span>
</span><span>out.p</span><span> </span><span>&lt;-</span><span> </span><span>scanone</span><span>(</span><span>listeria</span><span>,</span><span> </span><span>pheno.col</span><span> </span><span>=</span><span> </span><span>5</span><span>,</span><span> </span><span>model</span><span> </span><span>=</span><span> </span><span>&quot;binary&quot;</span><span>)</span><span>
</span><span>out.np1</span><span> </span><span>&lt;-</span><span> </span><span>scanone</span><span>(</span><span>listeria</span><span>,</span><span> </span><span>model</span><span> </span><span>=</span><span> </span><span>&quot;np&quot;</span><span>,</span><span> </span><span>ties.random</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>)</span><span>
</span><span>out.np2</span><span> </span><span>&lt;-</span><span> </span><span>scanone</span><span>(</span><span>listeria</span><span>,</span><span> </span><span>model</span><span> </span><span>=</span><span> </span><span>&quot;np&quot;</span><span>,</span><span> </span><span>ties.random</span><span> </span><span>=</span><span> </span><span>FALSE</span><span>)</span><span>
</span></code></pre>
</div>
<div>
<pre><code><span>qtl_plot</span><span>(</span><span>input</span><span> </span><span>=</span><span> </span><span>rbind</span><span>(</span><span>data.frame</span><span>(</span><span>out.np1</span><span>,</span><span> </span><span>method</span><span> </span><span>=</span><span> </span><span>&quot;out.2p&quot;</span><span>),</span><span>
</span><span>data.frame</span><span>(</span><span>out.np1</span><span>,</span><span> </span><span>method</span><span> </span><span>=</span><span> </span><span>&quot;np1&quot;</span><span>),</span><span>
</span><span>data.frame</span><span>(</span><span>out.np2</span><span>,</span><span> </span><span>method</span><span> </span><span>=</span><span> </span><span>&quot;np2&quot;</span><span>)))</span><span>
</span></code></pre>
</div>
<p><img alt="" src="https://i2.wp.com/shiring.github.io/ggplot2/2017/02/12/qtl_plots_files/figure-markdown_github/unnamed-chunk-11-1.png?w=456&ssl=1" data-recalc-dims="1"></p>
<p></p>
<p>The <em>fake.bc</em> data is used to show how to run QTL models with multiple phenotypes simultaneously and how to add additive or interactive covariates.</p>
<div>
<pre><code><span>data</span><span>(</span><span>fake.bc</span><span>)</span><span>
</span><span>fake.bc</span><span> </span><span>&lt;-</span><span> </span><span>calc.genoprob</span><span>(</span><span>fake.bc</span><span>,</span><span> </span><span>step</span><span> </span><span>=</span><span> </span><span>2.5</span><span>)</span><span>
</span><span>out.nocovar</span><span> </span><span>&lt;-</span><span> </span><span>scanone</span><span>(</span><span>fake.bc</span><span>,</span><span> </span><span>pheno.col</span><span> </span><span>=</span><span> </span><span>1</span><span>:</span><span>2</span><span>)</span><span>
</span></code></pre>
</div>
<p>If the parameter <em>mult.pheno</em> is set to TRUE, the plotting function gathers the phenotype columns and plots each phenotype in a different color.</p>
<div>
<pre><code><span>qtl_plot</span><span>(</span><span>input</span><span> </span><span>=</span><span> </span><span>out.nocovar</span><span>,</span><span> </span><span>mult.pheno</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>)</span><span>
</span></code></pre>
</div>
<p><img alt="" src="https://i1.wp.com/shiring.github.io/ggplot2/2017/02/12/qtl_plots_files/figure-markdown_github/unnamed-chunk-13-1.png?w=456&ssl=1" data-recalc-dims="1"></p>
<p>If we specify both <em>mult.pheno = TRUE</em> and <em>model = “2part”</em>, the function plots each LOD score for each phenotype in a different color. If you wanted to plot only the <em>lod.p</em> column for example, you could subset the input data frame before feeding it into the plotting function.</p>
<div>
<pre><code><span>out.nocovar.2p</span><span> </span><span>&lt;-</span><span> </span><span>scanone</span><span>(</span><span>fake.bc</span><span>,</span><span> </span><span>pheno.col</span><span> </span><span>=</span><span> </span><span>1</span><span>:</span><span>2</span><span>,</span><span> </span><span>model</span><span> </span><span>=</span><span> </span><span>&quot;2part&quot;</span><span>,</span><span> </span><span>upper</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>)</span><span>
</span><span>qtl_plot</span><span>(</span><span>input</span><span> </span><span>=</span><span> </span><span>out.nocovar.2p</span><span>,</span><span>
</span><span>chrs</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>2</span><span>,</span><span> </span><span>5</span><span>),</span><span>
</span><span>mult.pheno</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>,</span><span> </span><span>model</span><span> </span><span>=</span><span> </span><span>&quot;2part&quot;</span><span>)</span><span>
</span></code></pre>
</div>
<p><img alt="" src="https://i0.wp.com/shiring.github.io/ggplot2/2017/02/12/qtl_plots_files/figure-markdown_github/unnamed-chunk-14-1.png?w=456&ssl=1" data-recalc-dims="1"></p>
<p></p>
<p>If we run a multiple phenotype model and want to determine the QTL positions, we get a different LOD threshold for each of the phenotypes and respectively, for significantly associated markers as well.</p>
<div>
<pre><code><span>sex</span><span> </span><span>&lt;-</span><span> </span><span>fake.bc</span><span>$</span><span>pheno</span><span>$</span><span>sex</span><span>
</span><span>out.acovar</span><span> </span><span>&lt;-</span><span> </span><span>scanone</span><span>(</span><span>fake.bc</span><span>,</span><span> </span><span>pheno.col</span><span> </span><span>=</span><span> </span><span>1</span><span>:</span><span>2</span><span>,</span><span> </span><span>addcovar</span><span> </span><span>=</span><span> </span><span>sex</span><span>)</span><span>
</span><span>out.icovar</span><span> </span><span>&lt;-</span><span> </span><span>scanone</span><span>(</span><span>fake.bc</span><span>,</span><span> </span><span>pheno.col</span><span> </span><span>=</span><span> </span><span>1</span><span>:</span><span>2</span><span>,</span><span> </span><span>addcovar</span><span> </span><span>=</span><span> </span><span>sex</span><span>,</span><span> </span><span>intcovar</span><span> </span><span>=</span><span> </span><span>sex</span><span>)</span><span>
</span><span>out.sexint</span><span> </span><span>&lt;-</span><span> </span><span>out.icovar</span><span> </span><span>-</span><span> </span><span>out.acovar</span><span>
</span><span>operm.icovar</span><span> </span><span>&lt;-</span><span> </span><span>scanone</span><span>(</span><span>fake.bc</span><span>,</span><span> </span><span>pheno.col</span><span> </span><span>=</span><span> </span><span>1</span><span>:</span><span>2</span><span>,</span><span> </span><span>addcovar</span><span> </span><span>=</span><span> </span><span>sex</span><span>,</span><span> </span><span>intcovar</span><span> </span><span>=</span><span> </span><span>sex</span><span>,</span><span> </span><span>n.perm</span><span> </span><span>=</span><span> </span><span>25</span><span>,</span><span> </span><span>verbose</span><span> </span><span>=</span><span> </span><span>FALSE</span><span>)</span><span>
</span><span>lod_threshold</span><span> </span><span>&lt;-</span><span> </span><span>summary</span><span>(</span><span>operm.icovar</span><span>,</span><span> </span><span>alpha</span><span> </span><span>=</span><span> </span><span>0.05</span><span>)</span><span>
</span><span>labels_df</span><span> </span><span>&lt;-</span><span> </span><span>as.data.frame</span><span>(</span><span>summary</span><span>(</span><span>out.icovar</span><span>,</span><span> </span><span>perms</span><span> </span><span>=</span><span> </span><span>operm.icovar</span><span>,</span><span> </span><span>alpha</span><span> </span><span>=</span><span> </span><span>0.05</span><span>,</span><span> </span><span>pvalues</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>))</span><span>
</span></code></pre>
</div>
<p>This means that, if we want to plot QTL labels for both phenotypes, we first need to prepare the label data frame:</p>
<div>
<pre><code><span>pheno1</span><span> </span><span>&lt;-</span><span> </span><span>labels_df</span><span>[,</span><span> </span><span>1</span><span>:</span><span>4</span><span>]</span><span>
</span><span>colnames</span><span>(</span><span>pheno1</span><span>)[</span><span>3</span><span>]</span><span> </span><span>&lt;-</span><span> </span><span>&quot;lod&quot;</span><span>
</span><span>pheno1</span><span>$</span><span>name</span><span> </span><span>&lt;-</span><span> </span><span>paste</span><span>(</span><span>&quot;pheno1&quot;</span><span>,</span><span> </span><span>rownames</span><span>(</span><span>pheno1</span><span>),</span><span> </span><span>sep</span><span> </span><span>=</span><span> </span><span>&quot;\n&quot;</span><span>)</span><span>
</span><span>pheno2</span><span> </span><span>&lt;-</span><span> </span><span>labels_df</span><span>[,</span><span> </span><span>c</span><span>(</span><span>1</span><span>,</span><span> </span><span>2</span><span>,</span><span> </span><span>5</span><span>,</span><span> </span><span>6</span><span>)]</span><span>
</span><span>colnames</span><span>(</span><span>pheno2</span><span>)[</span><span>3</span><span>]</span><span> </span><span>&lt;-</span><span> </span><span>&quot;lod&quot;</span><span>
</span><span>pheno2</span><span>$</span><span>name</span><span> </span><span>&lt;-</span><span> </span><span>paste</span><span>(</span><span>&quot;pheno2&quot;</span><span>,</span><span> </span><span>rownames</span><span>(</span><span>pheno1</span><span>),</span><span> </span><span>sep</span><span> </span><span>=</span><span> </span><span>&quot;\n&quot;</span><span>)</span><span>
</span><span>labels_df</span><span> </span><span>&lt;-</span><span> </span><span>rbind</span><span>(</span><span>pheno1</span><span>,</span><span> </span><span>pheno2</span><span>)</span><span>
</span><span>f</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>&quot;1&quot;</span><span>,</span><span> </span><span>&quot;2&quot;</span><span>,</span><span> </span><span>&quot;3&quot;</span><span>,</span><span> </span><span>&quot;4&quot;</span><span>,</span><span> </span><span>&quot;5&quot;</span><span>,</span><span> </span><span>&quot;6&quot;</span><span>,</span><span> </span><span>&quot;7&quot;</span><span>,</span><span> </span><span>&quot;8&quot;</span><span>,</span><span> </span><span>&quot;9&quot;</span><span>,</span><span> </span><span>&quot;10&quot;</span><span>,</span><span> </span><span>&quot;11&quot;</span><span>,</span><span> </span><span>&quot;12&quot;</span><span>,</span><span> </span><span>&quot;13&quot;</span><span>,</span><span> </span><span>&quot;14&quot;</span><span>,</span><span> </span><span>&quot;15&quot;</span><span>,</span><span> </span><span>&quot;16&quot;</span><span>,</span><span> </span><span>&quot;17&quot;</span><span>,</span><span> </span><span>&quot;18&quot;</span><span>,</span><span> </span><span>&quot;19&quot;</span><span>,</span><span> </span><span>&quot;X&quot;</span><span>)</span><span>
</span><span>labels_df</span><span>$</span><span>chr</span><span> </span><span>&lt;-</span><span> </span><span>factor</span><span>(</span><span>labels_df</span><span>$</span><span>chr</span><span>,</span><span> </span><span>levels</span><span> </span><span>=</span><span> </span><span>f</span><span>)</span><span>
</span></code></pre>
</div>
<p>If different methods and groups are detected in the input data frame, the methods will be drawn with different colors, while the groups will have different line types. If we want to plot two LOD thresholds for the two phenotypes, we can give a data frame to the function that has a group column that corresponds to the phenotypes of the input data frame. The LOD threshold will now be plotted in the same line type as the phenotype LOD score plot.</p>
<div>
<pre><code><span>qtl_plot</span><span>(</span><span>input</span><span> </span><span>=</span><span> </span><span>rbind</span><span>(</span><span>data.frame</span><span>(</span><span>out.acovar</span><span>,</span><span> </span><span>method</span><span> </span><span>=</span><span> </span><span>&quot;acovar&quot;</span><span>),</span><span>
</span><span>data.frame</span><span>(</span><span>out.icovar</span><span>,</span><span> </span><span>method</span><span> </span><span>=</span><span> </span><span>&quot;icovar&quot;</span><span>),</span><span>
</span><span>data.frame</span><span>(</span><span>out.sexint</span><span>,</span><span> </span><span>method</span><span> </span><span>=</span><span> </span><span>&quot;sexint&quot;</span><span>)),</span><span> </span><span>chrs</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>2</span><span>,</span><span> </span><span>5</span><span>,</span><span> </span><span>17</span><span>),</span><span>
</span><span>mult.pheno</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>,</span><span>
</span><span>lod</span><span> </span><span>=</span><span> </span><span>data.frame</span><span>(</span><span>group</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>&quot;pheno1&quot;</span><span>,</span><span> </span><span>&quot;pheno2&quot;</span><span>),</span><span>
</span><span>lod</span><span> </span><span>=</span><span> </span><span>lod_threshold</span><span>[</span><span>1</span><span>:</span><span>2</span><span>]),</span><span>
</span><span>labels</span><span> </span><span>=</span><span> </span><span>labels_df</span><span>)</span><span>
</span></code></pre>
</div>
<p><img alt="" src="https://i1.wp.com/shiring.github.io/ggplot2/2017/02/12/qtl_plots_files/figure-markdown_github/unnamed-chunk-17-1.png?w=456&ssl=1" data-recalc-dims="1"></p>
<p></p>
<p>For QTL models with covariates, the same principles apply:</p>
<div>
<pre><code><span>seed</span><span> </span><span>&lt;-</span><span> </span><span>ceiling</span><span>(</span><span>runif</span><span>(</span><span>1</span><span>,</span><span> </span><span>0</span><span>,</span><span> </span><span>10</span><span>^</span><span>8</span><span>))</span><span>
</span><span>set.seed</span><span>(</span><span>seed</span><span>)</span><span>
</span><span>operm.acovar</span><span> </span><span>&lt;-</span><span> </span><span>scanone</span><span>(</span><span>fake.bc</span><span>,</span><span> </span><span>pheno.col</span><span> </span><span>=</span><span> </span><span>1</span><span>:</span><span>2</span><span>,</span><span> </span><span>addcovar</span><span> </span><span>=</span><span> </span><span>sex</span><span>,</span><span> </span><span>method</span><span> </span><span>=</span><span> </span><span>&quot;hk&quot;</span><span>,</span><span> </span><span>n.perm</span><span> </span><span>=</span><span> </span><span>100</span><span>,</span><span> </span><span>verbose</span><span> </span><span>=</span><span> </span><span>FALSE</span><span>)</span><span>
</span><span>set.seed</span><span>(</span><span>seed</span><span>)</span><span>
</span><span>operm.icovar</span><span> </span><span>&lt;-</span><span> </span><span>scanone</span><span>(</span><span>fake.bc</span><span>,</span><span> </span><span>pheno.col</span><span> </span><span>=</span><span> </span><span>1</span><span>:</span><span>2</span><span>,</span><span> </span><span>addcovar</span><span> </span><span>=</span><span> </span><span>sex</span><span>,</span><span> </span><span>intcovar</span><span> </span><span>=</span><span> </span><span>sex</span><span>,</span><span> </span><span>method</span><span> </span><span>=</span><span> </span><span>&quot;hk&quot;</span><span>,</span><span> </span><span>n.perm</span><span> </span><span>=</span><span> </span><span>100</span><span>,</span><span> </span><span>verbose</span><span> </span><span>=</span><span> </span><span>FALSE</span><span>)</span><span>
</span><span>operm.sexint</span><span> </span><span>&lt;-</span><span> </span><span>operm.icovar</span><span> </span><span>-</span><span> </span><span>operm.acovar</span><span>
</span><span>lod_threshold</span><span> </span><span>&lt;-</span><span> </span><span>summary</span><span>(</span><span>operm.sexint</span><span>,</span><span> </span><span>alpha</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>0.05</span><span>,</span><span> </span><span>0.20</span><span>))</span><span>
</span></code></pre>
</div>
<div>
<pre><code><span>labels</span><span> </span><span>&lt;-</span><span> </span><span>as.data.frame</span><span>(</span><span>summary</span><span>(</span><span>out.sexint</span><span>,</span><span> </span><span>perms</span><span> </span><span>=</span><span> </span><span>operm.sexint</span><span>,</span><span> </span><span>alpha</span><span> </span><span>=</span><span> </span><span>0.1</span><span>,</span><span> </span><span>format</span><span> </span><span>=</span><span> </span><span>&quot;allpeaks&quot;</span><span>,</span><span> </span><span>pvalues</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>))</span><span>
</span><span>pheno1</span><span> </span><span>&lt;-</span><span> </span><span>data.frame</span><span>(</span><span>labels</span><span>[,</span><span> </span><span>1</span><span>:</span><span>4</span><span>])</span><span>
</span><span>colnames</span><span>(</span><span>pheno1</span><span>)[</span><span>3</span><span>]</span><span> </span><span>&lt;-</span><span> </span><span>&quot;lod&quot;</span><span>
</span><span>pheno1</span><span>$</span><span>name</span><span> </span><span>&lt;-</span><span> </span><span>&quot;p1&quot;</span><span>
</span><span>pheno2</span><span> </span><span>&lt;-</span><span> </span><span>data.frame</span><span>(</span><span>labels</span><span>[,</span><span> </span><span>c</span><span>(</span><span>1</span><span>,</span><span> </span><span>5</span><span>:</span><span>7</span><span>)])</span><span>
</span><span>colnames</span><span>(</span><span>pheno2</span><span>)[</span><span>3</span><span>]</span><span> </span><span>&lt;-</span><span> </span><span>&quot;lod&quot;</span><span>
</span><span>pheno2</span><span>$</span><span>name</span><span> </span><span>&lt;-</span><span> </span><span>&quot;p2&quot;</span><span>
</span><span>labels_df</span><span> </span><span>&lt;-</span><span> </span><span>rbind</span><span>(</span><span>pheno1</span><span>,</span><span> </span><span>pheno2</span><span>)</span><span>
</span></code></pre>
</div>
<div>
<pre><code><span>qtl_plot</span><span>(</span><span>input</span><span> </span><span>=</span><span> </span><span>out.sexint</span><span>,</span><span> </span><span>mult.pheno</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>,</span><span>
</span><span>labels</span><span> </span><span>=</span><span> </span><span>labels_df</span><span>,</span><span>
</span><span>chrs</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>2</span><span>,</span><span> </span><span>7</span><span>,</span><span> </span><span>17</span><span>),</span><span> </span><span>lod</span><span> </span><span>=</span><span> </span><span>data.frame</span><span>(</span><span>group</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>&quot;pheno1&quot;</span><span>,</span><span> </span><span>&quot;pheno2&quot;</span><span>),</span><span>
</span><span>lod</span><span> </span><span>=</span><span> </span><span>lod_threshold</span><span>[</span><span>1</span><span>,</span><span> </span><span>]),</span><span>
</span><span>ncol</span><span> </span><span>=</span><span> </span><span>3</span><span>)</span><span>
</span></code></pre>
</div>
<p><img alt="" src="https://i1.wp.com/shiring.github.io/ggplot2/2017/02/12/qtl_plots_files/figure-markdown_github/unnamed-chunk-20-1.png?w=456&ssl=1" data-recalc-dims="1"></p>
<div>
<pre><code><span>hyper</span><span> </span><span>&lt;-</span><span> </span><span>sim.geno</span><span>(</span><span>hyper</span><span>,</span><span> </span><span>step</span><span> </span><span>=</span><span> </span><span>2.5</span><span>,</span><span> </span><span>n.draws</span><span> </span><span>=</span><span> </span><span>16</span><span>,</span><span> </span><span>err</span><span> </span><span>=</span><span> </span><span>0.01</span><span>)</span><span>
</span><span>g</span><span> </span><span>&lt;-</span><span> </span><span>pull.geno</span><span>(</span><span>fill.geno</span><span>(</span><span>hyper</span><span>))[,</span><span> </span><span>&quot;D4Mit164&quot;</span><span>]</span><span>
</span><span>out1.c4i</span><span> </span><span>&lt;-</span><span> </span><span>scanone</span><span>(</span><span>hyper</span><span>,</span><span> </span><span>method</span><span> </span><span>=</span><span> </span><span>&quot;imp&quot;</span><span>,</span><span> </span><span>addcovar</span><span> </span><span>=</span><span> </span><span>g</span><span>,</span><span> </span><span>intcovar</span><span> </span><span>=</span><span> </span><span>g</span><span>)</span><span>
</span></code></pre>
</div>
<div>
<pre><code><span>qtl_plot</span><span>(</span><span>input</span><span> </span><span>=</span><span> </span><span>out1.c4i</span><span>)</span><span>
</span></code></pre>
</div>
<p><img alt="" src="https://i2.wp.com/shiring.github.io/ggplot2/2017/02/12/qtl_plots_files/figure-markdown_github/unnamed-chunk-22-1.png?w=456&ssl=1" data-recalc-dims="1"></p>
<p></p>
<p>And as well for model fitting:</p>
<div>
<pre><code><span>qc</span><span> </span><span>&lt;-</span><span> </span><span>c</span><span>(</span><span>1</span><span>,</span><span> </span><span>1</span><span>,</span><span> </span><span>4</span><span>,</span><span> </span><span>6</span><span>,</span><span> </span><span>15</span><span>)</span><span>
</span><span>qp</span><span> </span><span>&lt;-</span><span> </span><span>c</span><span>(</span><span>43.3</span><span>,</span><span> </span><span>78.3</span><span>,</span><span> </span><span>30.0</span><span>,</span><span> </span><span>62.5</span><span>,</span><span> </span><span>18.0</span><span>)</span><span>
</span><span>qtl</span><span> </span><span>&lt;-</span><span> </span><span>makeqtl</span><span>(</span><span>hyper</span><span>,</span><span> </span><span>chr</span><span> </span><span>=</span><span> </span><span>qc</span><span>,</span><span> </span><span>pos</span><span> </span><span>=</span><span> </span><span>qp</span><span>)</span><span>
</span></code></pre>
</div>
<div>
<pre><code><span>myformula</span><span> </span><span>&lt;-</span><span> </span><span>y</span><span> </span><span>~</span><span> </span><span>Q</span><span>1</span><span> </span><span>+</span><span> </span><span>Q</span><span>2</span><span> </span><span>+</span><span> </span><span>Q</span><span>3</span><span> </span><span>+</span><span> </span><span>Q</span><span>4</span><span> </span><span>+</span><span> </span><span>Q</span><span>5</span><span> </span><span>+</span><span> </span><span>Q</span><span>4</span><span>:</span><span>Q</span><span>5</span><span>
</span><span>out.fq</span><span> </span><span>&lt;-</span><span> </span><span>fitqtl</span><span>(</span><span>hyper</span><span>,</span><span> </span><span>qtl</span><span> </span><span>=</span><span> </span><span>qtl</span><span>,</span><span> </span><span>formula</span><span> </span><span>=</span><span> </span><span>myformula</span><span>,</span><span> </span><span>drop</span><span> </span><span>=</span><span> </span><span>FALSE</span><span>,</span><span> </span><span>get.ests</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>)</span><span>
</span><span>revqtl</span><span> </span><span>&lt;-</span><span> </span><span>refineqtl</span><span>(</span><span>hyper</span><span>,</span><span> </span><span>qtl</span><span> </span><span>=</span><span> </span><span>qtl</span><span>,</span><span> </span><span>formula</span><span> </span><span>=</span><span> </span><span>myformula</span><span>,</span><span> </span><span>verbose</span><span> </span><span>=</span><span> </span><span>FALSE</span><span>)</span><span>
</span><span>out1.c4r</span><span> </span><span>&lt;-</span><span> </span><span>addqtl</span><span>(</span><span>hyper</span><span>,</span><span> </span><span>qtl</span><span> </span><span>=</span><span> </span><span>revqtl</span><span>,</span><span> </span><span>formula</span><span> </span><span>=</span><span> </span><span>y</span><span> </span><span>~</span><span> </span><span>Q</span><span>3</span><span>)</span><span>
</span><span>out2.c4r</span><span> </span><span>&lt;-</span><span> </span><span>addpair</span><span>(</span><span>hyper</span><span>,</span><span> </span><span>qtl</span><span> </span><span>=</span><span> </span><span>revqtl</span><span>,</span><span> </span><span>formula</span><span> </span><span>=</span><span> </span><span>y</span><span> </span><span>~</span><span> </span><span>Q</span><span>3</span><span>,</span><span> </span><span>chr</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>1</span><span>,</span><span> </span><span>6</span><span>,</span><span> </span><span>7</span><span>,</span><span> </span><span>15</span><span>),</span><span> </span><span>verbose</span><span> </span><span>=</span><span> </span><span>FALSE</span><span>)</span><span>
</span><span>out.iw4</span><span> </span><span>&lt;-</span><span> </span><span>addqtl</span><span>(</span><span>hyper</span><span>,</span><span> </span><span>qtl</span><span> </span><span>=</span><span> </span><span>revqtl</span><span>,</span><span> </span><span>formula</span><span> </span><span>=</span><span> </span><span>y</span><span> </span><span>~</span><span> </span><span>Q</span><span>1</span><span> </span><span>+</span><span> </span><span>Q</span><span>2</span><span> </span><span>+</span><span> </span><span>Q</span><span>3</span><span> </span><span>+</span><span> </span><span>Q</span><span>4</span><span> </span><span>+</span><span> </span><span>Q</span><span>5</span><span> </span><span>+</span><span> </span><span>Q</span><span>4</span><span>:</span><span>Q</span><span>5</span><span> </span><span>+</span><span> </span><span>Q</span><span>6</span><span> </span><span>+</span><span> </span><span>Q</span><span>5</span><span>:</span><span>Q</span><span>6</span><span>)</span><span>
</span><span>out.1more</span><span> </span><span>&lt;-</span><span> </span><span>addqtl</span><span>(</span><span>hyper</span><span>,</span><span> </span><span>qtl</span><span> </span><span>=</span><span> </span><span>revqtl</span><span>,</span><span> </span><span>formula</span><span> </span><span>=</span><span> </span><span>myformula</span><span>)</span><span>
</span><span>qtl2</span><span> </span><span>&lt;-</span><span> </span><span>addtoqtl</span><span>(</span><span>hyper</span><span>,</span><span> </span><span>revqtl</span><span>,</span><span> </span><span>7</span><span>,</span><span> </span><span>53.6</span><span>)</span><span>
</span><span>qtl3</span><span> </span><span>&lt;-</span><span> </span><span>dropfromqtl</span><span>(</span><span>qtl2</span><span>,</span><span> </span><span>index</span><span> </span><span>=</span><span> </span><span>2</span><span>)</span><span>
</span><span>qtl4</span><span> </span><span>&lt;-</span><span> </span><span>replaceqtl</span><span>(</span><span>hyper</span><span>,</span><span> </span><span>qtl3</span><span>,</span><span> </span><span>index</span><span> </span><span>=</span><span> </span><span>1</span><span>,</span><span> </span><span>chr</span><span> </span><span>=</span><span> </span><span>1</span><span>,</span><span> </span><span>pos</span><span> </span><span>=</span><span> </span><span>50</span><span>)</span><span>
</span><span>qtl5</span><span> </span><span>&lt;-</span><span> </span><span>reorderqtl</span><span>(</span><span>qtl4</span><span>,</span><span> </span><span>c</span><span>(</span><span>1</span><span>:</span><span>3</span><span>,</span><span> </span><span>5</span><span>,</span><span> </span><span>4</span><span>))</span><span>
</span><span>stepout.i</span><span> </span><span>&lt;-</span><span> </span><span>stepwiseqtl</span><span>(</span><span>hyper</span><span>,</span><span> </span><span>max.qtl</span><span> </span><span>=</span><span> </span><span>6</span><span>,</span><span> </span><span>verbose</span><span> </span><span>=</span><span> </span><span>FALSE</span><span>)</span><span>
</span></code></pre>
</div>
<p>Here, we also need to prepare the label data frame before the plotting function can handle it:</p>
<div>
<pre><code><span>label_df</span><span> </span><span>&lt;-</span><span> </span><span>data.frame</span><span>(</span><span>name</span><span> </span><span>=</span><span> </span><span>stepout.i</span><span>$</span><span>name</span><span>,</span><span> </span><span>chr</span><span> </span><span>=</span><span> </span><span>stepout.i</span><span>$</span><span>chr</span><span>,</span><span> </span><span>pos</span><span> </span><span>=</span><span> </span><span>stepout.i</span><span>$</span><span>pos</span><span>)</span><span>
</span><span>qtl1</span><span> </span><span>&lt;-</span><span> </span><span>attr</span><span>(</span><span>stepout.i</span><span>,</span><span> </span><span>&quot;lodprofile&quot;</span><span>)[[</span><span>1</span><span>]]</span><span>
</span><span>qtl4</span><span> </span><span>&lt;-</span><span> </span><span>attr</span><span>(</span><span>stepout.i</span><span>,</span><span> </span><span>&quot;lodprofile&quot;</span><span>)[[</span><span>2</span><span>]]</span><span>
</span><span>qtl6</span><span> </span><span>&lt;-</span><span> </span><span>attr</span><span>(</span><span>stepout.i</span><span>,</span><span> </span><span>&quot;lodprofile&quot;</span><span>)[[</span><span>3</span><span>]]</span><span>
</span><span>qtl15</span><span> </span><span>&lt;-</span><span> </span><span>attr</span><span>(</span><span>stepout.i</span><span>,</span><span> </span><span>&quot;lodprofile&quot;</span><span>)[[</span><span>4</span><span>]]</span><span>
</span><span>input_df</span><span> </span><span>&lt;-</span><span> </span><span>rbind</span><span>(</span><span>qtl1</span><span>,</span><span> </span><span>qtl4</span><span>,</span><span> </span><span>qtl6</span><span>,</span><span> </span><span>qtl15</span><span>)</span><span>
</span><span>input_df</span><span>$</span><span>marker</span><span> </span><span>&lt;-</span><span> </span><span>rownames</span><span>(</span><span>input_df</span><span>)</span><span>
</span><span>input_df</span><span>$</span><span>name</span><span> </span><span>&lt;-</span><span> </span><span>paste</span><span>(</span><span>input_df</span><span>$</span><span>chr</span><span>,</span><span> </span><span>round</span><span>(</span><span>input_df</span><span>$</span><span>pos</span><span>,</span><span> </span><span>digits</span><span> </span><span>=</span><span> </span><span>1</span><span>),</span><span> </span><span>sep</span><span> </span><span>=</span><span> </span><span>&quot;@&quot;</span><span>)</span><span>
</span><span>label_df</span><span>$</span><span>pos</span><span> </span><span>&lt;-</span><span> </span><span>as.numeric</span><span>(</span><span>gsub</span><span>(</span><span>&quot;(^[0-9]+)(.0$)&quot;</span><span>,</span><span> </span><span>&quot;\\1&quot;</span><span>,</span><span> </span><span>label_df</span><span>$</span><span>pos</span><span>))</span><span>
</span><span>label_df</span><span>$</span><span>name</span><span> </span><span>&lt;-</span><span> </span><span>paste</span><span>(</span><span>label_df</span><span>$</span><span>chr</span><span>,</span><span> </span><span>round</span><span>(</span><span>label_df</span><span>$</span><span>pos</span><span>,</span><span> </span><span>digits</span><span> </span><span>=</span><span> </span><span>1</span><span>),</span><span> </span><span>sep</span><span> </span><span>=</span><span> </span><span>&quot;@&quot;</span><span>)</span><span>
</span><span>label_df</span><span> </span><span>&lt;-</span><span> </span><span>left_join</span><span>(</span><span>label_df</span><span>,</span><span> </span><span>input_df</span><span>[,</span><span> </span><span>3</span><span>:</span><span>5</span><span>,</span><span> </span><span>drop</span><span> </span><span>=</span><span> </span><span>FALSE</span><span>],</span><span> </span><span>by</span><span> </span><span>=</span><span> </span><span>&quot;name&quot;</span><span>)</span><span>
</span><span>label_df</span><span>$</span><span>name</span><span> </span><span>&lt;-</span><span> </span><span>paste</span><span>(</span><span>label_df</span><span>$</span><span>name</span><span>,</span><span> </span><span>label_df</span><span>$</span><span>marker</span><span>,</span><span> </span><span>sep</span><span> </span><span>=</span><span> </span><span>&quot;\n&quot;</span><span>)</span><span>
</span></code></pre>
</div>
<div>
<pre><code><span>qtl_plot</span><span>(</span><span>input</span><span> </span><span>=</span><span> </span><span>input_df</span><span>,</span><span>
</span><span>labels</span><span> </span><span>=</span><span> </span><span>label_df</span><span>)</span><span>
</span></code></pre>
</div>
<p><img alt="" src="https://i1.wp.com/shiring.github.io/ggplot2/2017/02/12/qtl_plots_files/figure-markdown_github/unnamed-chunk-26-1.png?w=456&ssl=1" data-recalc-dims="1"></p>
<p></p>
<p>These examples show only the simple QTL models. The qtl package also gives examples for building <strong>scantwo()</strong> models. But they can not be plotted in the same way as a <strong>scanone()</strong> output and thus, won’t be covered here.</p>
<hr>
<p></p>
<div>
<pre><code><span>sessionInfo</span><span>()</span><span>
</span></code></pre>
</div>
<div>
<pre><code>## R version 3.3.2 (2016-10-31)
## Platform: x86_64-apple-darwin13.4.0 (64-bit)
## Running under: macOS Sierra 10.12.1
## 
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
## [1] dplyr_0.5.0   tidyr_0.6.0   ggrepel_0.6.5 ggplot2_2.2.1 qtl_1.40-8   
## 
## loaded via a namespace (and not attached):
##  [1] Rcpp_0.12.8        knitr_1.15.1       magrittr_1.5      
##  [4] munsell_0.4.3      colorspace_1.3-2   R6_2.2.0          
##  [7] stringr_1.1.0      plyr_1.8.4         tools_3.3.2       
## [10] parallel_3.3.2     grid_3.3.2         gtable_0.2.0      
## [13] DBI_0.5-1          htmltools_0.3.5    yaml_2.1.14       
## [16] lazyeval_0.2.0     rprojroot_1.1      digest_0.6.11     
## [19] assertthat_0.1     tibble_1.2         RColorBrewer_1.1-2
## [22] codetools_0.2-15   evaluate_0.10      rmarkdown_1.3     
## [25] labeling_0.3       stringi_1.1.2      scales_0.4.1      
## [28] backports_1.0.4
</code></pre>
</div>
<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://shiring.github.io/ggplot2/2017/02/12/qtl_plots"> Shirin's playgRound</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 title="The R Project for Statistical Computing" rel="nofollow" href="https://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="https://www.r-bloggers.com/search/data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="https://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="https://www.r-bloggers.com/search/map">maps</a>, <a title="Animation in R" rel="nofollow" href="https://www.r-bloggers.com/search/animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="https://www.r-bloggers.com/search/sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="https://www.r-bloggers.com/search/SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="https://www.r-bloggers.com/search/git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="https://www.r-bloggers.com/search/hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="https://www.r-bloggers.com/search/PCA">PCA</a>, <a title="Time series" rel="nofollow" href="https://www.r-bloggers.com/search/time+series">time series</a>, <a title="finance trading" rel="nofollow" href="https://www.r-bloggers.com/search/trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/-gKgPzImavA"></a></div>