-
Notifications
You must be signed in to change notification settings - Fork 1
/
evaluation_plots_all.Rmd
241 lines (175 loc) · 9.56 KB
/
evaluation_plots_all.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
---
title: "R Notebook"
output: html_notebook
---
This is an [R Markdown](http://rmarkdown.rstudio.com) Notebook. When you execute code within the notebook, the results appear beneath the code.
Try executing this chunk by clicking the *Run* button within the chunk or by placing your cursor inside it and pressing *Cmd+Shift+Enter*.
```{r}
###Use dictionary to set appropriate figure names
figure_names <- c(
'Neuroinflammation' = 'Figure 1c:\nNeuroinflammation',
'Covid19' = 'Figure 1a:\nCovid 19 Drugs',
'DS' = 'Figure 1b:\nInsulin Resistance'
)
```
```{r}
###Color panel used
cbp1 <- c("#999999", "#E69F00", "#56B4E9", "#009E73",
"#F0E442", "#0072B2", "#D55E00", "#CC79A7")
```
```{r}
library(ggplot2)
library(tidyr)
library(gridExtra)
#Compares the unique edge types in each subgraph for cs/pdp, intent is to show this for each cartoon in a different figure
output_figure_datasets <- function(output_dir,...) {
plots <- list()
all_figures <- list(...)
for (i in 1:length(all_figures)){
print(all_figures[[i]])
f <- paste(output_dir,'/Figures/',all_figures[i],'/Outputs/Evaluation_Files/edge_type_comparison.csv',sep="")
edge_type_comparison <- read.table(f, sep = ',', header = TRUE)
edge_type_comparison_long <- gather(edge_type_comparison,algorithm,count,pdp,cs,factor_key=TRUE)
p <- ggplot(edge_type_comparison_long, aes(x=Edge_Type, y=count, fill=algorithm)) +
#theme_bw(base_size = 20) + scale_fill_grey() +
geom_bar(stat='identity',position = position_dodge(),width = 0.4,colour="black") +
scale_fill_manual('Ranking Algorithm',labels=c('Path-Degree Product', 'Cosine Similarity'),values = cbp1) +
labs(title = figure_names[i],
x= 'Edge Type',
y='Count (Normalized)') +
theme_bw() + theme(axis.text.x=element_text(vjust=0.6,angle = 45,size = 18), panel.border = element_blank(), panel.grid.major = element_blank(),
panel.grid.minor = element_blank(), axis.line = element_line(colour = "black"),plot.title = element_text(hjust = 0.5),legend.text = element_text(size = 16),text = element_text(size = 20))
plots[[i]] = p
}
return(plots)
}
p <- output_figure_datasets(output_dir,'Neuroinflammation','Covid19','DS')
do.call("grid.arrange", c(p, ncol=1))
fig <- plot_grid(plotlist=p,ncol = 1)
ggsave(paste(output_dir,"/Figures/edge_type_comparison.png",sep=''), plot = fig, width = 30, height = 40, units = "cm")
```
```{r}
library(ggplot2)
library(tidyr)
#Compares the number of unique nodes in each subgraph for cs/pdp, intent is to show this for each cartoon in the same figure
combine_figure_datasets <- function(output_dir,...) {
all_figures <- list(...)
num_nodes_comparison <- data.frame(matrix(ncol = 2, nrow = 0))
colnames(num_nodes_comparison) <- c('pdp','cs')
for (i in all_figures){
f <- paste(output_dir,'/Figures/',i,'/Outputs/Evaluation_Files/num_nodes_comparison.csv',sep="")
df <- read.table(f, sep = ',', header = TRUE)
df$Figure <-rep(c(i),each=nrow(df))
num_nodes_comparison <- rbind(num_nodes_comparison, df)
}
num_nodes_comparison_long <- gather(num_nodes_comparison,algorithm,count,pdp,cs,factor_key=TRUE)
return(num_nodes_comparison_long)
}
output_dir <- '/Users/brooksantangelo/Documents/HunterLab/Cartoomics'
num_nodes_comparison_long <- combine_figure_datasets(output_dir,'Neuroinflammation','Covid19','DS')
print(num_nodes_comparison_long)
p <- ggplot(num_nodes_comparison_long, aes(x=Figure, y=count, fill=algorithm)) +
geom_bar(stat='identity',position = position_dodge(),width = 0.4,colour="black") +
#theme_bw(base_size = 20) +
scale_fill_manual('Ranking Algorithm',labels=c('Path-Degree Product', 'Cosine Similarity'),values = cbp1) +
scale_x_discrete(labels=c(figure_names['Covid19'],figure_names['DS'],figure_names['Neuroinflammation'])) +
#theme(axis.text.x=element_text(angle = 90)) +
labs(title = 'Number of Nodes per Subgraph',
x= 'Example Figure',
y='Total # Nodes') +
theme_bw() + theme(panel.border = element_blank(), panel.grid.major = element_blank(),
panel.grid.minor = element_blank(), axis.line = element_line(colour = "black"),plot.title = element_text(hjust = 0.5))
p
ggsave(paste(output_dir,"/Figures/num_nodes_comparison.png",sep=''), plot = p, width = 20, height = 10, units = "cm")
```
```{r}
#Compares the path length of all pairs in a subgraph, intent is to show this for each cartoon in the same figure
path_length_comparison <- read.table('/Users/brooksantangelo/Documents/HunterLab/Cartoomics/Figures/Neuroinflammation/Outputs/Evaluation_Files/path_length_comparison.csv', sep = ',', header = TRUE)
path_length_comparison_long <- gather(path_length_comparison,algorithm,count,pdp,cs,factor_key=TRUE)
#Combine multiple datasets for each figure
combine_figure_datasets <- function(output_dir,...) {
all_figures <- list(...)
path_length_comparison <- data.frame(matrix(ncol = 2, nrow = 0))
colnames(path_length_comparison) <- c('pdp','cs')
for (i in all_figures){
f <- paste(output_dir,'/Figures/',i,'/Outputs/Evaluation_Files/path_length_comparison.csv',sep="")
df <- read.table(f, sep = ',', header = TRUE)
df$Figure <-rep(c(i),each=nrow(df))
path_length_comparison <- rbind(path_length_comparison, df)
}
path_length_comparison_long <- gather(path_length_comparison,algorithm,count,pdp,cs,factor_key=TRUE)
return(path_length_comparison_long)
}
output_dir <- '/Users/brooksantangelo/Documents/HunterLab/Cartoomics'
path_length_comparison_long <- combine_figure_datasets(output_dir,'Neuroinflammation','Covid19','DS')
p <- ggplot(path_length_comparison_long, aes(x=Figure, y=count, fill=algorithm)) +
geom_boxplot() +
scale_fill_manual('Ranking Algorithm',labels=c('Path-Degree Product', 'Cosine Similarity'),values = cbp1) +
scale_x_discrete(labels=c(figure_names['Covid19'],figure_names['DS'],figure_names['Neuroinflammation'])) +
geom_jitter(height = 0, width = 0.3, alpha=0.3) +
labs(title = 'Distribution of Path Length',
x= 'Example Figure',
y='Path Length') +
theme_bw() + theme(panel.border = element_blank(), panel.grid.major = element_blank(),
panel.grid.minor = element_blank(), axis.line = element_line(colour = "black"),plot.title = element_text(hjust = 0.5))
p
ggsave(paste(output_dir,"/Figures/path_length_comparison.png",sep=''), plot = p, width = 20, height = 10, units = "cm")
```
```{r}
#Compares the ranking of each path for a pair in each figure
combine_figure_datasets <- function(output_dir,...) {
all_figures <- list(...)
ranked_comparison <- data.frame(matrix(ncol = 2, nrow = 0))
colnames(ranked_comparison) <- c('pdp','cs')
for (i in all_figures){
f <- paste(output_dir,'/Figures/',i,'/Outputs/Evaluation_Files/ranked_comparison.csv',sep="")
df <- read.table(f, sep = ',', header = TRUE)
df$Figure <-rep(c(i),each=nrow(df))
ranked_comparison <- rbind(ranked_comparison, df)
}
return(ranked_comparison)
}
output_dir <- '/Users/brooksantangelo/Documents/HunterLab/Cartoomics'
ranked_comparison <- combine_figure_datasets(output_dir,'Neuroinflammation','DS') #'Covid19'
ranked_comparison$cs <-ranked_comparison$cs + 1
ranked_comparison$pdp <-ranked_comparison$pdp + 1
p <- ggplot(data = ranked_comparison, aes(x=cs, y=pdp, color=Figure)) +
geom_point() +
scale_color_manual('Example Figure',labels=c(figure_names['DS'],figure_names['Neuroinflammation']),values = cbp1) + #figure_names['Covid19']
geom_smooth(method = 'lm', se = FALSE) +
labs(title = 'Prioritization of All Shortest Paths',
x= 'Path Rank (Cosine Similarity)',
y='Path Rank (Path-Degree Product)') +
theme_bw() + theme(panel.border = element_blank(), panel.grid.major = element_blank(),
panel.grid.minor = element_blank(), axis.line = element_line(colour = "black"),plot.title = element_text(hjust = 0.5))
p
ggsave(paste(output_dir,"/Figures/ranked_comparison_noCovid.png",sep=''), plot = p, width = 15, height = 10, units = "cm")
```
```{r}
#Compares the unique intermediate node types in each subgraph for cs/pdp, intent is to show this for each cartoon in a different figure
output_figure_datasets <- function(output_dir,...) {
plots <- list()
all_figures <- list(...)
for (i in 1:length(all_figures)){
print(all_figures[[i]])
f <- paste(output_dir,'/Figures/',all_figures[i],'/Outputs/Evaluation_Files/intermediate_nodes_comparison.csv',sep="")
print(f)
intermediate_nodes_comparison <- read.table(f, sep = ',', header = TRUE)
intermediate_nodes_comparison_long <- gather(intermediate_nodes_comparison,algorithm,count,pdp,cs,factor_key=TRUE)
print(intermediate_nodes_comparison_long)
p <- ggplot(intermediate_nodes_comparison_long, aes(x=Ontology_Type, y=count, fill=algorithm)) +
geom_bar(stat='identity',position = position_dodge(),width = 0.4,colour="black") +
scale_fill_manual('Ranking Algorithm',labels=c('Path-Degree Product', 'Cosine Similarity'),values = cbp1) +
labs(title = figure_names[i],
x= 'Ontology Type',
y='Count (Normalized)') +
theme_bw() + theme(axis.text.x=element_text(vjust=0.6,angle = 45,size = 18), panel.border = element_blank(), panel.grid.major = element_blank(),
panel.grid.minor = element_blank(), axis.line = element_line(colour = "black"),plot.title = element_text(hjust = 0.5),legend.text = element_text(size = 16),text = element_text(size = 20))
plots[[i]] = p
}
return(plots)
}
p <- output_figure_datasets(output_dir,'Neuroinflammation','Covid19','DS')
fig <- plot_grid(plotlist=p,ncol = 1)
ggsave(paste(output_dir,"/Figures/intermediate_nodes_comparison.png",sep=''), plot = fig, width = 30, height = 40, units = "cm")
```