talgalili / dendextend

Extending R's Dendrogram Functionality
153 stars 29 forks source link

dend_diff() plots the first dendrogram twice #59

Open RaSieb opened 6 years ago

RaSieb commented 6 years ago

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.

talgalili commented 6 years ago

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

jdetribol commented 6 years ago

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!

talgalili commented 6 years ago

Good catch. To help you practice github, Please change the code in line: https://github.com/talgalili/dendextend/blob/71c8a0dc0d53fb44f92a61ff68a326b73d1dc447/R/distinct_edges.R#L274 to be dend11 instead of dend2 <- And then also fix it in: https://github.com/talgalili/dendextend/blob/71c8a0dc0d53fb44f92a61ff68a326b73d1dc447/R/distinct_edges.R#L281

All you need to do is press the edit button (a small pencil) at the top right of when the code starts:

Could you do it?

----------------Contact Details:------------------------------------------------------- Tal Galili, Ph.D. in Statistics

Tal.Galili@gmail.com

www.r-statistics.com (English) www.biostatistics.co.il (Hebrew) | www.talgalili.com (Hebrew)

On Wed, Aug 8, 2018 at 4:49 PM, jdetribol notifications@github.com wrote:

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!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/talgalili/dendextend/issues/59#issuecomment-411411957, or mute the thread https://github.com/notifications/unsubscribe-auth/AA7khhLuYoacN9mHAfqUPMOGEb-600Q3ks5uOuxggaJpZM4RJH8I .

jdetribol commented 6 years ago

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