I am creating a relative abundance boxplot comparing two groups (pet, stray) using eight genera. However, the resulting plot displays almost zero values on the y-axis and only one value on the x-axis. I aim to generate a boxplot comparing the relative abundance of eight genera across two groups (pet, stray). How can I modify my code to achieve this?
I suspect that one genus has a significantly different scale of relative abundance, potentially causing the issue with the y-axis. If transforming the y-axis is an effective solution, please suggest appropriate transformations for the relative abundance values with revised code.
my R code is
library(ggplot2)
data <- read.csv("relative abundance raw data (putative pathogen).csv")
p<-ggplot(data, aes(x="Genus", y="Relative_abundance", fill="Group")) +
geom_boxplot(position = position_dodge(width = 0.8), alpha = 0.8) +
labs(title = "Relative Abundance Comparison",
x = "Genus",
y = "Relative Abundance",
fill = "Group") +
theme_minimal() +
scale_fill_manual(values = c("stray" = "blue", "pet" = "red"))
p + geom_jitter(shape=16, position=position_jitter(0.2))
the result figure :
my raw data format is :
My raw data file can be downloaded here : https://drive.google.com/file/d/1Dxy2EqqgC2BQK6b92gRHSI5t7DtA29YA/view?usp=sharing
Thank you for your assistance !
Thank you dear !!!
I have one more question, the box doesn't show color as I intended... What should be chaged from the code ?
In
scale_fill_manual
you have e.g."stray"
but in your data it's"Stray"
. Just make sure the cases match.Thank you!! I really appreciate your help.