-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfigure_1b.R
50 lines (36 loc) · 1.27 KB
/
figure_1b.R
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
# cleanup
rm(list=ls())
library(ggplot2)
library(reshape2)
library(ggtern)
source("src/plot.functions.R") # all function for plotting
source("src/calc.functions.R") # functions for data manipulation
# path to files
path.L <- "data/OTU_table/otu_table_L3.txt" # path to L3 table
# load OTU table
raw.data <- read.table(path.L , header=T)
# remove outgroup
raw.data$outgroup <- NULL
# basic manipulation of otu table
raw.data <- makeOtu(raw.data, method = "proportion")
# remove genera with rel ab. < 1%
raw.data <- removeRelAb(raw.data, 0.01)
# transform data for barchart
raw.data.t <- t(raw.data)
# process tax ID
df <- processTaxaID(raw.data.t)
# assign colors to taxa
df$col <- taxCol(df$p, df$c)
jColors <- df$col
names(jColors) <- df$c
jColors <- jColors[order(names(jColors))]
# melt dataframe for plotting
df.m <- melt(df)
# calculate difference to healthy
df.diff <- processTaxaDiff(df, "healthy", c("AIH","control"))
df.diff$healthy <- NULL # remove control
df.diff.m <- melt(df.diff) # melt dataframe for plotting
# generate plots
#bar <- barplotClass(df, "results/figure2/figure_2_bar.pdf", tooSmall = 0.2)
#dif <- plotDifferenceClass(df.diff.m,"results/figure2/figure_2_diff.pdf", jColors)
tri <- triplotTaxaClass(df, "results/figure_1b_triplot.pdf", label=F, jColors)