@@ -184,18 +184,18 @@ combined_results_graph <- function(combined_df, selected_terms = "common",
184
184
missing_B <- ! cond_up_B & ! cond_down_B
185
185
186
186
up_cond <- (cond_up_A & cond_up_B ) | (missing_A & cond_up_B ) | (cond_up_A & missing_B )
187
- down_cond <- cond_down_A & cond_down_B | (missing_A & cond_down_B ) | (cond_down_A & missing_B )
187
+ down_cond <- ( cond_down_A & cond_down_B ) | (missing_A & cond_down_B ) | (cond_down_A & missing_B )
188
188
189
- igraph :: V(g )$ color <- ifelse(igraph :: V(g )$ type == " common term" , " #FCCA46 " ,
190
- ifelse(igraph :: V(g )$ type == " A-only term" , " #9FB8AD " ,
191
- ifelse(igraph :: V(g )$ type == " B-only term" , " #619B8A " ,
192
- ifelse(up_cond , " green " ,
193
- ifelse(down_cond , " red " , " gray " )))))
189
+ igraph :: V(g )$ for_coloring <- ifelse(igraph :: V(g )$ type == " common term" , " Common term " ,
190
+ ifelse(igraph :: V(g )$ type == " A-only term" , " A-only term " ,
191
+ ifelse(igraph :: V(g )$ type == " B-only term" , " B-only term " ,
192
+ ifelse(up_cond , " Up gene " ,
193
+ ifelse(down_cond , " Down gene " , " Conflicting gene " )))))
194
194
195
195
# ## Create graph
196
196
p <- ggraph :: ggraph(g , layout = layout )
197
197
p <- p + ggraph :: geom_edge_link(alpha = .8 , colour = " darkgrey" )
198
- p <- p + ggraph :: geom_node_point(ggplot2 :: aes_(color = ~ I( color ) , size = ~ size ))
198
+ p <- p + ggraph :: geom_node_point(ggplot2 :: aes_(color = ~ for_coloring , size = ~ size ))
199
199
p <- p + ggplot2 :: scale_size(range = c(5 , 10 ),
200
200
breaks = round(seq(round(min(igraph :: V(g )$ size )),
201
201
round(max(igraph :: V(g )$ size )),
@@ -204,15 +204,13 @@ combined_results_graph <- function(combined_df, selected_terms = "common",
204
204
p <- p + ggplot2 :: theme_void()
205
205
p <- p + ggraph :: geom_node_text(ggplot2 :: aes_(label = ~ name ), nudge_y = .2 )
206
206
207
- cols <- unique(igraph :: V(g )$ color )
208
- lbls <- ifelse(cols == " #FCCA46" , " Common term" ,
209
- ifelse(cols == " #9FB8AD" , " A-only term" ,
210
- ifelse(cols == " #619B8A" , " B-only term" ,
211
- ifelse(cols == " green" , " Up gene" ,
212
- ifelse(cols == " red" , " Down gene" , " Conflicting gene" )))))
213
- p <- p + ggplot2 :: scale_colour_manual(values = cols ,
214
- name = NULL ,
215
- labels = lbls )
207
+ vertex_cols <- c(" Common term" = " #FCCA46" ,
208
+ " A-only term" = " #9FB8AD" ,
209
+ " B-only term" = " #619B8A" ,
210
+ " Up gene" = " green" ,
211
+ " Down gene" = " red" ,
212
+ " Conflicting gene" = " gray" )
213
+ p <- p + ggplot2 :: scale_colour_manual(values = vertex_cols )
216
214
p <- p + ggplot2 :: ggtitle(" Combined Terms Graph" )
217
215
p <- p + ggplot2 :: theme(plot.title = ggplot2 :: element_text(hjust = 0.5 ))
218
216
return (p )
0 commit comments