[adegenet-forum] DAPC and map

Jombart, Thibaut t.jombart at imperial.ac.uk
Mon Jul 18 11:04:56 CEST 2011


Hello Pierpaolo, 

I am on vacation now and don't have a R installed, so I can't check the doc, but I thought I had written a comment in the example of eHGDP about the colors varying from one system to another.

As in other multivariate analyses, the sign of principal components of DAPC is arbitrary, and will vary from one computer to another.

If you take e.g. one PC and recode it on the red channel, the results will vary from black to red, but the gradient will vary when using different computers or R versions. Therefore in the colorplot you can tweak the colors by multiplying the scores by "-1" (hence the "-dapc1$grp.coord"). The function you refer to in colorplot is not related to this anyway - it merely maps values for colors to positive values - proportions of colors have to be positive.

Best

Thibaut
________________________________________
From: adegenet-forum-bounces at r-forge.wu-wien.ac.at [adegenet-forum-bounces at r-forge.wu-wien.ac.at] on behalf of Maisano Delser, Pierpaolo [pm244 at leicester.ac.uk]
Sent: 11 July 2011 15:47
To: adegenet-forum at lists.r-forge.r-project.org
Subject: [adegenet-forum] DAPC and map

Dear Thibaut Jombart and List members,

I am performing the DAPC analysis on my dataset and I am particularly interested in reproducing the figure 5 (Jombart T et al._2010_BMCgenetics) with my data.
Before doing that I tried to follow the example on the eHGDP dataset in order to reproduce the figure 5. So I performed the DAPC on that dataset with n.pca=1000 in order to get a result as much comparable as possible to that one in the paper.

The barplot of the eigenvalues is exactly the same to the published one but the colored pattern I got by plotting all the populations is quite different. It seems to be much more similar to the figure 7 (same paper) where the number of inferred clusters is equal to 4 even if I used the original 79 populations as clusters.
I used these commands as written in the help file:


if(require(maps)){
     xy <- cbind(eHGDP$other$popInfo$Longitude, eHGDP$other$popInfo$Latitude)
     par(mar=rep(.1,4))
     map(fill=TRUE, col="lightgrey")
     colorplot(xy, -dapc1$grp.coord, cex=3, add=TRUE, trans=FALSE)
     }

Moreover another point I did not get is about that minus sign in front of dapc1$grp.coord...in that dataset each column (each discriminant function) could assume both positive and negative values...how could they be converted into rgb colors?
In order to understand something more I tried to read through the colorplot.default function by using my little R knowledge. I understood that those values are standardized by dividing them for their maximum within each column but I did not get what happen for the negative ones...are they substituted by their original value plus the absolute value of the minimum in that column?
Probably (I am not sure!) this is the part of the colorplot function responsible for that:

 f1 <- function(x) {
        if (any(x < 0)) {
            x <- x + abs(min(x))
        }
        return(x)

So my question is just to understand how to plot the DAPC results by using the rgb colors like in figure 5.
Any suggestions would be really appreciated.
Thank you so much for your help!

Best wishes,

Pierpaolo
_______________________________________________
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


More information about the adegenet-forum mailing list