Closed Robvh-git closed 1 year ago
Hi @Robvh-git It's because you added geom_point(size=4)
to the ggplot object when plot_ordination()
already produced the object with its own geom_point()
. Since there is no way to setting the point size while using the function, the dirty trick will be to make changes to the ggplot object itself, e.g.
library(phyloseq)
library(ggplot2)
data(GlobalPatterns)
GP = prune_taxa(names(sort(taxa_sums(GlobalPatterns), TRUE)[1:50]), GlobalPatterns)
sample_data(GP)$Shape = ifelse(sample_data(GP)$SampleType %in% c("Feces","Skin","Tongue"), "A", "B")
gp_bray_pcoa = ordinate(GP, "CCA", "bray")
# Plot
p = plot_ordination(GP, gp_bray_pcoa, "samples", color="SampleType", shape="Shape") +
scale_shape_manual(values = c("A" = 2, "B" = 3))
# Change the point size to 4
p$layers[[1]]$aes_params$size = 4
Hi @ycl6 thanks for the quick reply!
Aha that makes sense, thank you!
Your solution works, many thanks!
I'm analysing NGS data using the phyloseq package. I want to create a PCoA (Bray-curtis DM) plot using following code:
In the resulting plot, the shapes look like this:
As you can see, the shapes are plotted twice, at a different size within eachother. Also, if I would manually assign a 'filled' shape to a variable (e.g. shape code 22), it also does not appeared filled on the plot, but still has a empty fill.
When I run another geom_point() plot of ggplot2, I do get the good looking shapes.
How can I fix this?
(PS: I also posted this on stackoverflow, but now think it suits here better: https://stackoverflow.com/questions/76465183/plot-ordination-function-of-phyloseq-plots-shapes-double-within-itself_