talgalili / dendextend

Extending R's Dendrogram Functionality

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

dend_diff() plots the first dendrogram twice

RaSieb opened this issue · comments

Hi
The dend_diff() function plots the first dendrogram twice, and manually adjusting with which= produces an error. Here's an example with the dendrograms from the introduction:

dend13 <- c(1:3) %>%
  dist %>%
  hclust(method = "average") %>%
  as.dendrogram
dend15 <- c(1:5) %>% dist %>% hclust(method = "average") %>% as.dendrogram
l <- dendlist(dend13, dend15)
dend_diff(l)
dend_diff(l,which = 2)

 Error in partition_leaves(dend2) : 'dend' is not a dendrogram

Produced using dendextend_1.6.0 and R version 3.4.3 on MacOS.

Thanks Rasi, I won't get to look at it in the next few weeks, but will keep this issue open for later on when I'll get the time to solve it. If you will get to it before me, feel free to send a pull request.
The code for the function is here:
https://github.com/talgalili/dendextend/blob/master/R/distinct_edges.R

Hi I found the problem but I'm completely new to GitHub so I don't know how to change it myself.

The issue is that in dend_diff.dendrogram you overwrite the variable dend2 given to the function. Line 274: "dend2 <- highlight_distinct_edges(dend, dend2)" should be for example "dend21 <- highlight_distinct_edges(dend, dend2)" and then line 281 would be "plot(dend21 etc. etc.".

Sorry for not being able to change it myself. Thanks for writing the package!

Ok I'll give it a go! Thanks for the instructions!