igraph упрощает при попытке окрасить края - PullRequest
0 голосов
/ 31 января 2019

У меня есть несколько типов ячеек, и я хочу показать их связи друг с другом.Моя проблема, если я просто использую plot(all.cnx), он показывает все соединения.Однако, если я хочу добавить edge.color и т. Д., То это упрощает график.Например, соединения из «CT # 1_3» с другими типами ячеек.Как я могу предотвратить это упрощение, поскольку я хочу показать все края?

спасибо, ильяс.

library("igraph")
my_cnxs = c("CT#1_0","CT#2_7","CT#1_2","CT#2_7","CT#1_3","CT#2_7","CT#1_5","CT#2_7","CT#1_6","CT#2_7","CT#1_0","CT#2_0","CT#1_0","CT#2_2","CT#1_0","CT#2_8","CT#1_2","CT#2_8","CT#1_3","CT#2_8","CT#1_5","CT#2_8","CT#1_6","CT#2_8","CT#1_2","CT#2_0","CT#1_2","CT#2_2","CT#1_3","CT#2_0","CT#1_3","CT#2_2","CT#1_5","CT#2_0","CT#1_5","CT#2_2","CT#1_6","CT#2_0","CT#1_6","CT#2_2","CT#1_1","CT#3_2","CT#1_1","CT#2_0","CT#1_1","CT#2_2","CT#1_2","CT#3_2","CT#1_3","CT#3_2","CT#1_5","CT#3_2","CT#1_6","CT#3_2","CT#3_2","CT#3_2","CT#3_2","CT#2_0","CT#3_2","CT#2_2","CT#2_8","CT#3_2","CT#2_8","CT#2_0","CT#2_8","CT#2_2","CT#1_1","CT#2_7","CT#1_2","CT#2_7","CT#1_3","CT#2_7","CT#1_5","CT#2_7","CT#1_6","CT#2_7","CT#3_2","CT#2_7","CT#2_8","CT#2_7")

my_edge_colors = c("green","green","green","green","green","green","green","green","green","green","green","green","black","black","black","black","black","black","black","black","red","red","red","red","red","red","red","red","red","red","red","red","red","red","red","red","red","red","red","red")

all_cell_colors = c("yellow3","red","skyblue","orange","violet","cyan3","gray80","green","darkgreen","pink","gold","cadetblue1","purple","darkkhaki","chocolate","darkred","aquamarine","darkslategray4","blue","cyan1")

names(all_cell_colors) = c("CT#4_0","CT#1_0","CT#1_1","CT#1_2","CT#1_3","CT#1_4","CT#1_5","CT#1_6","CT#1_7","CT#3_1","CT#3_2","CT#2_0","CT#2_1","CT#2_2","CT#2_3","CT#2_4","CT#2_5","CT#2_6","CT#2_7","CT#2_8")

all.cnx = graph(my_cnxs)
my_layout = layout_(all.cnx, nicely())
my.cx.names = names(edges(all.cnx)[[1]][1]) 
my_vertex_colors = all_cell_colors[match(my.cx.names, names(all_cell_colors))]
plot(all.cnx, layout = my_layout, edge.color = my_edge_colors, edge.arrow.size=0.4, vertex.color = my_vertex_colors, vertex.size=30,vertex.frame.color="black", vertex.label.color="black",vertex.label.cex=0.5, vertex.label.dist=0, edge.curved=0.2)
plot(all.cnx ,layout = my_layout)

1 Ответ

0 голосов
/ 31 января 2019

Края перекрываются из-за edge.curved = 0.5.При этом все ребра имеют одинаковую кривизну, поэтому появляется, если график упрощается, но на самом деле это ребро, просто идеально перекрывающееся.

Чтобы вернуться к тому, что вы хотели, меньше кривой вребра, вы можете использовать функцию curve_multiple() непосредственно на объекте igraph и передать полученный вектор в edge.curve.

plot(all.cnx, layout = my_layout,
     edge.color = my_edge_colors, edge.arrow.size=0.4,
     vertex.color = my_vertex_colors, vertex.size=30,vertex.frame.color="black",
     vertex.label.color="black",vertex.label.cex=0.5, vertex.label.dist=0,
     edge.curved = curve_multiple(all.cnx, .2)) # the default is 0.5

enter image description here

Это будет только кривые края, где кривая необходима, т.е. будет перекрытие.Если вы просто удалите аргумент edge.curved, он сбрасывается к значению по умолчанию, в результате чего края имеют большую кривизну, но без перекрытия.

...