GG Sankey plot - plot that does not show any flow between columns
1
1
Entering edit mode
6 months ago
ijarne ▴ 10

Hi,

I am trying to create a Sankey plot that illustrates the relationship of some GO terms, and I have a dataset that looks like this:

structure(list(parent_id = c("GO:0015727", "GO:0035873", "GO:0035873", 
"GO:0015129", "GO:0035879"), parent_name = c("lactate transport", 
"lactate transmembrane transport", "lactate transmembrane transport", 
"lactate transmembrane transporter activity", "plasma membrane lactate transport"
), aspect_parent = c("biological_process", "biological_process", 
"biological_process", "molecular_function", "biological_process"
), id = c("GO:0035873", "GO:0015129", "GO:0035879", "GO:0015650", 
"GO:0046722"), name = c("lactate transmembrane transport", "lactate transmembrane transporter activity", 
"plasma membrane lactate transport", "lactate:proton symporter activity", 
"lactic acid secretion"), relation = c("is_a", "part_of", "is_a", 
"is_a", "is_a"), hasChildren = c("TRUE", "TRUE", "TRUE", "FALSE", 
"FALSE"), aspect = c("biological_process", "molecular_function", 
"biological_process", "molecular_function", "biological_process"
), recursive_pass = structure(c(1L, 2L, 2L, 3L, 3L), levels = c("first", 
"second", "third"), class = "factor"), next_pass = structure(c(1L, 
2L, 2L, NA, NA), levels = c("first", "second", "third"), class = "factor")), row.names = c(NA, 
-5L), class = "data.frame")

Now i have used the ggsankey R package to make a Sankey plot and the ordering of the data, everything looks fine to me but I get a plot that does not show any flow between columns, and I do not understand where my code or my data structure is falling.

Thank you !

The ggplot code:

pathways_connections <- ggplot(data = GOs_childs_recursive,
                               aes(x = recursive_pass, 
                                   next_x = next_pass, 
                                   node = parent_id, 
                                   next_node = parent_id,
                                   fill = factor(parent_id))) + 
  geom_sankey(flow_alpha = 1,
              node.color = "black",           
              show.legend = TRUE)
pathways_connections

The graph I get:

enter image description here

ggplot2 sankey-plot r GO • 992 views
ADD COMMENT
0
Entering edit mode

Use dput to share the dataset, not to show what it looks like - use a simple print() to do that, like so:

   parent_id                                parent_name      aspect_parent         id                                       name relation hasChildren             aspect recursive_pass next_pass
1 GO:0015727                          lactate transport biological_process GO:0035873            lactate transmembrane transport     is_a        TRUE biological_process          first     first
2 GO:0035873            lactate transmembrane transport biological_process GO:0015129 lactate transmembrane transporter activity  part_of        TRUE molecular_function         second    second
3 GO:0035873            lactate transmembrane transport biological_process GO:0035879          plasma membrane lactate transport     is_a        TRUE biological_process         second    second
4 GO:0015129 lactate transmembrane transporter activity molecular_function GO:0015650          lactate:proton symporter activity     is_a       FALSE molecular_function          third      <NA>
5 GO:0035879          plasma membrane lactate transport biological_process GO:0046722                      lactic acid secretion     is_a       FALSE biological_process          third      <NA>
ADD REPLY
2
Entering edit mode
6 months ago
bk11 ★ 3.0k

You need to change your data table into a 'long' format. You can do something like this-

GOs_childs_recursive <- GOs_childs_recursive %>% make_long(parent_id, id)

ggplot(data=GOs_childs_recursive, 
       aes(x=x, next_x=next_x, 
           node=node, 
           next_node=next_node, 
           fill=factor(node), 
           label=node, 
           color=factor(node)))+
  geom_sankey()

You will get something like below:

enter image description here

ADD COMMENT
0
Entering edit mode

bk11 i changed this comment to an answer. if you disagree please let me know. thanks for sharing your knowledge. VAL

ADD REPLY
0
Entering edit mode

Hey I am sorry for the late response, thank you for the help ! I will post the latest version of the plots when finished as it is something I am not working on now ! But thanks !

ADD REPLY
0
Entering edit mode

We don't need your latest version, just whether or not bk11's post helped you. Also, use Comments, not Answers to reply to people.

ADD REPLY
0
Entering edit mode

OK. Yes it helped.

ADD REPLY
0
Entering edit mode

upvote_bookmark_accept

ADD REPLY

Login before adding your answer.

Traffic: 1405 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6