rnodesigraphggraphtidygraph

ggraph node color and legend not matching


This is my tidygraph object which I'm trying to plot

hub_plot1
# A tbl_graph: 50 nodes and 540 edges
#
# An undirected simple graph with 2 components
#
# Node Data: 50 × 4 (active)
  name     mod         kme color
  <chr>    <chr>     <dbl> <chr>
1 CTSZ     turquoise 0.908 black
2 ATP6V0D1 turquoise 0.887 black
3 S100A6   turquoise 0.886 black
4 NADK     turquoise 0.869 black
5 PILRA    turquoise 0.869 black
6 SIRPA    turquoise 0.868 black
# … with 44 more rows
#
# Edge Data: 540 × 3
   from    to weight
  <int> <int>  <dbl>
1     1     2  0.587
2     1     3  0.493
3     1     4  0.641
# … with 537 more rows

Here as in my hubplot object i have two modules. My objective is to color all the nodes coming from a particular modules as the same color for example here my first module is turquoise I would like to label them the same color, here is the code which I'm using to generate the final plot where my desired graph network is generated but the node color and the legend color I'm not able to match.

sigmods <-  c("turquoise","blue") ## modules to plot

lapply(sigmods, function(col) {
    maxsize <- 25
    hubs <- data.frame(genes=hubgenes[[col]]$gene[1:maxsize], kme = hubgenes[[col]]$kme[1:maxsize], mod = rep(col,25))
}) %>% bind_rows() -> hub_plot1 



adj[hub_plot1$genes, hub_plot1$genes] %>% 
  graph.adjacency(mode = "undirected", weighted = T, diag = FALSE) %>%
  as_tbl_graph(g1) %>% upgrade_graph() %>% activate(nodes) %>% dplyr::mutate(mod=hub_plot1$mod) %>% 
  dplyr::mutate(kme=hub_plot1$kme) %>% activate(edges) %>% dplyr::filter(weight>.15) %>% activate(nodes) %>% 
  filter(!node_is_isolated()) %>% 
  dplyr::mutate(color = ifelse(name %in% c("YPEL1","MEGF6","SYNE1","SLC25A23","BCAR1"), yes="red", no="black")) -> hub_plot1

## code to plot
geneplot <- ggraph(hub_plot1,  layout = 'fr') + 
  geom_edge_link(color="darkgrey", aes(alpha = weight), show.legend = F)  + 
  scale_edge_width(range = c(0.2, 1)) + geom_node_text(aes(label = name, color=color), size=3, repel=T) +
  geom_node_point(aes(fill = mod, size=kme), shape=21, alpha=0.5) + 
  scale_size(range = c(1,5), name = "kME") +
  ggsci::scale_fill_npg(name="Module") +
  # guides(fill = guide_legend(override.aes = list(size=5)),
  #        size = guide_legend(override.aes = list(size=c(1,2,3,4)))) + 
   theme_graph(base_family="sans",base_size = 40)+ theme(legend.title.align=0.5,
                         legend.box = "horizontal", 
                         legend.position = c(0.9, 0.9),
                         legend.margin = margin(-0.5,0,0,0, unit="cm"),
                         legend.title = element_text(size=10),
                         legend.text = element_text(size=8)) +
  scale_color_manual(values=c("gray0","red")) + guides(color=FALSE) +
  coord_cartesian(clip="off")

My figure generated here we can see the blue module is colored not blue rather red! or orange not sure.

QUESTION How do I match node and the legend color? any suggestion or help would be really appreciated

network

UPDATE data

dput(hub_plot1)
structure(list(50, FALSE, c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 
12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 2, 3, 4, 
5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 
22, 23, 24, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 
17, 18, 19, 20, 21, 22, 23, 24, 4, 5, 6, 7, 8, 9, 10, 11, 12, 
13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 5, 6, 7, 8, 9, 
10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 6, 
7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 
23, 24, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 
21, 22, 23, 24, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 
20, 21, 22, 23, 24, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 
20, 21, 22, 23, 24, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 
21, 22, 23, 24, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 
23, 24, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 13, 
14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 14, 15, 16, 17, 18, 
19, 20, 21, 22, 23, 24, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 
16, 17, 18, 19, 20, 21, 22, 23, 24, 17, 18, 19, 20, 21, 22, 23, 
24, 18, 19, 20, 21, 22, 23, 24, 19, 20, 21, 22, 23, 24, 20, 21, 
22, 23, 24, 21, 22, 23, 24, 22, 23, 24, 23, 24, 24, 26, 27, 28, 
29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45, 
47, 48, 49, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 
40, 43, 44, 47, 48, 49, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 
38, 39, 40, 41, 42, 43, 44, 45, 47, 48, 29, 30, 31, 32, 33, 34, 
35, 36, 37, 38, 39, 40, 41, 42, 43, 45, 47, 48, 49, 30, 31, 32, 
33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 
49, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45, 46, 
47, 49, 32, 33, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 
47, 49, 33, 34, 35, 36, 37, 38, 39, 40, 42, 44, 45, 47, 48, 49, 
34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45, 46, 47, 48, 49, 35, 
36, 37, 39, 40, 43, 44, 47, 48, 36, 37, 38, 39, 40, 41, 42, 44, 
45, 46, 47, 48, 49, 37, 38, 39, 40, 41, 42, 43, 45, 46, 49, 39, 
40, 41, 44, 49, 39, 40, 41, 42, 43, 44, 45, 46, 47, 49, 40, 41, 
47, 48, 49, 41, 42, 44, 47, 42, 43, 45, 46, 49, 43, 44, 45, 46, 
47, 49, 45, 46, 49, 47, 48, 49, 46, 47, 49, 49, 48), c(0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 
3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 
4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 
5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 
9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 
10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 
12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 
13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 
15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 
17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 19, 19, 19, 
19, 19, 20, 20, 20, 20, 21, 21, 21, 22, 22, 23, 25, 25, 25, 25, 
25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 
25, 25, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 
26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 
27, 27, 27, 27, 27, 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 
28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 
30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 
30, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 
31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 
33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 
34, 34, 34, 34, 34, 34, 34, 35, 35, 35, 35, 35, 35, 35, 35, 35, 
35, 35, 35, 35, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 37, 37, 
37, 37, 37, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 39, 39, 39, 
39, 39, 40, 40, 40, 40, 41, 41, 41, 41, 41, 42, 42, 42, 42, 42, 
42, 43, 43, 43, 44, 44, 44, 45, 45, 45, 46, 47), c(0, 1, 24, 
2, 25, 47, 3, 26, 48, 69, 4, 27, 49, 70, 90, 5, 28, 50, 71, 91, 
110, 6, 29, 51, 72, 92, 111, 129, 7, 30, 52, 73, 93, 112, 130, 
147, 8, 31, 53, 74, 94, 113, 131, 148, 164, 9, 32, 54, 75, 95, 
114, 132, 149, 165, 180, 10, 33, 55, 76, 96, 115, 133, 150, 166, 
181, 195, 11, 34, 56, 77, 97, 116, 134, 151, 167, 182, 196, 209, 
12, 35, 57, 78, 98, 117, 135, 152, 168, 183, 197, 210, 222, 13, 
36, 58, 79, 99, 118, 136, 153, 169, 184, 198, 211, 223, 234, 
14, 37, 59, 80, 100, 119, 137, 154, 170, 185, 199, 212, 224, 
235, 245, 15, 38, 60, 81, 101, 120, 138, 155, 171, 186, 200, 
213, 225, 236, 246, 255, 16, 39, 61, 82, 102, 121, 139, 156, 
172, 187, 201, 214, 226, 237, 247, 256, 264, 17, 40, 62, 83, 
103, 122, 140, 157, 173, 188, 202, 215, 227, 238, 248, 257, 265, 
272, 18, 41, 63, 84, 104, 123, 141, 158, 174, 189, 203, 216, 
228, 239, 249, 258, 266, 273, 279, 19, 42, 64, 85, 105, 124, 
142, 159, 175, 190, 204, 217, 229, 240, 250, 259, 267, 274, 280, 
285, 20, 43, 65, 86, 106, 125, 143, 160, 176, 191, 205, 218, 
230, 241, 251, 260, 268, 275, 281, 286, 290, 21, 44, 66, 87, 
107, 126, 144, 161, 177, 192, 206, 219, 231, 242, 252, 261, 269, 
276, 282, 287, 291, 294, 22, 45, 67, 88, 108, 127, 145, 162, 
178, 193, 207, 220, 232, 243, 253, 262, 270, 277, 283, 288, 292, 
295, 297, 23, 46, 68, 89, 109, 128, 146, 163, 179, 194, 208, 
221, 233, 244, 254, 263, 271, 278, 284, 289, 293, 296, 298, 299, 
300, 301, 322, 302, 323, 341, 303, 324, 342, 361, 304, 325, 343, 
362, 380, 305, 326, 344, 363, 381, 400, 306, 327, 345, 364, 382, 
401, 417, 307, 328, 346, 365, 383, 402, 418, 433, 308, 329, 347, 
366, 384, 403, 434, 447, 309, 330, 348, 367, 385, 404, 419, 435, 
448, 462, 310, 331, 349, 368, 386, 405, 420, 436, 449, 463, 471, 
311, 332, 350, 369, 387, 406, 421, 437, 450, 464, 472, 484, 312, 
333, 351, 370, 388, 407, 422, 438, 451, 473, 485, 313, 334, 352, 
371, 389, 408, 423, 439, 452, 465, 474, 486, 494, 499, 314, 335, 
353, 372, 390, 409, 424, 440, 453, 466, 475, 487, 495, 500, 509, 
315, 354, 373, 391, 410, 425, 454, 476, 488, 496, 501, 510, 514, 
316, 355, 374, 392, 411, 426, 441, 455, 477, 489, 502, 515, 518, 
317, 336, 356, 375, 393, 412, 427, 456, 467, 490, 503, 519, 523, 
337, 357, 394, 428, 442, 468, 478, 497, 504, 516, 524, 318, 358, 
376, 395, 413, 429, 443, 457, 479, 491, 505, 520, 525, 529, 396, 
414, 430, 458, 480, 492, 506, 521, 526, 530, 535, 319, 338, 359, 
377, 397, 415, 431, 444, 459, 469, 481, 507, 511, 517, 527, 532, 
536, 320, 339, 360, 378, 398, 445, 460, 470, 482, 512, 533, 539, 
321, 340, 379, 399, 416, 432, 446, 461, 483, 493, 498, 508, 513, 
522, 528, 531, 534, 537, 538), c(0, 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, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 
248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 
261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 
274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 
287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 
300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 
313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 
326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 
339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 
352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 
365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 
378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 
391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 
404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 
417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 
430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 
443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 
456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468, 
469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 
482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 
495, 496, 497, 498, 499, 500, 501, 502, 503, 504, 505, 506, 507, 
508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 
521, 522, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 
534, 535, 536, 537, 538, 539), c(0, 0, 1, 3, 6, 10, 15, 21, 28, 
36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210, 231, 
253, 276, 300, 300, 301, 303, 306, 310, 315, 321, 328, 336, 344, 
354, 365, 377, 388, 402, 417, 430, 443, 456, 467, 481, 492, 509, 
521, 540), c(0, 24, 47, 69, 90, 110, 129, 147, 164, 180, 195, 
209, 222, 234, 245, 255, 264, 272, 279, 285, 290, 294, 297, 299, 
300, 300, 322, 341, 361, 380, 400, 417, 433, 447, 462, 471, 484, 
494, 499, 509, 514, 518, 523, 529, 532, 535, 538, 539, 540, 540, 
540), list(c(1, 0, 1), structure(list(), names = character(0)), 
    list(name = c("CTSZ", "ATP6V0D1", "S100A6", "NADK", "PILRA", 
    "SIRPA", "ZBTB7B", "IFNGR2", "MVP", "FRAT1", "CTSB", "TBC1D2", 
    "TFEB", "PSAP", "PTPN18", "OCEL1", "EFHD2", "SPI1", "BLOC1S1", 
    "HS1BP3", "CD68", "ARPC1B", "UBXN11", "FTL", "DOK2", "ZBTB8A", 
    "PRKCQ", "ERG", "MAST4", "CCDC171", "ZNF610", "ZNF571", "PRKCQ-AS1", 
    "NEDD4", "ZNF496", "IPO5P1", "ZNF772", "MYOZ3", "ZNF737", 
    "ZNF792", "KLHL23", "ZNF681", "ZNF493", "ZNF154", "MRPS31P5", 
    "ZNF91", "ZNF559-ZNF177", "ODF2L", "TRAF5", "ZNF781"), mod = c("turquoise", 
    "turquoise", "turquoise", "turquoise", "turquoise", "turquoise", 
    "turquoise", "turquoise", "turquoise", "turquoise", "turquoise", 
    "turquoise", "turquoise", "turquoise", "turquoise", "turquoise", 
    "turquoise", "turquoise", "turquoise", "turquoise", "turquoise", 
    "turquoise", "turquoise", "turquoise", "turquoise", "blue", 
    "blue", "blue", "blue", "blue", "blue", "blue", "blue", "blue", 
    "blue", "blue", "blue", "blue", "blue", "blue", "blue", "blue", 
    "blue", "blue", "blue", "blue", "blue", "blue", "blue", "blue"
    ), kme = c(0.908202550708176, 0.88696859487821, 0.886373699672794, 
    0.868944558964172, 0.868840728479905, 0.868295217044695, 
    0.860022491697271, 0.859608467009185, 0.858438605362727, 
    0.857344432987579, 0.856593822564897, 0.856372825369744, 
    0.854405284842672, 0.849804187161887, 0.849177806920511, 
    0.848750441691451, 0.847964316794339, 0.84308922611303, 0.842161760780816, 
    0.841574898461895, 0.839606309206986, 0.835504752905547, 
    0.835153610465851, 0.835133850804409, 0.834842240807777, 
    0.81944198612353, 0.811527617948752, 0.808145585444372, 0.804954244940244, 
    0.799606964613387, 0.799334946508982, 0.793351409643501, 
    0.779669269443535, 0.777026283859174, 0.772883904296972, 
    0.772847262644349, 0.766627286664148, 0.76285987468748, 0.756565868358268, 
    0.755598258462248, 0.755239568238221, 0.754816851365307, 
    0.754660968704501, 0.747298469686197, 0.743902230107152, 
    0.743348817185401, 0.742736965986213, 0.741665786296338, 
    0.740574738363986, 0.739340915833608), color = c("black", 
    "black", "black", "black", "black", "black", "black", "black", 
    "black", "black", "black", "black", "black", "black", "black", 
    "black", "black", "black", "black", "black", "black", "black", 
    "black", "black", "black", "black", "black", "black", "black", 
    "black", "black", "black", "black", "black", "black", "black", 
    "black", "black", "black", "black", "black", "black", "black", 
    "black", "black", "black", "black", "black", "black", "black"
    )), list(weight = c(0.587221700159896, 0.492737365080114, 
    0.641120541063917, 0.581167775527095, 0.579561066877488, 
    0.574137947179824, 0.4894792009605, 0.473926039098903, 0.454310440369375, 
    0.554241316271735, 0.541883168764592, 0.454457861542351, 
    0.604332741439515, 0.540695028873092, 0.39563533951686, 0.434146312070783, 
    0.501923288560107, 0.39355110552466, 0.41809514942744, 0.499504079231113, 
    0.595812336309417, 0.532911771557008, 0.379369437094666, 
    0.438835078694045, 0.410702500498134, 0.588378207771393, 
    0.489114325862011, 0.446131493730883, 0.503898667076488, 
    0.462363603443673, 0.455562831926475, 0.451840476397193, 
    0.47525202625276, 0.515074703781082, 0.386153830850571, 0.572850973653104, 
    0.525453291220881, 0.37847056866325, 0.527645466921247, 0.588866193449821, 
    0.469692893480244, 0.455172799015145, 0.519295268096243, 
    0.558756108861516, 0.52912527775688, 0.522568811406527, 0.428695446541398, 
    0.437082653616202, 0.443655109823767, 0.392882410475111, 
    0.46225928919736, 0.407504439670244, 0.483905898113982, 0.309526310475157, 
    0.417662841463504, 0.48287436056602, 0.499309930766372, 0.429550254831548, 
    0.36793416415954, 0.39998580071139, 0.489491863887712, 0.384234206583464, 
    0.451800600979828, 0.399469376791468, 0.345439425628258, 
    0.382098684856665, 0.381070852162158, 0.363450908531267, 
    0.412241575669031, 0.498413759031919, 0.404876590725242, 
    0.502927104901646, 0.431815142177119, 0.537880538611933, 
    0.377164086746828, 0.426464470279544, 0.580428427280008, 
    0.49633008524872, 0.587946746290481, 0.419375721638227, 0.292019178011938, 
    0.473454278143221, 0.561758855209141, 0.360962944400714, 
    0.334191412966179, 0.362997523931313, 0.505844127410716, 
    0.598551059104936, 0.335017564868834, 0.450331654842663, 
    0.441677826284325, 0.413956893966009, 0.617097238524826, 
    0.370877705363871, 0.366427000427686, 0.508413548955733, 
    0.497483643394845, 0.303704811155292, 0.61289253149548, 0.477659681074506, 
    0.319079946963575, 0.35076704857208, 0.440706084991603, 0.341421895266547, 
    0.40037695274687, 0.497587670061708, 0.412738872911776, 0.374708177867541, 
    0.449833088305997, 0.352182086239319, 0.531305195653187, 
    0.450637187730285, 0.251675344711228, 0.53926035200181, 0.396598603906862, 
    0.393867273091007, 0.344269187770846, 0.389035794070624, 
    0.392967893678239, 0.4040831963319, 0.326185137444012, 0.348240481882434, 
    0.306753937446921, 0.384635559721938, 0.306418711979442, 
    0.367213690921525, 0.360147728637864, 0.275579363958768, 
    0.316547549319518, 0.412280036872796, 0.379139479521832, 
    0.401820628092819, 0.411070472805251, 0.493908530514911, 
    0.396673045535904, 0.482935568850487, 0.433725855789188, 
    0.3777791076663, 0.541493965368537, 0.512575750244049, 0.395226592002154, 
    0.524832124627329, 0.341035248463893, 0.379565422297709, 
    0.427487722500645, 0.341582037229785, 0.394584674492639, 
    0.30552904639435, 0.445105441339645, 0.510203138516952, 0.447017567958637, 
    0.242270227648862, 0.600021785467057, 0.434570525119936, 
    0.279768154145025, 0.31391539920257, 0.355843383772115, 0.302677982654902, 
    0.393505745774557, 0.451555968971692, 0.31995090141484, 0.296303864485411, 
    0.458212002132761, 0.301351184718365, 0.290566461615932, 
    0.36336838764711, 0.544240611623441, 0.564461383341668, 0.430693401207898, 
    0.381448283923021, 0.341425666024221, 0.471886416466978, 
    0.453913392664524, 0.404732207228083, 0.385699993085613, 
    0.302551992526533, 0.488254616012667, 0.520558043911984, 
    0.300866623198717, 0.534865480327612, 0.307955016434397, 
    0.30691094082515, 0.275998025346642, 0.287877846923219, 0.437751595081922, 
    0.508109133965374, 0.319112772418912, 0.390793256989697, 
    0.351090156129, 0.422995014250804, 0.344091011916599, 0.389455832620334, 
    0.344274507359781, 0.326157825030467, 0.347989970149455, 
    0.497853535173946, 0.352311879689945, 0.6086087997098, 0.427365916115931, 
    0.266693111965115, 0.372630868233203, 0.314596044647729, 
    0.300566493472819, 0.37758153078573, 0.426214839897885, 0.346163018115, 
    0.380705742656941, 0.408362042740536, 0.314402169151834, 
    0.392454668609131, 0.610635489855821, 0.436422281027539, 
    0.28430775540064, 0.424723134978422, 0.417881018556868, 0.286684178143725, 
    0.46070137571272, 0.380202894148103, 0.404590270125674, 0.459856431263103, 
    0.334677705568049, 0.357271907186953, 0.362182686106985, 
    0.27796051442461, 0.332146519201433, 0.4964665320617, 0.379567588570002, 
    0.393013449148333, 0.268494181350373, 0.228905786858048, 
    0.351483533335741, 0.513980390666559, 0.231254471608342, 
    0.448885209038097, 0.442825519473332, 0.221654829328706, 
    0.385028267358779, 0.360460832823773, 0.29923573895999, 0.334800262629183, 
    0.420577026302653, 0.410927432261151, 0.426959217810375, 
    0.435672697546432, 0.357997764560066, 0.366681410127908, 
    0.347581461527579, 0.434805261577024, 0.348494226245852, 
    0.504887813329235, 0.407645340701939, 0.494822062242728, 
    0.338384940586105, 0.410325431914444, 0.361539967657604, 
    0.410601410381859, 0.465407725611506, 0.501556815954473, 
    0.478284012006853, 0.310864323170348, 0.436247392917795, 
    0.341584540768694, 0.427959398083796, 0.33689327615974, 0.643926890152215, 
    0.491602391048782, 0.437280337271057, 0.293264583673787, 
    0.386432422987936, 0.484358826190582, 0.462611902580695, 
    0.470509677206882, 0.493119117689827, 0.49052350330483, 0.32836203375077, 
    0.499818678692032, 0.496291186364509, 0.516604157731002, 
    0.37927462523574, 0.411728079776955, 0.321156396702638, 0.417906547623147, 
    0.389825668405321, 0.477672151569978, 0.256395827039857, 
    0.369349337272154, 0.425568347504623, 0.309651240525142, 
    0.401178071476474, 0.305135323499848, 0.373114384684745, 
    0.31491980960156, 0.447310352518228, 0.309955661443655, 0.443133248175444, 
    0.344582247021507, 0.386532094274268, 0.286107712711867, 
    0.450657726028203, 0.273471883683274, 0.297862612358491, 
    0.385818183435417, 0.458758138723549, 0.246426762745747, 
    0.38281940466586, 0.204471096326512, 0.299563590467578, 0.303421976399176, 
    0.243646697868875, 0.239712342239371, 0.25046068218792, 0.287974875393558, 
    0.215133352819049, 0.30778589226626, 0.33220999339814, 0.289774199850394, 
    0.207809483183818, 0.177631030866718, 0.264128710016145, 
    0.277173543352048, 0.27897397607637, 0.189989914532045, 0.360544798185691, 
    0.437696306474472, 0.230591733115137, 0.205338936041758, 
    0.201590081835722, 0.638971821848141, 0.279696454916995, 
    0.358553068478744, 0.199791529419465, 0.228973219328669, 
    0.201495118300592, 0.196566562152201, 0.401012947683939, 
    0.252587822107546, 0.173380945713134, 0.182560667654688, 
    0.246949602428734, 0.445292374595779, 0.187990554999655, 
    0.278379198652008, 0.204132198699358, 0.19016459961075, 0.157407540202989, 
    0.255898215858651, 0.388341749293294, 0.308004577458857, 
    0.183186861356065, 0.169268369604055, 0.342074734742075, 
    0.184373366138077, 0.240832856384351, 0.285422881132346, 
    0.201423388532013, 0.164590282465066, 0.151648828411359, 
    0.252153013660867, 0.158370666344985, 0.202907233141236, 
    0.295775330334727, 0.326762554146448, 0.252980514100564, 
    0.160486020983059, 0.33138610916861, 0.284397735625352, 0.321774108791643, 
    0.22635794899503, 0.252918621245626, 0.248828899836202, 0.16160394302803, 
    0.403572845920479, 0.289449188574506, 0.230999729306942, 
    0.153337926529536, 0.204836889477835, 0.194650281820943, 
    0.355659393019546, 0.286555812503691, 0.163055559376536, 
    0.299992273654938, 0.274188387652168, 0.232107728755177, 
    0.24439364315363, 0.221906542809825, 0.21527191341641, 0.234154997002068, 
    0.190253999827869, 0.184632383044872, 0.197393183993108, 
    0.300483746651963, 0.186026468261356, 0.207740625707798, 
    0.237253933214246, 0.150384846688558, 0.308445574047236, 
    0.238428549748897, 0.251762565709943, 0.156085564350801, 
    0.165715861096662, 0.374465549188542, 0.288026265365618, 
    0.24292260987357, 0.212896948121416, 0.338537234341832, 0.439017961137048, 
    0.270385347577486, 0.350377755163656, 0.248327302086238, 
    0.303781930244524, 0.374206278698761, 0.32960795522594, 0.205047881783545, 
    0.276180886702025, 0.369238081302719, 0.167457623166145, 
    0.23589437525035, 0.231505366112004, 0.223549052289827, 0.382397238586739, 
    0.358944554709578, 0.157804398377026, 0.444540115237408, 
    0.195573052261095, 0.210047073681573, 0.333812102144009, 
    0.521833112123666, 0.253379299597201, 0.172523504987385, 
    0.37740654106418, 0.40995547728894, 0.160825650589967, 0.423339130978785, 
    0.206433697985695, 0.302346873584048, 0.284301206901398, 
    0.220626656667639, 0.197398525759993, 0.225631786856265, 
    0.376645936771519, 0.232306525274379, 0.164026170879389, 
    0.156354628050143, 0.171307687309742, 0.235375305838399, 
    0.277286550798841, 0.160750161218709, 0.190851080675454, 
    0.162514112097119, 0.250084508072779, 0.286410303481615, 
    0.24371189155177, 0.215660511749997, 0.349464797740435, 0.310787417359119, 
    0.195356976907865, 0.195462127724917, 0.184632806556688, 
    0.181723273699587, 0.216155201210979, 0.246657011296115, 
    0.152132510143203, 0.219266397098808, 0.180998669443103, 
    0.295590015151726, 0.335830479020209, 0.212928151230035, 
    0.164798099173247, 0.21121093463675, 0.181690947985679, 0.318931325460731, 
    0.187448600367745, 0.23992128893406, 0.275008546349042, 0.284661719452111, 
    0.171870997860103, 0.224280101920737, 0.334026962855309, 
    0.173492831453961, 0.268108463879988, 0.213648977568728, 
    0.173508712284038, 0.159879793732163, 0.212954582664069, 
    0.167869043428149, 0.421381921440872, 0.206281471494785, 
    0.262277798575539, 0.322726537388717, 0.308874346148399, 
    0.298633988170328, 0.205840019117666, 0.395284826009002, 
    0.262892130977886, 0.18087372685649, 0.279399479094886, 0.216411980395914, 
    0.170572620820647, 0.153865792626467, 0.216276574189114, 
    0.2188859347541, 0.433570505244078, 0.484623077668395, 0.182107343830163, 
    0.161127925618343, 0.378515092092278, 0.312191822398631, 
    0.153209165942297, 0.337411328844175, 0.183558401557491, 
    0.207172313175134, 0.198383501392553, 0.255823083073815, 
    0.169964038097769, 0.20506789081376, 0.222261748529342, 0.166075945551066, 
    0.156052164341577, 0.326879270909704, 0.199953766650971, 
    0.354830919484774, 0.255693703942452, 0.323872348424834, 
    0.18376472919277, 0.222919264218169, 0.461010924707936, 0.358046216634287, 
    0.186597520675411, 0.379849425216928, 0.223577405041575, 
    0.261117696298502, 0.204937999578366, 0.223165897667078, 
    0.203346473478762, 0.188813524117959, 0.267359461319295, 
    0.219506695062399, 0.26180623631519, 0.238683492525455, 0.322674092882975
    ))), <environment>), class = c("tbl_graph", "igraph"), active = "nodes")

Solution

  • Alternatively, if you are looking to use the value in mod as the fill color, you can do so by setting the fill value to the column outside of the aes(). In this case you don't get a legend.

    geneplot <- ggraph(hub_plot1,  layout = 'fr') + 
      geom_edge_link(color="darkgrey", aes(alpha = weight), show.legend = F)  + 
      scale_edge_width(range = c(0.2, 1)) + geom_node_text(aes(label = name, color=color), size=3, repel=T) +
      geom_node_point(aes(size=kme), fill = V(hub_plot1)$mod, shape=21, alpha=0.5) + 
      scale_size(range = c(1,5), name = "kME") +
      theme_graph(base_family="sans",base_size = 40)+ theme(legend.title.align=0.5,
                                                            legend.box = "horizontal", 
                                                            legend.position = c(0.9, 0.9),
                                                            legend.margin = margin(-0.5,0,0,0, unit="cm"),
                                                            legend.title = element_text(size=10),
                                                            legend.text = element_text(size=8)) +
      scale_color_manual(values=c("gray0","red")) + guides(color="none") +
      coord_cartesian(clip="off")
    
    

    enter image description here