-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFigure2_imputation.Rmd
143 lines (107 loc) · 4.56 KB
/
Figure2_imputation.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
---
title: "Figure2_imputation"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r message=FALSE}
library(plyr)
library(dplyr)
library(tidyr)
library(tibble)
library(ggplot2)
library(ComplexHeatmap)
set.seed(4242)
library(ggcorrplot)
library(corrplot)
library(circlize)
library(RColorBrewer)
library(viridis)
library(readxl)
```
# Figure 2.A
```{r}
fragment_comb <- read.table("./main_fig_data/foldchnge_fragment_9_unnorm.txt", sep = "\t", stringsAsFactors = FALSE)
colnames(fragment_comb) <-as.data.frame(fragment_comb[1,])
fragment_comb <- as.data.frame(fragment_comb[-1,])
fragment_comb <- filter(fragment_comb, !imputation == "imputation")
fragment_comb[, 3] <- lapply(3, function(x) as.numeric(fragment_comb[[x]]))
fragment_comb$imputation[grep("no_imp", fragment_comb$imputation)] <- "None"
fragment_comb$imputation[grep("zero_imp", fragment_comb$imputation)] <- "Zero"
fragment_comb$imputation[grep("minDet_imp", fragment_comb$imputation)] <- "minDet"
fragment_comb$imputation[grep("minProb_imp", fragment_comb$imputation)] <- "minProb"
fragment_comb$imputation[grep("svd_imp", fragment_comb$imputation)] <- "SVDmethod"
fragment_comb$imputation[grep("bpca_imp", fragment_comb$imputation)] <- "BPCA"
fragment_comb$imputation[grep("knn_imp", fragment_comb$imputation)] <- "KNNmethod"
fragment_comb$imputation[grep("lls_imp", fragment_comb$imputation)] <- "LLS"
fragment_comb$imputation[grep("rf_imp", fragment_comb$imputation)] <- "Random Forest"
fragment_comb$imputation <- factor(fragment_comb$imputation, levels = unique(fragment_comb$imputation), ordered = TRUE)
imp_methods_col <- c('#e41a1c','#377eb8','#4daf4a','#984ea3','#ff7f00','#ffff33','#a65628','#f781bf','#999999')
colnames(fragment_comb)
fragment_comb$load[grep("high_med", fragment_comb$load)] <- "high-med"
fragment_comb$load[grep("high_low", fragment_comb$load)] <- "high-low"
fragment_comb$load[grep("med_low", fragment_comb$load)] <- "med-low"
ggplot(fragment_comb, aes(x = load, y = foldchange, fill = imputation)) +
geom_boxplot() +
theme_bw() +
theme(text = element_text(size = 35)) +
scale_y_continuous(breaks=seq(-14, 15, 1)) +
geom_hline(yintercept = 2) +
geom_hline(yintercept = 1) +
scale_fill_manual(values = imp_methods_col) +
labs(y = "Fold Change", x = "Sample Concentration")
```
# Figure 2.B
```{r}
comb_imp_foldchnge <- read.csv("./main_fig_data/comb_imp_foldchnge.csv")
comb_imp_foldchnge <- as.data.frame(comb_imp_foldchnge[,-1])
colnames(comb_imp_foldchnge) <- c("Random Forest", "LLS", "KNNmethod",
"BPCA", "SVDmethod", "minProb", "minDet",
"Zero", "None", "Ideal")
corr_foldchnge_imp <- cor(comb_imp_foldchnge)
p.imp <- cor_pmat(comb_imp_foldchnge)
corr_foldchnge_imp <- as.matrix(corr_foldchnge_imp)
column_ha = HeatmapAnnotation(correlation_coefficient = anno_barplot(corr_foldchnge_imp[c(1:10), 10]),
annotation_name_gp= gpar(fontsize = 15))
hmap <- Heatmap(
corr_foldchnge_imp,
show_row_names = T,
show_column_names = T,
cluster_rows = TRUE,
cluster_columns = TRUE,
show_column_dend = TRUE,
show_row_dend = TRUE,
row_dend_reorder = TRUE,
column_dend_reorder = TRUE,
clustering_method_rows = "ward.D2",
clustering_method_columns = "ward.D2",
width = unit(100, "mm"),
heatmap_legend_param = list(
title = "Pearson's correlation coefficient",
title_position = "topcenter",
direction = "horizontal"),
row_names_gp = gpar(fontsize = 20),
column_names_gp = gpar(fontsize = 20))
draw(hmap, heatmap_legend_side="bottom")
```
# Figure 2.C
```{r}
rsr_fragment_imp <- read.csv("./main_fig_data/rsr_fragment_imp.csv", stringsAsFactors = F)
rsr_fragment_imp$imputation <- c("Ideal", "None", "Zero", "minDet", "minProb",
"SVDmethod", "BPCA", "KNNmethod", "LLS","Random Forest")
label_V1 <- rsr_fragment_imp$V1
label_V1 <- round(label_V1, digits = 2)
rsr_fragment_imp$imputation <- factor(rsr_fragment_imp$imputation,
levels = unique(rsr_fragment_imp$imputation),ordered = TRUE)
ggplot(rsr_fragment_imp, aes(x = imputation, y = V1, fill = imputation)) +
geom_col(color = "black") +
scale_fill_manual(values = c("black", imp_methods_col)) +
theme_bw() +
labs(x = "Imputation Methods", y = "Ratio of RMSE to the standard deviation") +
geom_text(aes(label=label_V1), position=position_dodge(width=0.9), vjust=-0.25,
size = 10) +
theme(text = element_text(size = 35),
axis.text.x = element_blank(),
axis.ticks.x=element_blank())
```