ropensci / iheatmapr

Complex, interactive heatmaps in R
https://docs.ropensci.org/iheatmapr
Other
267 stars 36 forks source link

Error messages when number of rows differ. #29

Open IgnatiusPang opened 6 years ago

IgnatiusPang commented 6 years ago

Dear Alicia,

I have spotted this possible area where the code could be improved. I have tried placing heat maps side by side using the 'add_main_heatmap' function. The error messages could possibly be improved if the number of rows for the two input matrices are not the same. For example:

library(iheatmapr)

set.seed(12345)

table_1 <- matrix( runif(100 ), nrow=10, ncol=10)

table_2 <- matrix( runif(110 ), nrow=11, ncol=10)

This one works, table 2 trimmed. Perhaps it could be better to warn the users the number of rows differ, but still print the plot.

main_heatmap(table_1) %>% add_row_clustering( ) %>% add_col_clustering() %>% add_main_heatmap( table_2) %>% add_col_clustering()

This one gave a subscript out of bound error. I guess it could be better to print some warnings or errors?

main_heatmap(table_2) %>% add_row_clustering( ) %>% add_col_clustering() %>% add_main_heatmap( table_1) %>% add_col_clustering()

This is just a suggestion, not urgent, but I guess it could help other people debug their code a bit quicker. Thank you, iheatmapr is a really useful tool and I use it whenever I can now.

Kind Regards,

Igy

AliciaSchep commented 6 years ago

Thanks for the suggestion! Checks for compatible dimensions (with informative error messages) seems like a great idea.