|
a |
|
b/6-Figure scripts/Fig 1.r |
|
|
1 |
library(readxl) |
|
|
2 |
library(dplyr) |
|
|
3 |
|
|
|
4 |
# Figure 1a ------------------------------------------ |
|
|
5 |
# Figure 1a. taxonomy ####### |
|
|
6 |
rm(list = ls()) |
|
|
7 |
dat.taxa <- read_excel("Fig 1 Source Data.xlsx", sheet = "Fig 1a taxonomy PCA") |
|
|
8 |
dat.funct <- read_excel("Fig 1 Source Data.xlsx", sheet = "Fig 1a metagenome PCA") |
|
|
9 |
|
|
|
10 |
pca <- dat.taxa |
|
|
11 |
Fig1a.taxa.pca <- ggplot(pca,aes(PC1,PC2))+ |
|
|
12 |
geom_point(size=2,aes(col=Disease,shape=Cohort))+ |
|
|
13 |
scale_color_manual(values=c("#f0999f","#46bbc0"))+ |
|
|
14 |
scale_shape_manual(values=c(16,15)) + |
|
|
15 |
theme_bw()+theme(axis.line = element_line(colour = "black"), |
|
|
16 |
panel.grid.major = element_blank(), |
|
|
17 |
panel.grid.minor = element_blank(), |
|
|
18 |
panel.background = element_blank()) |
|
|
19 |
|
|
|
20 |
pca$Group = paste(pca$Disease,"|", pca$Cohort,sep = "") |
|
|
21 |
Fig1a.taxa.pca |
|
|
22 |
|
|
|
23 |
Fig1a.taxa.pc1.density <- |
|
|
24 |
ggplot(pca) + |
|
|
25 |
geom_density(aes(x=PC1, group=Group, fill=Disease, linetype=Cohort), |
|
|
26 |
color="black", alpha=0.6, position = 'identity') + |
|
|
27 |
scale_fill_manual(values=c("#f0999f","#46bbc0")) + |
|
|
28 |
theme_bw() + |
|
|
29 |
scale_linetype_manual(values = c("solid","dashed"))+ |
|
|
30 |
labs(fill="") |
|
|
31 |
Fig1a.taxa.pc1.density |
|
|
32 |
|
|
|
33 |
Fig1a.taxa.pc2.density <- |
|
|
34 |
ggplot(pca) + |
|
|
35 |
geom_density(aes(x=PC2, group=Group, fill=Disease, linetype=Cohort), |
|
|
36 |
color="black", alpha=0.6, position = 'identity') + |
|
|
37 |
scale_fill_manual(values=c("#f0999f","#46bbc0")) + |
|
|
38 |
theme_bw() + |
|
|
39 |
scale_linetype_manual(values = c("solid","dashed"))+ |
|
|
40 |
labs(fill="") + |
|
|
41 |
coord_flip() |
|
|
42 |
Fig1a.taxa.pc2.density |
|
|
43 |
|
|
|
44 |
# Figure 1a. function ####### |
|
|
45 |
|
|
|
46 |
pca <- dat.funct |
|
|
47 |
Fig1a.function.pca <- ggplot(pca,aes(PC1,PC2))+ |
|
|
48 |
geom_point(size=2, aes(col=Disease,shape=Cohort))+ |
|
|
49 |
scale_color_manual(values=c("#f0999f","#46bbc0"))+ |
|
|
50 |
scale_shape_manual(values=c(16,15)) + |
|
|
51 |
theme_bw()+theme(axis.line = element_line(colour = "black"), |
|
|
52 |
panel.grid.major = element_blank(), |
|
|
53 |
panel.grid.minor = element_blank(), |
|
|
54 |
panel.background = element_blank()) |
|
|
55 |
|
|
|
56 |
pca$Group = paste(pca$Disease,"|", pca$Cohort,sep = "") |
|
|
57 |
Fig1a.function.pca |
|
|
58 |
|
|
|
59 |
Fig1a.function.pc1.density <- |
|
|
60 |
ggplot(pca) + |
|
|
61 |
geom_density(aes(x=PC1, group=Group, fill=Disease, linetype=Cohort), |
|
|
62 |
color="black", alpha=0.6, position = 'identity') + |
|
|
63 |
scale_fill_manual(values=c("#f0999f","#46bbc0")) + |
|
|
64 |
theme_bw() + |
|
|
65 |
scale_linetype_manual(values = c("solid","dashed"))+ |
|
|
66 |
labs(fill="") |
|
|
67 |
Fig1a.function.pc1.density |
|
|
68 |
|
|
|
69 |
Fig1a.function.pc2.density <- |
|
|
70 |
ggplot(pca) + |
|
|
71 |
geom_density(aes(x=PC2, group=Group, fill=Disease, linetype=Cohort), |
|
|
72 |
color="black", alpha=0.6, position = 'identity') + |
|
|
73 |
scale_fill_manual(values=c("#f0999f","#46bbc0")) + |
|
|
74 |
theme_bw() + |
|
|
75 |
scale_linetype_manual(values = c("solid","dashed"))+ |
|
|
76 |
labs(fill="") + |
|
|
77 |
coord_flip() |
|
|
78 |
Fig1a.function.pc2.density |
|
|
79 |
|
|
|
80 |
|
|
|
81 |
|
|
|
82 |
# Figure 1b. -------------------------------------------- |
|
|
83 |
rm(list = ls()) |
|
|
84 |
library(reshape2) |
|
|
85 |
dat <- read_excel("Fig 1 Source Data.xlsx", sheet ="Fig 1b species abund") |
|
|
86 |
data2<-melt(dat,id.vals=c("NAME","Disease")) |
|
|
87 |
species=factor(data2$variable, |
|
|
88 |
levels=c("Moraxella_catarrhalis","Pseudomonas_aeruginosa","Haemophilus_parahaemolyticus","Stenotrophomonas_maltophilia","Streptococcus_intermedius","Acinetobacter_johnsonii","Neisseria_subflava","Prevotella_melaninogenica","Prevotella_intermedia","Haemophilus_parainfluenzae","Mogibacterium_diversum","Fusobacterium_pseudoperio.","Fusobacterium_nucleatum","Neisseria_flavescens","Porphyromonas_gingivalis","Veillonella_parvula","Lactobacillus_oris","Prevotella_scopos","Neisseria_meningitidis","Campylobacter_concisus","Prevotella_sp_oral_taxon_299","Neisseria_elongata","Filifactor_alocis","Prevotella_denticola","Parvimonas_micra","Treponema_sp_OMZ_838","Tannerella_sp_oral_taxon_286","Prevotella_fusca","Treponema_denticola","Tannerella_forsythia","Capnocytophaga_gingivalis")) |
|
|
89 |
Fig1b <- ggplot(data2,aes(x=species,y=data2$value),colour=factor(data2$Disease))+ |
|
|
90 |
geom_boxplot(aes(fill=data2$Disease),outlier.colour=NULL,outlier.shape=21,outlier.size=2)+ |
|
|
91 |
ylim(0,0.5)+ |
|
|
92 |
scale_fill_manual(values=c("#f0999f","#46bbc0"))+ |
|
|
93 |
xlab("") + ylab("Normalized relative abundance") + |
|
|
94 |
theme_bw()+theme(axis.line = element_line(colour = "black"), |
|
|
95 |
panel.grid.major = element_blank(), |
|
|
96 |
panel.grid.minor = element_blank(), |
|
|
97 |
# panel.border = element_blank(), |
|
|
98 |
panel.background = element_blank(), |
|
|
99 |
axis.text.x=element_text(angle=90, hjust=1, vjust=0.3, color="black",size=11), |
|
|
100 |
axis.text.y=element_text(color="black",size=11), |
|
|
101 |
axis.title.x=element_text(), |
|
|
102 |
axis.title.y=element_text()) |
|
|
103 |
|
|
|
104 |
Fig1b |