[adegenet-forum] compoplot

Miguel Navascues navascues at supagro.inra.fr
Mon Jan 6 16:09:16 CET 2014


Hi,

Barplots in R, such as compoplot, use some strange (to me) way to scale 
the plot. The key to add labels (or axis) to the compoplot is to get 
rigth sacle. You can do this by using the function barplot() and saving 
the result into a variable. The object will have as many positions as 
bars (i.e. individuals) and will contain in each position the x 
coordinate of the barplot scale. So,if you look to produce something 
like the figure attached you need to order the individuals by population 
and run DAPC. Then you do something like this:


# get scale of barplot using posterior probabilities of the dapc result

barplot_scale <- barplot( t(dapc_result$posterior) )

compoplot(dapc_result, lab=NA, legend=F)

# add ticks at the limits of each population (e.g. positions of first 
individuals of each population plus last individual)

axis(1, at = barplot_scale[limits_between_populations], labels = F, 
lwd=3, lwd.ticks=3)

# add population name between ticks (one vector with the middle position 
for each population + one vector with the population names)

axis(1, at = barplot_scale[middle_point_of_populations], labels = 
population_names, las=3, tick=F)




Cheers,

Miguel




On 01/06/2014 03:38 PM, Jombart, Thibaut wrote:
> Hello,
>
> there is currently no simple way of adding the population information to the plot. The only practical one would need assuming that individuals are sorted by population, which is not usually the case. An alternative would be adding coloured symbols above / below the bars for each individual, but this would become quickly unreadable.
>
> In your case, if you want to save some daunting programming and just need this for a restricted number of plots, I would advise i) sorting individuals per population ii) saving the figure as .svg iii) editing it using inkscape to add vertical lines separating populations and annotations.
> In case you've never used it, inkscape is an outstanding free software for vector graphics available there:
> http://www.inkscape.org/
>
> Cheers
> Thibaut
>
>
> ________________________________________
> From: adegenet-forum-bounces at lists.r-forge.r-project.org [adegenet-forum-bounces at lists.r-forge.r-project.org] on behalf of Rita Castilho [rita.castil at gmail.com]
> Sent: 06 January 2014 11:35
> To: adegenet-forum at lists.r-forge.r-project.org
> Subject: [adegenet-forum] compoplot
>
> Hi!
> Is there a way to graphically mark the origin info (populations, for
> instance) in the compoplot? Small ticks below the plot, would do, with
> the pop codes in between.
>
> Many thanks
> Rita
>
> _______________________________________________
> 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
> _______________________________________________
> 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
>


-- 
Miguel NAVASCUÉS, PhD

Chargé de Recherche (CR2) INRA

UMR CBGP Centre de Biologie pour la Gestion des Populations
Institut National de la Recherche Agronomique
Campus International de Baillarguet, CS 30016
34988 Montferrier-sur-Lez (France)

phone:  +33(0)4.99.62.33.70
fax:    +33(0)4.99.62.33.45
e-mail: miguel.navascues AT supagro.inra.fr
e-mail: m.navascues AT gmail.com
Skype:  m.navascues
web:    http://www1.montpellier.inra.fr/cbgp/
web:    http://sites.google.com/site/navascuesresearch/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Barplot.pdf
Type: video/x-flv
Size: 109173 bytes
Desc: not available
URL: <http://lists.r-forge.r-project.org/pipermail/adegenet-forum/attachments/20140106/b5eef484/attachment-0001.flv>


More information about the adegenet-forum mailing list