Open ucabuk opened 10 months ago
Hi @ucabuk,
Thank you for raising this point. This is an important problem. Node highlighting would be easy as we need to simply take all the elements in one pathway and highlight these in the other pathway like below.
g1 <- pathway("ko00620")
g2 <- pathway("ko00640")
candidate <- g1 |>
filter(startsWith(name, "ko:")) |> pull(name) |>
strsplit(" ") |> unlist() |> unique()
g2 <- g2 |> mutate(dup=highlight_set_nodes(candidate))
If we need to preserve the original structure of the pathway within the other pathway like edges, it is relatively difficult. One way would be to join the two pathways, and find the duplicated edges and mark them. The below example is not perfect, and I am sure there is another implementation, but may be useful.
g3 <- graph_join(g1, g2, by="name") |>
activate(nodes) |>
mutate(dup=name %in% candidate) |> # highlight nodes
activate(edges) |>
group_by(from, to) |>
mutate(n=n(),
dup=ifelse(n > 1 & length(unique(pathway_id))>1, TRUE, FALSE))
I will see and try to implement the function (like highlight_pathway()
) to find the structure of the pathway within the other pathway, using methods such as an intersection of the graphs.
Hi,
I want to show metabolic pathway in KEGG and then I want to highlight line of the subpathway rather than the module. Is it possible to do that using ggkegg?
Thank you. Best, Ugur