Skip to content
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

Is it possible to "mirror" a dendrogram? #29

Closed
EOneita opened this issue Oct 12, 2016 · 2 comments
Closed

Is it possible to "mirror" a dendrogram? #29

EOneita opened this issue Oct 12, 2016 · 2 comments

Comments

@EOneita
Copy link

EOneita commented Oct 12, 2016

I have attached the image of the dendrogram I have created. Is there a code in ddextend that can be used to mirror this image? So, I would have the questions on the left, and the tree extending to the left, as an inverse of what is seen here.

I've been looking through the ddextend manual for code to this effect, but have struggled to find any.

Thank you in advance for your help,
Elizabeth
screen shot 2016-10-12 at 10 56 27

@talgalili
Copy link
Owner

talgalili commented Oct 12, 2016

Good question. The function you are looking for is dendextend::plot_horiz.dendrogram. This function is indeed not documented in the vignettes, although it is used by tanglegram. Here is an example for how to use it, I hope this helps:

hc <- hclust(dist(USArrests), "ave")
d <- as.dendrogram(hc)
plot(d, horiz  = TRUE)

library(dendextend)
d <- d %>% color_branches(k=3) %>% color_labels

par(mar = c(3,7,1,1))
plot_horiz.dendrogram(d, side = TRUE)

Output

image

With regards,
Tal

@EOneita
Copy link
Author

EOneita commented Oct 12, 2016

Great, thank you so much! Worked like a charm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants