[16eabd]: / 6-Figure scripts / Fig S7.R

Download this file

66 lines (46 with data), 2.1 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
library(readxl)
excel_sheets("Fig S7 Source Data.xlsx")
# Figure S7 a ----------------------------
dat <- read_excel("Fig S7 Source Data.xlsx", sheet = "Shannon")
head(dat)
library(ggplot2)
FigS7a <- ggplot(dat) +
geom_boxplot(aes(x=Group,y=Shannon,fill=Group),alpha=0.5,outlier.shape = NA) +
geom_jitter(aes(x=Group,y=Shannon,fill=Group),shape=21, width = 0.2,size=2) +
theme_bw() + theme(panel.grid = element_blank())+
xlab("") + ggtitle("Shannon index for \n K01426 contribution")
# wilcox
w=wilcox.test(Shannon~Group,data = dat)
w$p.value #0.006
# Figure S7 b ----------------------------
dat <- read_excel("Fig S7 Source Data.xlsx", sheet = "Contribution")
colnames(dat)[1] <- "Species"
library(RColorBrewer)
nb.cols = 17
mycolors <- colorRampPalette(brewer.pal(12, "Paired"))(nb.cols)
library(scales)
show_col(mycolors)
# rank
species_rank <- c(dat$Species[dat$Species != "Others"],"Others")
dat <- reshape2::melt(dat, id.var="Species")
dat$Species <- factor(dat$Species, levels = rev(species_rank))
FigS7b <- ggplot(dat) +
geom_col(aes(x=variable,y=value,fill=Species))+
scale_fill_manual(values = c("gray",rev(mycolors)))+
theme_bw() + theme(panel.grid = element_blank())+
xlab("") + ylab("RPKM")+ ggtitle("Contribution to K01426")
# Figure S7c ------------------------------------
dat <- read_excel("Fig S7 Source Data.xlsx", sheet = "Differential contribution")
colnames(dat)[1] <- "Species"
library(ggrepel)
FigS7c <- ggplot(dat) +
geom_point(aes(x=FC, y=log10P), size=2, alpha=0.5, fill="gray", shape=21)+
theme_bw() + theme(panel.grid = element_blank())+
geom_text_repel(aes(x=FC, y=log10P, label=Label)) +
geom_hline(yintercept = 1.3, color="red", size=0.3, linetype="dashed")+
geom_vline(xintercept = 0, color="darkgray", size=0.3, linetype="dashed")+
xlab("Fold-change of contribution to K01426") + ylab("minus log10 P-value") +
ggtitle("Differential contribution to K01426")
library(ggpubr)
FigS7 <- ggarrange(FigS7a, FigS7b, FigS7c,ncol = 3)
FigS7