[adegenet-forum] colorplot and scatter

Jombart, Thibaut t.jombart at imperial.ac.uk
Thu Aug 20 13:01:56 CEST 2015


Hi Coraline

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.

As for your second question, your approach is the best way to go. But there's a trick.
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.:

library(adegenet)
example(dapc)
scatter(dapc1, col="transparent", scree.da=FALSE)
points(dapc1$ind.coord[,1],dapc1$ind.coord[,2], col=funky(100))

Note that if some points are missing around the edges, you may need a par(xpd=TRUE) right before your 'points(..)'.

Cheers
Thibaut

==============================
Dr Thibaut Jombart
MRC Centre for Outbreak Analysis and Modelling
Department of Infectious Disease Epidemiology
Imperial College - School of Public Health
Norfolk Place, London W2 1PG, UK
Tel. : 0044 (0)20 7594 3658
http://sites.google.com/site/thibautjombart/
http://sites.google.com/site/therepiproject/
http://adegenet.r-forge.r-project.org/
Twitter: @thibautjombart


________________________________
From: adegenet-forum-bounces at lists.r-forge.r-project.org [adegenet-forum-bounces at lists.r-forge.r-project.org] on behalf of BICHET CORALINE [coraline.bichet at univ-lyon1.fr]
Sent: 20 August 2015 10:29
To: adegenet-forum at lists.r-forge.r-project.org
Subject: [adegenet-forum] colorplot and scatter

Dear forum

I have two questions about the adegenet functions "colorplot" and "scatter"
I precise that I am a beginner with the package adegenet, so excuse me in advance if my questions seem a little stupid...

1. Colorplot

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...


[cid:426d0c7f-6e00-4dd2-a001-eeab8f80089a]


2. Scatter

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...
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 :

points(ind$LD1[ind$pop=="Aussois"]), scale(ind$LD2[ind$pop=="Aussois"]), col="black", pch=16, cex = 1)


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.

Thanks a lot!

Coraline Bichet
coraline.bichet at univ-lyon1.fr
+33(0)472433584
UMR-CNRS 5558, Laboratoire de Biométrie et Biologie Evolutive (LBBE)
Université Claude Bernard Lyon 1, bâtiment Mendel
43 boulevard du 11 novembre 1918
69622 Villeurbanne Cedex, FRANCE

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/adegenet-forum/attachments/20150820/8831d633/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: box.jpg
Type: image/jpeg
Size: 5902 bytes
Desc: box.jpg
URL: <http://lists.r-forge.r-project.org/pipermail/adegenet-forum/attachments/20150820/8831d633/attachment.jpg>


More information about the adegenet-forum mailing list