jokergoo / ComplexHeatmap

Make Complex Heatmaps
https://jokergoo.github.io/ComplexHeatmap-reference/book/
Other
1.25k stars 220 forks source link

Fix slow distance matrix calculation #1154

Open skelly001 opened 5 months ago

skelly001 commented 5 months ago

Distance matrix calculation is extremely slow when using correlation-based distance and NAs are present. The existing strategy utilizes nested for loops via the ComplexHeatmap:::dist2 function when NAs are present in the matrix. This solution is too slow for large matrices (e.g., 10000 x 100). These nested for loops can be avoided by using the use = "pairwise.complete.obs" argument of the stats::cor function yielding quick distance matrix calculation in the presence of NAs.