2

I try to plot a dendrogram with the ggraph package but, it's ok with geom_edge_diagonal() but not with geom_edge_elbow()

Packages

library(phyloseq)
library(igraph)
library(ggraph)

Getting data

The file ps.rds is available here

https://github.com/spholmes/F1000_workflow/tree/master/data

ps <- readRDS("ps.rds")

EdgeList <- phy_tree(ps)$edge
Tree <- graph_from_edgelist(EdgeList, directed = TRUE)

Plotting

ggraph(Tree, 'dendrogram') +
  geom_edge_diagonal()

enter image description here

This code works but the plot is not very beautiful.

And now :

ggraph(Tree, 'dendrogram', circular = TRUE) +
  geom_edge_elbow()

Error in FUN(X[[i]], ...) : object 'direction' not found

So I have some questions :

  1. Why it doesn't work yhereas it works for the other dendrogram ?
  2. What is direction ? In the package documentation, it is said that direction is "automatically set" https://www.rdocumentation.org/packages/ggraph/versions/0.1.1/topics/geom_edge_elbow
  3. Can I found something useful for plotting in the ps object ?

EDIT after F. Privé comment

Yes, it's possible to mix dendrogram and circular.

ggraph(Tree, 'dendrogram', circular = TRUE) +
  geom_edge_diagonal()

enter image description here

abichat
  • 2,317
  • 2
  • 21
  • 39
  • When I play around your example, I get the error "Circular layout only applicable to tree and DAG layout". Are you sure you can use `layout = 'dendrogram'` with `circular = TRUE`? – F. Privé Jul 25 '17 at 08:05

1 Answers1

2

For some reasons that are too involved to discuss here, geom_edge_elbow currently only supports dedrogram/hclust objects and not igraph objects.

I'll probably have figured a way around that for the next release

ThomasP85
  • 1,624
  • 2
  • 15
  • 26