-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
possible bug with tbl_graph
#250
Comments
Hi - can you try to condense the issue down to a simpler case that does not require me to understand your scientific question. That would make it much easier to follow and debug |
Hello @thomasp85 and thanks for your reply, I think the problem is more related to a network layout than other things, not sure how to solve it though. It could lead to misleading interpretation anyways.
If you look at the graph (attached) the vertex 1 is a Fungus and should not be connected with 3 an 2 in the Intra panel on the right. I think it is not but graphically it seems so. Do you see a way to fix this? I hope this help to clarify. |
I am not totally sure though that is the only issue, if you look at this graph you can see FOTU_115 is connected to FOTU_201, but that connection does not exist in the data frames I used to generate the network.
Additionally, even if existed, it should be in the panel Fungi_Fungi, since connects to fungal otus. Please have a look at test4.pdf Thanks again, |
The example you show is def a visual artefact of the DH layout - try using a different layout that doesn't have this characteristic... As for the other thing it is har to comment on - my guess is that something has gone wrong in the data-preprocessing but it is hard to tell. I'm pretty sure ggraph would not draw an edge that doesn't exist in the dataset |
Thanks for the prompt reply @thomasp85, I believe you. I am not saying it is wrong, I am just trying to find a solution as I want to really use it in my analyses. This is what I did
These are the two datasets for nodes and edges and this is graph I obtained. Can you please try to reproduce and see if you get the same? Gian |
As I said, your graph is encoded wrong. How and when that happened I don't know but the column that encode inter/intra status is not correct. I'm sorry, but I do not have time to help you with the analysis since this does not appear to be an issue with one of my packages |
Hi, @thomasp85 and @Gian77. I think I have figured out a fix to the problem experienced by @Gian77. I was able to reproduce the issue with the code provided by @Gian77 and the data. The first problem was a visual artifact created by the layout "dh". However, the second problem seems to be related to adding the node_key option not matching the edges correctly. For example, using the data contained in the edges_and_nodes.zip file in the last comment by @Gian77:
clearly has edges connecting fungi to fungi (blue dots to blue dots) and prokaryotes to prokaryotes (red to red) when those edges are not in the original edge table (edges_Pop_inter) However, when I use the function as_tbl_graph to create a graph object with just the edge data, then left_join the associated metadata to the graph's nodes, everything is match up correctly.
So, as @Gian77 has mentioned, not sure if this is a bug with the node_key option in tbl_graph or if we are not using tbl_graph properly. If we are not using tbl_graph properly then an explanation of why would be helpful, and I think this issue can then be closed. |
Veeery belated but this was/is an issue in tidygraph that did not correctly match edge and node id if the edge ids are encoded as factors instead of characters. Will push a fix to tidygraph shortly |
Hello,
I am working with coral microbiome and I have a dataset that includes Fungi, Bacteria, Apicomplexa and Symbiodinium. I am trying to build a network out form nodes and edges data frames and plot with facets in
ggraph
to display connections between different organisms (e.g. Inter-Kingdorm = Fungi-Fungi and Intra-Kingdom = Bacteria-Fungi connections). I have generated the two networks, I want to compare, inSpecEasi
. I pooled out nodes and edges data frames form both. I put them together usingrbind.data.frame
and then put them in the sametbl_graph
. Please see the code below and the attached image and datasets.My problem is that the facet do not really work. When I try to facet my graph by edges Inter-Kingdorm and Intra-Kingdom connections I have all the edges plotted wrongly in the two panels (see figure). In the Intra-Kigdom panel I am supposed to see only connections that connect nodes form the same Kingdom. I have checked in the data frames, before
tbl_graph
and they look fine. I presume there is a bug and whentbl_graph
tries to match edges names to nodes, it messes the order up. I am including the code as wee was the data frames so it can be reproduced (see below).Thank you so much for your help!
Gian
test.pdf
node_edges_data.zip
The text was updated successfully, but these errors were encountered: