forked from lch14forever/hospital_microbiome
-
Notifications
You must be signed in to change notification settings - Fork 5
/
sup8.diversity_after_antibiotics.Rmd
58 lines (50 loc) · 1.71 KB
/
sup8.diversity_after_antibiotics.Rmd
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
---
title: "Violin plots showing the distribution of genus-level diversity metrics for various culture-enriched communities"
output:
html_document:
df_print: paged
---
### Nanopore diversity plot
Load generic libraries
```{r}
source('configuration.r')
```
Load plot specific libraries
```{r message=FALSE}
library(vegan)
library(reshape2)
```
Sup. Fig. 6
```{r}
df.mapping <- read.table('../metadata/nanopore.metadata.txt',head=T,sep='\t')
df.nanopore <- read.table('../tables/nanopore.kraken.table.g',head=T,sep='\t',row.names=1)
df.nanopore[df.nanopore < 0.1] <- 0
df.nanopore <- df.nanopore[rowSums(df.nanopore)>0, ]
shan=data.frame(diversity(t(df.nanopore),index="shannon"))
simp=data.frame(diversity(t(df.nanopore),index="simpson"))
shan= mutate(shan,Library=rownames(shan))
simp= mutate(simp,Library=rownames(simp))
colnames(shan)[1]="Shannon"
colnames(simp)[1]="Simpson"
diversity=merge(shan,df.mapping,by.x="Library",by.y="Nanopore_ID")
diversity=merge(diversity,simp,by="Library")
diversity1=select(diversity,Antibiotics,Simpson,Shannon)
diversity1=melt(diversity1,id="Antibiotics")
level_order <- c('BHI', 'AMP', 'CHLOR', 'KAN', 'STREP', 'TET')
diversity1 <- mutate(diversity1, Antibiotics=factor(Antibiotics,level=level_order, ordered = T))
g.a <- ggplot(data = diversity1, aes(x=Antibiotics,y=value,fill=Antibiotics)) +
geom_violin() +
theme(axis.text.x = element_text(angle=40, hjust=1, size=18)) +
scale_fill_manual(values=pal_simpsons(c("springfield"))(16)[-c(2,8)])+
labs(x='Antibiotics', y='Diversity') +
facet_wrap(~variable,nrow=2,scale="free_y")
g.a
```
Save plot
```{r fig.height=10, fig.width=10}
ggsave('../plots/sup8.svg', g.a, width = 10, height = 5)
```
### Session informaton
```{r}
sessionInfo()
```