Diff of /6-Figure scripts/Fig S7.R [000000] .. [16eabd]

Switch to unified view

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