<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" id="owaParaStyle">
<!--
p
        {margin-top:0;
        margin-bottom:0}
-->
</style>
</head>
<body fpstyle="1" ocsi="0">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;"><span style="font-size: 13.3333330154419px;">Dear Thibaut</span>
<div style="font-size: 13.3333330154419px;"><br>
</div>
<div style="font-size: 13.3333330154419px;">Thanks à lot!</div>
<div style="font-size: 13.3333330154419px;"><br>
</div>
<div style="font-size: 13.3333330154419px;">The script for the scatter works very well!</div>
<div style="font-size: 13.3333330154419px;"><br>
</div>
<div><span style="font-size: 13.3333330154419px;">I give more precisions about my problem with the function colorplot. </span></div>
<div><span style="font-size: 13.3333330154419px;">My sPCA in only defined with two axes:</span><br>
<div style="font-size: 13.3333330154419px;"><br>
</div>
<div style="font-size: 13.3333330154419px;">><font color="#3366FF">spca1</font></div>
<div>
<div style="font-size: 13.3333330154419px;"><font color="#3366FF">########################################</font></div>
<div style="font-size: 13.3333330154419px;"><font color="#3366FF"># spatial Principal Component Analysis</font></div>
<div style="font-size: 13.3333330154419px;"><font color="#3366FF">#</font><font color="#3366FF">########################################</font></div>
<div style="font-size: 13.3333330154419px;"><font color="#3366FF">class: spca</font></div>
<div style="font-size: 13.3333330154419px;"><font color="#3366FF">$call: spca(obj = geno, xy = coord, scale = TRUE)</font></div>
<div style="font-size: 13.3333330154419px;"><font color="#3366FF"><br>
</font></div>
<div style="font-size: 13.3333330154419px;"><font color="#3366FF">$nfposi: 2 axis-components saved</font></div>
<div style="font-size: 13.3333330154419px;"><font color="#3366FF">$nfnega: 0 axis-components saved</font></div>
<div style="font-size: 13.3333330154419px;"><font color="#3366FF">Positive eigenvalues: 9.571 6.744 4.421 3.258 2.818 ...</font></div>
<div style="font-size: 13.3333330154419px;"><font color="#3366FF">Negative eigenvalues: -0.1399 -0.09504 -0.09378 -0.08205 -0.0807 ...</font></div>
<div style="font-size: 13.3333330154419px;"><font color="#3366FF"><br>
</font></div>
<div style="font-size: 13.3333330154419px;"><font color="#3366FF">  vector length mode    content    </font></div>
<div style="font-size: 13.3333330154419px;"><font color="#3366FF">1 $eig   123    numeric eigenvalues</font></div>
<div style="font-size: 13.3333330154419px;"><font color="#3366FF"><br>
</font></div>
<div style="font-size: 13.3333330154419px;"><font color="#3366FF">  data.frame nrow ncol content                                                 </font></div>
<div style="font-size: 13.3333330154419px;"><font color="#3366FF">1 $c1        140  2    principal axes: scaled vectors of alleles loadings      </font></div>
<div style="font-size: 13.3333330154419px;"><font color="#3366FF">2 $li        310  2    principal components: coordinates of entities ('scores')</font></div>
<div style="font-size: 13.3333330154419px;"><font color="#3366FF">3 $ls        310  2    lag vector of principal components                      </font></div>
<div style="font-size: 13.3333330154419px;"><font color="#3366FF">4 $as        2    2    pca axes onto spca axes                                 </font></div>
<div style="font-size: 13.3333330154419px;"><font color="#3366FF"><br>
</font></div>
<div style="font-size: 13.3333330154419px;"><font color="#3366FF">$xy: matrix of spatial coordinates</font></div>
<div style="font-size: 13.3333330154419px;"><font color="#3366FF">$lw: a list of spatial weights (class 'listw')</font></div>
<div style="font-size: 13.3333330154419px;"><font color="#3366FF"><br>
</font></div>
<div style="font-size: 13.3333330154419px;"><font color="#3366FF">other elements: NULL</font></div>
<div style="font-size: 13.3333330154419px;"><br>
</div>
<div style="font-size: 13.3333330154419px;">And the colorsplot function is:</div>
<div style="font-size: 13.3333330154419px;"><font color="#3366FF">colorplot(spca1$xy, spca1$ls, axes = 1:2, cex = 3)</font></div>
<div style="font-size: 13.3333330154419px;"><br>
</div>
<div style="font-size: 13.3333330154419px;"><span style="font-size: 10pt;">If I understand well the function, the colorplot projects my populations according to their geographical coordinates and adds a color (green-red scale) according to the ls score for
 the twa sPCA axes.</span></div>
<div>
<div>The spca1$ls object contains two columns corresponding to the ls of the two axes:</div>
</div>
<div style="font-size: 13.3333330154419px;"><br>
</div>
<div style="font-size: 13.3333330154419px;">
<div><font color="#3366FF">> head(spca1$ls)</font></div>
<div><font color="#3366FF">    Axis 1    Axis 2</font></div>
<div><font color="#3366FF">1 3.383404 -2.599413</font></div>
<div><font color="#3366FF">2 3.401930 -2.626953</font></div>
<div><font color="#3366FF">3 3.410790 -2.636643</font></div>
<div><font color="#3366FF">4 3.376684 -2.647047</font></div>
<div><font color="#3366FF">5 3.368616 -2.582604</font></div>
<div><font color="#3366FF">6 3.385992 -2.636117</font></div>
</div>
<div style="font-size: 13.3333330154419px;"><br>
</div>
<div>
<div>So what I want to do is add the legend of these colors ...</div>
<div>I ask again because I'm not sure that I was clear the first time</div>
<div><span style="font-size: 10pt;">I'm sorry to ask you again, but even my colleagues who usually save me with R have never used this colorplot ...</span></div>
<div><br>
</div>
<div>Thank you again!</div>
</div>
</div>
</div>
<div><br>
<div style="font-family:Tahoma; font-size:13px"><i><font size="4">Coraline Bichet</font></i>
<div>
<div><font size="2">coraline.bichet@univ-lyon1.fr</font></div>
<div><font size="2">+33(0)472433584</font></div>
<div>UMR-CNRS 5558, Laboratoire de Biométrie et Biologie Evolutive (LBBE) <br>
<div>Université Claude Bernard Lyon 1, bâtiment Mendel</div>
<div>43 boulevard du 11 novembre 1918</div>
<div>69622 Villeurbanne Cedex, FRANCE</div>
<div><br>
</div>
</div>
</div>
</div>
</div>
<div style="font-family: Times New Roman; color: #000000; font-size: 16px">
<hr tabindex="-1">
<div id="divRpF159875" style="direction: ltr;"><font face="Tahoma" size="2" color="#000000"><b>De :</b> Jombart, Thibaut [t.jombart@imperial.ac.uk]<br>
<b>Envoyé :</b> jeudi 20 août 2015 13:01<br>
<b>À :</b> BICHET CORALINE; adegenet-forum@lists.r-forge.r-project.org<br>
<b>Objet :</b> RE: colorplot and scatter<br>
</font><br>
</div>
<div></div>
<div>
<div style="direction:ltr; font-family:Tahoma; color:#000000; font-size:10pt">Hi Coraline
<br>
<br>
The colorplot is basically translating up to 3 quantitative variables into colors using RGB coding. So each axis corresponds to a channel, but the problem is our eyes are not good at knowing what color comes out when combining values RBG channels. To have a
 proper legend for 3 axes we would need some kind of color triangle. And a different system for 2 axes.. nothing impossible to code, but cumbersome.
<br>
<br>
As for your second question, your approach is the best way to go. But there's a trick.<br>
The function add.scatter.eig, which adds the barplots of eigenvalues to the plot, changes the coordinate system, so that you can't plot anything afterwards. You need to disable them,e g.:<br>
<br>
library(adegenet)<br>
example(dapc)<br>
<div>scatter(dapc1, col="transparent", scree.da=FALSE)<br>
points(dapc1$ind.coord[,1],dapc1$ind.coord[,2], col=funky(100))<br>
<div style="font-family:Tahoma; font-size:13px">
<div class="BodyFragment"><font size="2"><span style="font-size:10pt">
<div class="PlainText"><br>
Note that if some points are missing around the edges, you may need a par(xpd=TRUE) right before your 'points(..)'.<br>
<br>
Cheers<br>
Thibaut<br>
                <br>
==============================<br>
Dr Thibaut Jombart<br>
MRC Centre for Outbreak Analysis and Modelling<br>
Department of Infectious Disease Epidemiology<br>
Imperial College - School of Public Health<br>
Norfolk Place, London W2 1PG, UK<br>
Tel. : 0044 (0)20 7594 3658<br>
http://sites.google.com/site/thibautjombart/<br>
http://sites.google.com/site/therepiproject/<br>
http://adegenet.r-forge.r-project.org/<br>
Twitter: @thibautjombart<br>
<br>
<br>
</div>
</span></font></div>
</div>
</div>
<div style="font-family:Times New Roman; color:#000000; font-size:16px">
<hr tabindex="-1">
<div id="divRpF839377" style="direction:ltr"><font face="Tahoma" color="#000000" size="2"><b>From:</b> adegenet-forum-bounces@lists.r-forge.r-project.org [adegenet-forum-bounces@lists.r-forge.r-project.org] on behalf of BICHET CORALINE [coraline.bichet@univ-lyon1.fr]<br>
<b>Sent:</b> 20 August 2015 10:29<br>
<b>To:</b> adegenet-forum@lists.r-forge.r-project.org<br>
<b>Subject:</b> [adegenet-forum] colorplot and scatter<br>
</font><br>
</div>
<div></div>
<div>
<div style="direction:ltr; font-family:Tahoma; color:#000000; font-size:10pt">
<div>Dear forum</div>
<div><br>
</div>
<div>I have two questions about the adegenet functions "colorplot" and "scatter"</div>
<div>I precise that I am a beginner with the package adegenet, so excuse me in advance if my questions seem a little stupid...</div>
<div><br>
</div>
<div>1. Colorplot</div>
<div><br>
</div>
<div>I made a colorplot to represent the result of a sPCA. The colorplot plots the different populations according to their localisation and the colors correspond to the global sPCA score. I would like to add a legend in a box representing the correspondance
 between colors and sPCA score (as the image below). I search... but I did not find anything to do this... </div>
<div><br>
</div>
<div>
<p><img src="cid:426d0c7f-6e00-4dd2-a001-eeab8f80089a"></p>
<div><br>
</div>
<div><br>
</div>
<div>2. Scatter</div>
<div><br>
</div>
<div>I used the function scatter to represent the results of a DAPC. The colored dots in the plot represent the cluster, but I would like to know if it is possible that the dots represent populations instead of clusters. The clusters would be still represented
 with the colored bars and the ellipses. I only want to change the dot colors. I tried to manually add dots in the plot (with the function "points"), using the coordinates of each indviduals in the DAPC axes. But the dots did not appeared... maybe due to a
 scale problem that I cannot solve... </div>
<div>Here the function that I use for one population. The data frame "ind" contains the DAPC LD1 and LD2, and the population names of the different individuals :</div>
</div>
<div>
<div><br>
</div>
<div><span style="font-size:13.3333330154419px">points(ind$LD1[ind$pop=="Aussois"]), scale(ind$LD2[ind$pop=="Aussois"]), col="black", pch=16, cex = 1)</span></div>
<div><span style="font-size:13.3333330154419px"><br>
</span></div>
<div><span style="font-size:13.3333330154419px"><br>
</span></div>
<div>
<div>I hope that my questions are comprehensible. Thank you very much in advance for your help. Don't hesitate to let me know if you need further information to more understand my problems.</div>
<div><br>
</div>
<div>Thanks a lot!</div>
</div>
<div><br>
<div style="font-family:Tahoma; font-size:13px"><i><font size="4">Coraline Bichet</font></i>
<div>
<div><font size="2">coraline.bichet@univ-lyon1.fr</font></div>
<div><font size="2">+33(0)472433584</font></div>
<div>UMR-CNRS 5558, Laboratoire de Biométrie et Biologie Evolutive (LBBE) <br>
<div>Université Claude Bernard Lyon 1, bâtiment Mendel</div>
<div>43 boulevard du 11 novembre 1918</div>
<div>69622 Villeurbanne Cedex, FRANCE</div>
<div><br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>