joey711 / phyloseq

phyloseq is a set of classes, wrappers, and tools (in R) to make it easier to import, store, and analyze phylogenetic sequencing data; and to reproducibly share that data and analysis with others. See the phyloseq front page:
http://joey711.github.io/phyloseq/
582 stars 187 forks source link

transparency in plot_ordination #1531

Closed rjverheijden closed 2 years ago

rjverheijden commented 2 years ago

Hi there,

I am greatfully using the plot_ordination() function, but would like to set the transparency of the points in the PCoA plot (by using e.g. alpha = 0.5). As geom_point() is already inherently used in the plot_ordination() function , it is unable to set aesthetics that are not included in the plot_ordination() function like alpha, fill, etc.

I used a work-around for myself by removing the +geom_point(na.rm=TRUE) part from the function and manually specify it outside the function (just copy pasted function from your GitHub and adjusted it locally), which allows more flexibility, but obviously has some limitations as well.

Would it be possible to add the alpha and fill aesthetics in the plot_ordination() function or is there an alternative work-around which doesn't require running the function locally? Many thanks in advance!

https://github.com/joey711/phyloseq/blob/9b211d94fbe065e1d2c55d61177958ca15129bd5/R/plot-methods.R#L1116

rjverheijden commented 2 years ago

Ah I found another workaround which is much easier thanks to @vmikk: https://github.com/joey711/phyloseq/issues/515#issuecomment-946742728 just use plot_ordination(..., justDF = TRUE) and use the dataframe that it produces to plot the data:

DF<-plot_ordination(..., justDF = TRUE) ggplot(data = DF, aes(x=DF[,1], y=DF[,2], ...) + geom_point(alpha = 0.5, na.rm=TRUE)