<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style id="owaParaStyle" type="text/css">P {margin-top:0;margin-bottom:0;}</style>
</head>
<body ocsi="0" fpstyle="1">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;"><br>
Hi there, <br>
<br>
I went through the email trail quickly, but I think you need something along the lines of:<br>
<br>
<div>####<br>
<font face="Courier New">library(adegenet)<br>
</font>
<div style="font-family:Tahoma; font-size:13px">
<div class="BodyFragment"><font size="2"><span style="font-size:10pt">
<div class="PlainText"><font face="Courier New">example(dapc)<br>
morpho <- factor(sample(letters[1:6], nrow(dapc1$ind.coord), replace=TRUE))<br>
<br>
scatter(dapc1, pch="", scree.da=FALSE)<br>
par(xpd=TRUE)<br>
points(dapc1$ind.coord, pch=as.integer(morpho))<br>
</font><br>
####<br>
<br>
Otherwise ggplot2 offers good alternatives:<br>
<br>
####<br>
<font face="Courier New">> dat <- data.frame(dapc1$ind.coord, group=factor(dapc1$grp), morpho)<br>
> head(dat)<br>
                 LD1        LD2         LD3        LD4        LD5         LD6<br>
AFBIBOR9503 5.398012 -5.9154641  0.30329146 -0.5874714 -0.8290345 -0.26056227<br>
AFBIBOR9504 3.697040 -3.8046570 -0.09263061 -0.5967574 -0.5017393  1.88135969<br>
AFBIBOR9505 5.496883  0.9354478  0.61307612 -0.1419224 -2.6534069 -0.24431807<br>
AFBIBOR9506 5.538440 -2.6152434  0.80186922  0.3334149 -1.6202109  0.06381506<br>
AFBIBOR9507 5.258127 -1.6598447  0.21333638 -1.3799890 -0.1550098  1.77052354<br>
AFBIBOR9508 6.381482  0.5563613  0.42597354 -1.0441841 -1.0207730 -0.04500107<br>
                    LD7        LD8        LD9         LD10       LD11<br>
AFBIBOR9503 -0.07016765 -1.1810082 -1.0765799 -0.389844937 -0.4576461<br>
AFBIBOR9504  1.68135006  1.5462166 -1.4605117 -0.732729892 -1.5683318<br>
AFBIBOR9505 -0.28373085  0.4224500 -1.5026889 -0.495831033  1.8832038<br>
AFBIBOR9506  0.83341513 -0.857079e-6 -0.4147484  1.304984340 -0.2535325<br>
AFBIBOR9507 -0.23776197  0.3483954 -0.7429532  0.003968628  0.6304628<br>
AFBIBOR9508  0.78436225 -0.2455169 -1.9580097 -0.022258198 -1.0614034<br>
                  LD12       LD13       LD14  group morpho<br>
AFBIBOR9503 -1.1221279  2.0025634  0.2963844 Borgou      a<br>
AFBIBOR9504  0.4286541 -1.0477615  0.7572506 Borgou      d<br>
AFBIBOR9505  0.7906680  0.8864259 -2.0664313 Borgou      b<br>
AFBIBOR9506 -0.9793516  0.8136440 -0.3757589 Borgou      c<br>
AFBIBOR9507 -1.2099940 -0.0540738  1.3394422 Borgou      c<br>
AFBIBOR9508 -2.0181906  1.6781495  0.2876485 Borgou      c<br>
> library(ggplot2)<br>
> ggplot(dat, aes(x=LD1, y=LD2)) + geom_point(aes(color=group, shape=morpho))<br>
</font><br>
####<br>
<br>
Cheers<br>
Thibaut<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 style="direction: ltr;" id="divRpF518467"><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 Nicolas Dussex [nicolas.dussex@gmail.com]<br>
<b>Sent:</b> 30 April 2015 23:48<br>
<b>To:</b> pablo fresia; adegenet-forum@lists.r-forge.r-project.org<br>
<b>Subject:</b> Re: [adegenet-forum] labeling individuals in scatter pot<br>
</font><br>
</div>
<div></div>
<div>
<div dir="ltr">
<div>
<div>humm.. I realise that it's gonna be difficult to do that with my 300+ samples so if someone has other suggestions, that would be fantastic.<br>
<br>
</div>
Cheers<br>
</div>
Nic<br>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On 1 May 2015 at 10:05, Nicolas Dussex <span dir="ltr"><<a href="mailto:nicolas.dussex@gmail.com" target="_blank">nicolas.dussex@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div dir="ltr">
<div>Thanks Pablo, seems to be working!<br>
<br>
</div>
Nic<br>
</div>
<div class="HOEnZb">
<div class="h5">
<div class="gmail_extra"><br>
<div class="gmail_quote">On 30 April 2015 at 14:28, pablo fresia <span dir="ltr">
<<a href="mailto:pfresia@gmail.com" target="_blank">pfresia@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div dir="ltr">... the errors are probably because of the bounds within [..., ...]<br>
<div class="gmail_extra"><br>
<div class="gmail_quote"><span>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div dir="ltr">
<div>
<div>
<div>
<div>
<div>I got this error message now:<span><br>
<br>
> points(dapc1$ind.coord[1:90,],<br>
+        pch=17, cex=1, col="black")<br>
</span>Error in dapc1$ind.coord[1:90, ] : subscript out of bounds<span><br>
> par(xpd=TRUE)<br>
> points(dapc1$ind.coord[91:218,],<br>
+        pch=18, cex=1.4, col="black")<br>
</span>Error in dapc1$ind.coord[91:218, ] : subscript out of bounds<span><br>
> par(xpd=TRUE)<br>
> points(dapc1$ind.coord[219:326,],<br>
+        pch=21, cex=1, col="black")<br>
</span>Error in dapc1$ind.coord[219:326, ] : subscript out of bounds<span><br>
> par(xpd=TRUE)<br>
> points(dapc1$ind.coord[327:392,],<br>
+        pch=20, cex=1.3, col="black")<br>
</span>Error in dapc1$ind.coord[327:392, ] : subscript out of bounds<br>
<br>
</div>
I thought about sorting indviduals by morphotype, but not sure how to do it as I want to keep the population info too. My samples are grouped by population at this stage.
<br>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</span>
<div><br>
... mixing both approaches may be you find a way. I figure, if you keep the inds organized by pop but dividing it by morphotype you can assign colors and symbols in the way you need.<br>
<br>
eg. pop 1: 1 to 30 inds, 1-15 morph 1 and 16-30 morph 2:<br>
<br>
> points(dapc1$ind.coord[1:15,], pch=17, cex=1, col="black")<br>
> points(dapc1$ind.coord[16:30,], pch=18, cex=1, col="black")<br>
<br>
and so on... <br>
<br>
</div>
<span>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div dir="ltr">
<div>
<div>
<div>
<div></div>
If I run this:<br>
<br>
scatter(dapc1, cstar=0,cex=2.5, cell=0, label=NULL, leg = TRUE,scree.da=FALSE,txt.leg = c("233","287","418","674","878","957","1085")) #pch=c)#col = myCol)<br>
par(new=TRUE)<br>
df <- data.frame(x = dapc1$ind.coord[,1], y = dapc1$ind.coord[,2])<br>
morph_data_6m<-read.table("morph_data_6m.txt", header=T)<br>
c<-morph_data_6m[,1]<br>
s.label(dfxy = df, xax=1, yax=2, label=c,clabel=0.7,boxes=FALSE,grid=FALSE, addaxes=FALSE)<br>
<br>
</div>
I obtain a plot of coloured dots corresponding to each population and I then add the morphotype label (W, WR or X; from my "moprh_data_6m.txt" file) on top of each dot, but it gets difficult to read when dots overlap (see example attached)<br>
</div>
</div>
</div>
</blockquote>
<div><br>
</div>
</span>
<div> best<br>
</div>
<div>
<div>
<div>pablo<br>
<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div>
<div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On 30 April 2015 at 13:53, pablo fresia <span dir="ltr">
<<a href="mailto:pfresia@gmail.com" target="_blank">pfresia@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div dir="ltr">... maybe, the individuals needs to be by organized morphotype before to run the DAPC.</div>
<div>
<div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On 29 April 2015 at 22:49, pablo fresia <span dir="ltr">
<<a href="mailto:pfresia@gmail.com" target="_blank">pfresia@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div dir="ltr">Hi Nic,<br>
<div>
<div class="gmail_extra"><br>
<div class="gmail_quote">an error, should be here<br>
<br>
</div>
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div dir="ltr">
<div class="gmail_extra">
<div><span><span>> myCol <- c("darkblue","darkgreen","red")<br>
</span>> scatter(dapc1, scree.da=FALSE, bg="white", pch=20, solid=.4, cex=0, cstar=1, clab=1, col=myCol)</span><span><br>
> par(xpd=TRUE)<br>
> points(<u>dapc<b><span style="background-color:rgb(255,255,255)">1</span></b></u>$ind.coord[1:90,],<br>
</span><span>+        pch=17, cex=1, col="black")<br>
<b>Error in dapc$ind.coord : object of type 'closure' is not subsettable</b></span><span><br>
> par(xpd=TRUE)<br>
> points(<u>dapc<b>1</b></u>$ind.coord[91:218,],<br>
</span><span>+        pch=18, cex=1.4, col="black")<br>
<b>Error in dapc$ind.coord : object of type 'closure' is not subsettable</b></span><span><br>
> par(xpd=TRUE)<br>
> points(<u>dapc<b>1</b></u>$ind.coord[219:326,],<br>
</span><span>+        pch=21, cex=1, col="black")<br>
<b>Error in dapc$ind.coord : object of type 'closure' is not subsettable</b></span><span><br>
> par(xpd=TRUE)<br>
> points(<u>dapc<b>1</b></u>$ind.coord[327:392,],<br>
</span><span>+        pch=20, cex=1.3, col="black")<br>
<b>Error in dapc$ind.coord : object of type 'closure' is not subsettable</b><br>
</span></div>
</div>
</div>
</blockquote>
<div><br>
</div>
<div>cheers,<br>
</div>
<div>pablo<br>
 <br>
</div>
<div>
<div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div dir="ltr">
<div class="gmail_extra">
<div></div>
<div class="gmail_quote">On 30 April 2015 at 13:03, pablo fresia <span dir="ltr">
<<a href="mailto:pfresia@gmail.com" target="_blank">pfresia@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div dir="ltr">Hi Nicolas,<br>
<br>
what's going on, if you try something like this below ?<br>
<div><br>
myCol <- c("darkblue","darkgreen","red")<br>
scatter(dapc, scree.da=FALSE, bg="white", pch=20, solid=.4, cex=0, cstar=1, clab=1, col=myCol)<br>
par(xpd=TRUE)<br>
points(dapc$ind.coord[1:90,], <br>
       pch=17, cex=1, col="black")<br>
par(xpd=TRUE)<br>
points(dapc$ind.coord[91:218,], <br>
       pch=18, cex=1.4, col="black")<br>
par(xpd=TRUE)<br>
points(dapc$ind.coord[219:326,], <br>
       pch=21, cex=1, col="black")<br>
par(xpd=TRUE)<br>
points(dapc$ind.coord[327:392,], <br>
       pch=20, cex=1.3, col="black")<br>
<br>
</div>
<div>good luck!<br>
</div>
<div>pablo<br>
</div>
<div><br>
</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">
<div>
<div>On 29 April 2015 at 21:50, Nicolas Dussex <span dir="ltr"><<a href="mailto:nicolas.dussex@gmail.com" target="_blank">nicolas.dussex@gmail.com</a>></span> wrote:<br>
</div>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div>
<div>
<div dir="ltr">
<div>
<div>
<div>
<div>
<div>Hi,<br>
<br>
</div>
I am doing a DAPC for a dataset that contains 6 populations. Among all my samples, there are three different morphs and each population contains a variable mixture of each. What I want to do is to use a different color for each population (I managed to do it)
 and use a different type of point for each sample according to its moprhotype. I have a file that contains this info ( 1 colomn with either X, W or WR).
<br>
<br>
</div>
I tried using pch as described below, but the labels do not correspond to the individuals.
<br>
<br>
dapc1 <- dapc(Z1, n.pca = 10, n.da = 3)<br>
c<-morph_data_6m[,1]<br>
scatter(dapc1, cstar=0,cex=2.5, cell=0, label=NULL, leg = TRUE,scree.da=FALSE,txt.leg = c("233","287","418","674","878","957","1085"),
<b>pch=c</b>)<br>
<br>
</div>
Would there be a way to assign to each individual a type of point corresponding to its morphotype? Say point for W, star for X and triangle for WR.<br>
<br>
</div>
Thanks for your help!<br>
</div>
Nic<span><font color="#888888"><br>
<div>
<div>
<div><br>
<br>
<div>
<div>
<div>-- <br>
<div>
<div dir="ltr">
<div>
<div dir="ltr">Nic Dussex PhD<br>
Department of Zoology<br>
University of Otago<br>
340 Great King Street<br>
P.O.Box 56<br>
Dunedin 9054<br>
New Zealand<br>
<br>
Mobile: +64 21 02790938<br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</font></span></div>
<br>
</div>
</div>
_______________________________________________<br>
adegenet-forum mailing list<br>
<a href="mailto:adegenet-forum@lists.r-forge.r-project.org" target="_blank">adegenet-forum@lists.r-forge.r-project.org</a><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/adegenet-forum" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/adegenet-forum</a><br>
</blockquote>
</div>
<br>
</div>
</blockquote>
</div>
<br>
<br clear="all">
<br>
-- <br>
<div>
<div dir="ltr">
<div>
<div dir="ltr">Nic Dussex PhD<br>
Department of Zoology<br>
University of Otago<br>
340 Great King Street<br>
P.O.Box 56<br>
Dunedin 9054<br>
New Zealand<br>
<br>
Mobile: +64 21 02790938<br>
</div>
</div>
</div>
</div>
</div>
</div>
<div>
<div></div>
</div>
</blockquote>
</div>
</div>
</div>
<br>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</blockquote>
</div>
<br>
<br clear="all">
<br>
-- <br>
<div>
<div dir="ltr">
<div>
<div dir="ltr">Nic Dussex PhD<br>
Department of Zoology<br>
University of Otago<br>
340 Great King Street<br>
P.O.Box 56<br>
Dunedin 9054<br>
New Zealand<br>
<br>
Mobile: +64 21 02790938<br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
<br>
</div>
</div>
</blockquote>
</div>
<br>
<br clear="all">
<br>
-- <br>
<div>
<div dir="ltr">
<div>
<div dir="ltr">Nic Dussex PhD<br>
Department of Zoology<br>
University of Otago<br>
340 Great King Street<br>
P.O.Box 56<br>
Dunedin 9054<br>
New Zealand<br>
<br>
Mobile: +64 21 02790938<br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br>
<br clear="all">
<br>
-- <br>
<div class="gmail_signature">
<div dir="ltr">
<div>
<div dir="ltr">Nic Dussex PhD<br>
Department of Zoology<br>
University of Otago<br>
340 Great King Street<br>
P.O.Box 56<br>
Dunedin 9054<br>
New Zealand<br>
<br>
Mobile: +64 21 02790938<br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>