Set up

library(igraph)
library(ggraph)
library(magrittr)
library(ptrapr)
library(tidygraph)

Issue - direction of the edges in ptrapr output

Sometimes, the direction of the edges in the graphs produced with ptrap is inverted.

Every edge correspond to the part of a branch that connect one node to another. By convention each edge should be directed outward: pointing from the node closer to the base of the panicle to the one further away.

You can understand this better by looking at the panicle graphs: we provide two panicle graph objects:

We can see this comparing the graphs.

The good_panicle graph has no inverted edges:

good_panicle %>% plot_panicle()

Compare the previous graph with the one below, representing the inverted_panicle object. In the graph below, the edges on the main axis are inverted.

inverted_panicle %>% plot_panicle()

Invert edges with invert_edges()

If you find a panicle with inverted edges on the main axis, you can use the function invert_edges() to revert them.

tst <- inverted_panicle %>% invert_edges()
tst %>% plot_panicle()


inverted_panicle %>%
  invert_edges(check_before = TRUE) %>%
  plot_panicle()

good_panicle %>%
  invert_edges(check_before = TRUE) %>%
  plot_panicle()

Details



othomantegazza/ptrapr documentation built on May 4, 2019, 4:16 a.m.