ComplexHeatmap
ComplexHeatmap copied to clipboard
an error becomes a message when calling hm1 + hm2 from draw
Normally, when adding two heatmaps with different number of rows, an error is generated.
However in this code, a message is outputted instead of an error:
m1 <- matrix(1:9, nrow = 3, ncol = 3, byrow = TRUE)
m2 <- m1[c(1, 3),]
hm1 <- ComplexHeatmap::Heatmap(m1, cluster_rows = F, cluster_columns = F)
hm2 <- ComplexHeatmap::Heatmap(m2, cluster_rows = F, cluster_columns = F)
ComplexHeatmap::draw(
hm1 + hm2
)
#> `nrow` of all heatmaps and `nobs` of all annotations should be the same
#> for horizontal heatmap list.
#> heatmap 'matrix_1': 3
#> heatmap 'matrix_2': 2
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'object' in selecting a method for function 'draw': You have an error when adding heatmaps and annotations.
Created on 2023-03-30 with reprex v2.0.2
In situations when your code is rendered using Rmarkdown, it makes it extremely difficult to debug, since knitting is just aborted and only errors are shown. All messages are lost in this scenario.
I'm not sure what's the reason. But it would be nice if the "inner" error is reported, since the draw()
error is not informative at all in such cases.
Thanks! That is a nice suggestion.
I will wrap all the messages in the stop()
function.