renozao / NMF

NMF: A Flexible R package for Nonnegative Matrix Factorization
137 stars 40 forks source link

aheatmap: Line width of the tree #47

Open sjackman opened 9 years ago

sjackman commented 9 years ago

Is it possible to set the line width of the tree of aheatmap? Any other tips for producing figures for publication?

renozao commented 9 years ago

Which version are you using. Try the one on the devel branch on Github. You will need to install the develop version of pkgmaker as well. Have a look at the aheatmap vignette.

sjackman commented 9 years ago

I've read the vignette, but I didn't see an option to change the line width of the tree. Does it require passing an option to the dendextend package?

renozao commented 9 years ago

You can pass a pre-formated dendrogram to Rowv or Colv (top of page 5 in the vignettes, which I agree does not show the right plot. Will fix this). Some formatting options are built-in aheatmap, but there is a lot of other neat things you can do with dendextend from @talgalili.

# data
x <- rmatrix(20, 10)
# extract clustering or create it externally
a <- aheatmap(x)
hc <- a$Colv
# hc <- as.dendrogram(hclust(dist(t(x))))

# pre-format
library(dendextend)
hc <- set("nodes_pch", c(19,1,4)) %>%
set("nodes_cex", c(2,1,2)) %>%
set("nodes_col", c(3,4))
hc <- hc %>% set("branches_lwd", c(4,1)) %>%
set("branches_lty", c(1,1,3)) %>%
set("branches_col", c(1,2,3))

# plot
aheatmap(x, Colv = hc, Rowv = FALSE, main = "Custom dendrogram")
talgalili commented 9 years ago

Dear @renozao , Thank you for letting me know. I now added a mention of using aheatmap with dendextend in its vignette: https://github.com/talgalili/dendextend/commit/9d75974f58a83e30ee0ee7cf2a6e705bf7fbbb93

With regards, Tal