stocnet / manynet

Many Ways to Make, Manipulate, and Map Myriad Networks
https://stocnet.github.io/manynet/
Other
12 stars 0 forks source link

node_group not working in autographr() #11

Closed jhollway closed 1 year ago

jhollway commented 2 years ago

Gives an anchors[[1]]: subscript out of bounds error.

jaeltan commented 2 years ago

I'm not getting this error, but the groups weren't plotting correctly so I changed that

jhollway commented 2 years ago

Thanks @jaeltan, it is working better now. Still, the error persists and can be reproduced with:

autographr(ison_marvel_relationships, node_group = "PowerOrigin")
jaeltan commented 2 years ago

I just tried this and got a plot without any error https://app.zenhub.com/files/238751844/3d9f3646-ab07-4ccd-9a4f-cca0c4f7a392/download

jhollway commented 2 years ago

Can you try it @henriquesposito to see whether this is a Mac issue?

henriquesposito commented 2 years ago

I get no errors on my side, I get the same plot as Jael...

henriquesposito commented 1 year ago

I can reproduce the error and I think it might be related to the release version of {ggplot2} and/or {ggforce}; as well as the number of overlaps for groups in the data. I can remove the error using ggforce::geom_mark_hull(), but the "geom" still does not correctly "hull" over the groups. I can, however, make the groups work with ggforce::geom_mark_ellipse(). I have made the respective changes.

Please let me know what you think @jhollway .

Another alternative could be to require certain package versions in the description file. However, I am not sure how this will affect previous changes in argument names, for example, with the new versions of {ggplot2}.

jhollway commented 1 year ago

I'm travelling again, but can you please show here/on Slack what the differences would be visually between hulls and ellipses? What's at stake in the choice?

henriquesposito commented 1 year ago

Running autographr(ison_marvel_relationships, node_group = "PowerOrigin") with a (semi)working (no messages or warnings but missing labels) version of the hull returns:

image.png

I have been able to make the function work better with the ellipses (below).

image.png

@jhollway please let me know what you think.

jhollway commented 1 year ago

Honestly, neither really looks all that helpful. Does the node_group = argument expect a character or numeric vector?

henriquesposito commented 1 year ago

I understand, I will go back to it and try to find a better alternative.

"node_group" expects a variable in the data to be declared, it could be character or numeric, and the argument is treated as a factor.

henriquesposito commented 1 year ago

I have been looking more into this issue and the fix might be more complicated then first taught (see https://github.com/thomasp85/ggforce/issues for this and other related issues).

Some alternatives to move forward (ordered by difficulty):

1- We could use a temporary fix for now (e.g. ellipses/polygons) and wait until the respective functions on {ggforce} are updated.

2- We can alter the layout when the 'node_group' argument is declared to improve community visualisation. For instance, we can use network backbones to better place nodes from the same community near(ish) each other (see http://blog.schochastics.net/post/ggraph-tricks-for-common-problems/ and http://blog.schochastics.net/post/introducing-graphlayouts-with-got/) and improve visuals. Though this way we might still have to handle issues with {ggforce} functions and/or perhaps rely on other packages/functions to visualise groups.

3- We can try and create our own custom "hull" function to visualise communities.

@jhollway please let me know what you think. Thank you.

henriquesposito commented 1 year ago

I will suspend this functionality momentarily and go back to it when the issues in ggforce are solved.

henriquesposito commented 1 year ago

This issue has been fixed by limiting the number of categories group variables can have when plotting with autographr(). This change should avoid that we run into limit issues for ggforce::geom_node_hull().