[adegenet-forum] labeling individuals in scatter pot
Nicolas Dussex
nicolas.dussex at gmail.com
Fri May 1 00:05:56 CEST 2015
Thanks Pablo, seems to be working!
Nic
On 30 April 2015 at 14:28, pablo fresia <pfresia at gmail.com> wrote:
> ... the errors are probably because of the bounds within [..., ...]
>
> I got this error message now:
>>
>> > points(dapc1$ind.coord[1:90,],
>> + pch=17, cex=1, col="black")
>> Error in dapc1$ind.coord[1:90, ] : subscript out of bounds
>> > par(xpd=TRUE)
>> > points(dapc1$ind.coord[91:218,],
>> + pch=18, cex=1.4, col="black")
>> Error in dapc1$ind.coord[91:218, ] : subscript out of bounds
>> > par(xpd=TRUE)
>> > points(dapc1$ind.coord[219:326,],
>> + pch=21, cex=1, col="black")
>> Error in dapc1$ind.coord[219:326, ] : subscript out of bounds
>> > par(xpd=TRUE)
>> > points(dapc1$ind.coord[327:392,],
>> + pch=20, cex=1.3, col="black")
>> Error in dapc1$ind.coord[327:392, ] : subscript out of bounds
>>
>> 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.
>>
>
> ... 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.
>
> eg. pop 1: 1 to 30 inds, 1-15 morph 1 and 16-30 morph 2:
>
> > points(dapc1$ind.coord[1:15,], pch=17, cex=1, col="black")
> > points(dapc1$ind.coord[16:30,], pch=18, cex=1, col="black")
>
> and so on...
>
> If I run this:
>>
>> 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)
>> par(new=TRUE)
>> df <- data.frame(x = dapc1$ind.coord[,1], y = dapc1$ind.coord[,2])
>> morph_data_6m<-read.table("morph_data_6m.txt", header=T)
>> c<-morph_data_6m[,1]
>> s.label(dfxy = df, xax=1, yax=2,
>> label=c,clabel=0.7,boxes=FALSE,grid=FALSE, addaxes=FALSE)
>>
>> 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)
>>
>
> best
> pablo
>
>
>> On 30 April 2015 at 13:53, pablo fresia <pfresia at gmail.com> wrote:
>>
>>> ... maybe, the individuals needs to be by organized morphotype before to
>>> run the DAPC.
>>>
>>> On 29 April 2015 at 22:49, pablo fresia <pfresia at gmail.com> wrote:
>>>
>>>> Hi Nic,
>>>>
>>>> an error, should be here
>>>>
>>>> > myCol <- c("darkblue","darkgreen","red")
>>>>> > scatter(dapc1, scree.da=FALSE, bg="white", pch=20, solid=.4, cex=0,
>>>>> cstar=1, clab=1, col=myCol)
>>>>> > par(xpd=TRUE)
>>>>> > points(*dapc1*$ind.coord[1:90,],
>>>>> + pch=17, cex=1, col="black")
>>>>> *Error in dapc$ind.coord : object of type 'closure' is not subsettable*
>>>>> > par(xpd=TRUE)
>>>>> > points(*dapc1*$ind.coord[91:218,],
>>>>> + pch=18, cex=1.4, col="black")
>>>>> *Error in dapc$ind.coord : object of type 'closure' is not subsettable*
>>>>> > par(xpd=TRUE)
>>>>> > points(*dapc1*$ind.coord[219:326,],
>>>>> + pch=21, cex=1, col="black")
>>>>> *Error in dapc$ind.coord : object of type 'closure' is not subsettable*
>>>>> > par(xpd=TRUE)
>>>>> > points(*dapc1*$ind.coord[327:392,],
>>>>> + pch=20, cex=1.3, col="black")
>>>>> *Error in dapc$ind.coord : object of type 'closure' is not subsettable*
>>>>>
>>>>
>>>> cheers,
>>>> pablo
>>>>
>>>>
>>>>> On 30 April 2015 at 13:03, pablo fresia <pfresia at gmail.com> wrote:
>>>>>
>>>>>> Hi Nicolas,
>>>>>>
>>>>>> what's going on, if you try something like this below ?
>>>>>>
>>>>>> myCol <- c("darkblue","darkgreen","red")
>>>>>> scatter(dapc, scree.da=FALSE, bg="white", pch=20, solid=.4, cex=0,
>>>>>> cstar=1, clab=1, col=myCol)
>>>>>> par(xpd=TRUE)
>>>>>> points(dapc$ind.coord[1:90,],
>>>>>> pch=17, cex=1, col="black")
>>>>>> par(xpd=TRUE)
>>>>>> points(dapc$ind.coord[91:218,],
>>>>>> pch=18, cex=1.4, col="black")
>>>>>> par(xpd=TRUE)
>>>>>> points(dapc$ind.coord[219:326,],
>>>>>> pch=21, cex=1, col="black")
>>>>>> par(xpd=TRUE)
>>>>>> points(dapc$ind.coord[327:392,],
>>>>>> pch=20, cex=1.3, col="black")
>>>>>>
>>>>>> good luck!
>>>>>> pablo
>>>>>>
>>>>>>
>>>>>> On 29 April 2015 at 21:50, Nicolas Dussex <nicolas.dussex at gmail.com>
>>>>>> wrote:
>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> 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).
>>>>>>>
>>>>>>> I tried using pch as described below, but the labels do not
>>>>>>> correspond to the individuals.
>>>>>>>
>>>>>>> dapc1 <- dapc(Z1, n.pca = 10, n.da = 3)
>>>>>>> c<-morph_data_6m[,1]
>>>>>>> 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*)
>>>>>>>
>>>>>>> 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.
>>>>>>>
>>>>>>> Thanks for your help!
>>>>>>> Nic
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Nic Dussex PhD
>>>>>>> Department of Zoology
>>>>>>> University of Otago
>>>>>>> 340 Great King Street
>>>>>>> P.O.Box 56
>>>>>>> Dunedin 9054
>>>>>>> New Zealand
>>>>>>>
>>>>>>> Mobile: +64 21 02790938
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> adegenet-forum mailing list
>>>>>>> adegenet-forum at lists.r-forge.r-project.org
>>>>>>>
>>>>>>> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/adegenet-forum
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Nic Dussex PhD
>>>>> Department of Zoology
>>>>> University of Otago
>>>>> 340 Great King Street
>>>>> P.O.Box 56
>>>>> Dunedin 9054
>>>>> New Zealand
>>>>>
>>>>> Mobile: +64 21 02790938
>>>>>
>>>>
>>>>
>>>
>>
>>
>> --
>> Nic Dussex PhD
>> Department of Zoology
>> University of Otago
>> 340 Great King Street
>> P.O.Box 56
>> Dunedin 9054
>> New Zealand
>>
>> Mobile: +64 21 02790938
>>
>
>
--
Nic Dussex PhD
Department of Zoology
University of Otago
340 Great King Street
P.O.Box 56
Dunedin 9054
New Zealand
Mobile: +64 21 02790938
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/adegenet-forum/attachments/20150501/cf1e4ff7/attachment.html>
More information about the adegenet-forum
mailing list