michaelgreenacre / CODAinPractice

Compositional Data Analysis in Practice
35 stars 9 forks source link

Repel labels in PLOT.RDA function #1

Closed magibc closed 1 year ago

magibc commented 2 years ago

Dear @michaelgreenacre

First of all, thank you for you R package easyCODA and your collaboration team (coda4microbiome).

In my microbiota study I'm trying to plot an RDA using PLOT.RDA() function.

PLOT.RDA(provaRDA2, map="symmetric", colrows = colcat[diagnosis] , colcats=colcat, rescale = 1, indcat = 1:11, pchrows = rep(19, nrow(x_no0)), cexs = c(1,1,1), fonts = c(2,4,2))

Nevertheless, the names of species appears overlapped. It is possible to use geom_text_repel(). I tried without success indicanting me the following error when I tried to use geom_text_repel() function.

Error in `validate_mapping()`:
! `mapping` must be created by `aes()`
Run `rlang::last_error()` to see where the error occurred.

Thanks on advance,

Magí.

michaelgreenacre commented 2 years ago

Hi Magi

This is a typical problem, overlapping labels. I see two solutions for you.

  1. You export the coordinates of the rows, columns and covariates (looks like categories in your case). These are in your RDA object provaRDA2, usually you would plot the row principal coordinates in $rowpcoord, the column standard coordinates in $colcoord, and the covariates in $covcoord. You will probably have to introduce scale factors for the columns and the covariates. So your use ggplot2 and its options then, and you have complete control over colours, symbols, labels, etc...
  2. You edit the map to de-overlap the labels manually (I usually do this since I don't use ggplot2). That is, export the PLOT.RDA map to PDF and use a PDF editor (I use the free one Inkscape, but you might have Adobe Illustrator...). Then shift labels very slightly to avoid the overlapping.

Best wishes Michael

with some of my songs below

My latest statistical song, The P-Value Song https://youtu.be/yy4nsEvKh2E. Also my renewable energy song Water Wind Sun & Sea http://www.youtube.com/watch?v=YAxfYA-oIVk‎ and the title track of my new album of original music, Below the Surface, with singer Gurdeep Stephens http://www.gurdeep.net, at michaelgreenacre.blogspot.com http://michaelgreenacre.blogspot.com/ See my new personal webpage at www.econ.upf.edu/~michael http://www.econ.upf.edu/~michael Get my free books at www.multivariatestatistics.org http://www.multivariatestatistics.org and www.carme-n.org http://www.carme-n.org

Michael Greenacre Departament d'Economia i Empresa Universitat Pompeu Fabra Ca l'Escopeter Ramon Trias Fargas 25-27 Sant Sebastià 3 Barcelona Sant Fruitòs de Bages 08005 Catalunya. Espanya 08272 Catalunya, Espanya @. @.> * @. @.>www.econ.upf.edu/~michael http://www.econ.upf.edu/~michael www.globalsong.net http://www.globalsong.net/ *

Listen to my statistical songs, sung by Gurdeep Stephens & Yuna Blum, including The SVD Song https://youtu.be/JEYLfIVvR9I at: www.youtube.com/StatisticalSongs http://www.youtube.com/StatisticalSongs

Follow the YouWomanGroup at: The Millennium Song, in Catalan, English subtitles www.youtube.com/YouWomanGroup http://www.youtube.com/YouWomanGroup www.youtube.com/GlobalSongProject http://www.youtube.com/GlobalSongProject

For continuing scientific and cultural activities Follow the Correspondence Analysis and in northern Norway, follow Arctic Frontiers at: Related Methods (CARME) network at: www.youtube.com/ArcticFrontiers http://www.youtube.com/ArcticFrontiers www.youtube.com/CARMEnetwork http://www.youtube.com/CARMEnetwork

On Sat, 13 Aug 2022 at 10:55, magibc @.***> wrote:

Dear @michaelgreenacre https://github.com/michaelgreenacre

First of all, thank you for you R package easyCODA and your collaboration team (coda4microbiome).

In my microbiota study I'm trying to plot an RDA using PLOT.RDA() function.

PLOT.RDA(provaRDA2, map="symmetric", colrows = colcat[diagnosis] , colcats=colcat, rescale = 1, indcat = 1:11, pchrows = rep(19, nrow(x_no0)), cexs = c(1,1,1), fonts = c(2,4,2))

Nevertheless, the names of species appears overlapped. It is possible to use geom_text_repel(). I tried without success indicanting me the following error when I tried to use geom_text_repel() function.

Error in validate_mapping():

! mapping must be created by aes()

Run rlang::last_error() to see where the error occurred.

Thanks on advance,

Magí.

— Reply to this email directly, view it on GitHub https://github.com/michaelgreenacre/CODAinPractice/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACXFPFGZPFE6ANSQSUYKLYLVY5PI3ANCNFSM56NZ4MNA . You are receiving this because you were mentioned.Message ID: @.***>

magibc commented 1 year ago

Thank you Michael. Sorry for the delay of my response.