abundances <- c(11.42, 8.71, 8.36, 6.72, 6.46, 5.24, 5.24, 3.13, 2.48, 2.22, 40.02)
microbes <- c("Bacteroides vulgatus", "Bacteroides uniformis", "Bacteroides fragilis", "Bacteroides eggerthii", "[Eubacterium] eligens", "Bacteroides cellulosilyticus",
"Faecalibacterium prausnitzii", "Bacteroides intestinalis", "Roseburia intestinalis", "Bacteroides salyersiae", "Other organisms")
dat <- data.frame(abundances=abundances, microbes=microbes, stringsAsFactors=FALSE)
dat = dat[order(dat$abundances), ] # order dataframe by abundances
dat$ymax = cumsum(dat$abundances) # create ymax column (similar to abundances)
dat$ymin = c(0, head(dat$ymax, n=-1)) # create ymin column (f)
dat$ymean = (dat$ymin + dat$ymax) / 2
# Make the plot
p1 = ggplot(dat, aes(fill=microbes, xmin=3, xmax=4, ymin=ymin, ymax=ymax)) +
geom_rect(colour="grey30") +
xlim(c(0, 4)) +
geom_text(data=dat, aes(x=3.5, y=ymean, label=abundances), size=3) +
coord_polar(theta="y") + # to obtain ring plot
theme_bw() + # ggplot theme
theme( panel.grid=element_blank()) + # to hide grid
theme( axis.text=element_blank()) + # to hide axis text
theme(axis.title.x=element_blank()) + # to hide x axis title
theme(axis.title.y=element_blank()) + # to hide y axis title
theme( axis.ticks=element_blank()) + # to hide axis ticks
labs(title="Top10 microbes") + # title
scale_fill_discrete(name = "Microbes") + # Change legend title
theme(plot.title = element_text(hjust = 0.5)) # Center plot title
p1