ggraph icon indicating copy to clipboard operation
ggraph copied to clipboard

geom_conn_bundle "value" does not work for graphs with high interconnectivity

Open gargiris opened this issue 6 years ago • 7 comments

Hello,

I am trying to create a hierarchical edge bundling circular graph of brain connectivity in which the points in the circle are nodes and the edges connecting them are connections in the brain. I am trying to use scale_edge_color_continuous in order to color code the edges by strength of connection. However, for some reason, when I assign a vector of these strength values, which is from a matrix that contains (my "from" node, my "to" node, and my "value" node) in the code:

mygraph + geom_conn_bundle(data = get_con(from = from2, to = to2, value=adjacencyvec$value), aes(colour=value), width = .5, tension = .9) + scale_edge_color_continuous(low="turquoise1", high="orangered")

The value mappings are incorrect. I suspect that the problem is that the "value" cannot be assigned to the actual edge but rather to the node itself. So in the example case below, where "subgroup#" is the name of my node:

Subgroup 76 to Subgroup 101 Subgroup 76 to Subgroup 118 Subgroup 76 to Subgroup 123 Subgroup 101 to Subgroup 118 Subgroup 101 to Subgroup 123

while the values ascribed to the first four pairings above are plausible (in bold is the node that decides the value), pairing 5 becomes implausible because subgroup 101 and subgroup 123 have already had their values ascribed in other mode combinations. So if either of these nodes "values" are used again, it creates a value mapping error. So it seems that only a limited number of pairings can be made without a conflict occurring in the value ascribed (which is why it seems to work in some cases of limited connections but not in others of higher connections). Have others encountered this problem and is there a workaround? Thank you.

Georgette

gargiris avatar Jun 12 '19 22:06 gargiris

There has been some bugs in adding additional information to the connections, which have been fixed now. Please try again with the development version and see if it has been fixed

thomasp85 avatar Aug 13 '19 10:08 thomasp85

Hi Thomas,

Thank you for your response. I tried to reinstall ggraph and it appears that the issue remains. The mapping is the same as before. Maybe I've missed something? Thank you again.

Georgette

gargiris avatar Aug 28 '19 15:08 gargiris

Hi Thomas, Georgette,

I'm also trying to assign continuous (color/width) aesthetics to my connections (the 'from' and 'to' curves), but as of today the bug seems to persist. Calling (aes(colour=value) in my geom_conn_bundle() seems to reference vertices$value, and not connections$value.

When trying to be explicit: ggraph(mygraph, layout = 'dendrogram', circular = TRUE) + geom_conn_bundle(data = get_con(from = from, to = to), aes(colour = connections$value))

Error: Aesthetics must be either length 1 or the same as the data (383): edge_colour

Thanks for the wonderful package! Eric

e-south avatar May 04 '20 19:05 e-south

Hello,

I have the same issue as described by Eric. I was practicing with the example code from the R graph gallery and figured out that indeed a call to "value" inside geom_conn_bundle refers to vertices$value. I intended to use connections$value to represent correlation strength between nodes in my own dataset, but this is now not possible.

I am using R version 4.0.0 and ggraph version 2.0.3

Best, Saskia

Saskia-vA avatar Jun 04 '20 09:06 Saskia-vA

@Saskia-vA, this issue has not been addressed but have you figure the way around of this issue ?

Thanks.

akhst7 avatar Jan 06 '21 20:01 akhst7

@Saskia-vA, this issue has not been addressed but have you figure the way around of this issue ?

Thanks.

In the end I used a different library (circlize) which gave me more flexibility to visualize my data. So unfortunately I have no pointers on how to work around the issue using ggraph.

Saskia-vA avatar Jan 07 '21 09:01 Saskia-vA

@Saskia-vA yeah, I decided to use circlize as well. Could you kindly enough to share your code by using circlize to draw the plot in question ?

Thanks.

akhst7 avatar Jan 16 '21 14:01 akhst7