diff --git a/NEWS.md b/NEWS.md index 89adae4..3088436 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,9 @@ # News +## metacoder 0.3.9.9000 (development version) + +* Fixed `heat_tree()` erroring with `The value is not representable as an integer. Invalid value` when using `layout = "davidson-harel"` on a graph with a connected component larger than 1024 nodes. The `fineiter` argument passed to `igraph::layout_with_dh()` must be an integer, but was computed as `max(10, log2(vcount(graph)))`, which is non-integer once `vcount > 1024`. It is now rounded (issue [#362](https://github.com/grunwaldlab/metacoder/issues/362)). + ## metacoder 0.3.9 * Maintenance release to fix CRAN check issues. diff --git a/R/heat_tree--layouts.R b/R/heat_tree--layouts.R index cbc61e5..f68cc57 100644 --- a/R/heat_tree--layouts.R +++ b/R/heat_tree--layouts.R @@ -46,8 +46,13 @@ layout_functions <- function(name = NULL, graph = NULL, intitial_coords = NULL, "reingold-tilford" = list(circular = TRUE, mode = "out"), "davidson-harel" = list(coords = intitial_coords, - maxiter = 10 * effort, - fineiter = max(10, log2(igraph::vcount(graph))) * effort, + maxiter = round(10 * effort), + # `fineiter` is passed to igraph::layout_with_dh(), which + # requires an integer. `log2(vcount)` is non-integer once a + # (connected component of the) graph exceeds 1024 nodes, so + # round to avoid igraph's "not representable as an integer" + # error (grunwaldlab/metacoder#362). + fineiter = round(max(10, log2(igraph::vcount(graph))) * effort), cool.fact = 0.75 - effort * 0.1, weight.node.dist = 13, #* ifelse(is.null(v_weight), 1, list(rescale(v_weight, c(.1, 10))))[[1]], #higher values spread out nodes weight.border = 0,