Skip to content

Commit 2531f3c

Browse files
authored
Merge pull request #1154 from skelly001/develop
Fix slow distance matrix calculation
2 parents db56271 + 3f3bbc6 commit 2531f3c

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

ComplexHeatmap.Rproj

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Version: 1.0
2+
3+
RestoreWorkspace: Default
4+
SaveWorkspace: Default
5+
AlwaysSaveHistory: Default
6+
7+
EnableCodeIndexing: Yes
8+
UseSpacesForTab: Yes
9+
NumSpacesForTab: 3
10+
Encoding: UTF-8
11+
12+
RnwWeave: Sweave
13+
LaTeX: pdfLaTeX
14+
15+
BuildType: Package
16+
PackageUseDevtools: Yes
17+
PackageInstallArgs: --no-multiarch --with-keep.source

DESCRIPTION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ Description: Complex heatmaps are efficient to visualize associations
2222
biocViews: Software, Visualization, Sequencing
2323
URL: https://github.com/jokergoo/ComplexHeatmap, https://jokergoo.github.io/ComplexHeatmap-reference/book/
2424
License: MIT + file LICENSE
25+
RoxygenNote: 7.2.3

R/utils.R

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -214,19 +214,12 @@ get_dist = function(matrix, method) {
214214
# }
215215
} else if(method %in% c("pearson", "spearman", "kendall")) {
216216
if(any(is.na(matrix))) {
217-
dst = get_dist(matrix, function(x, y) {
218-
l = is.na(x) | is.na(y)
219-
x = x[!l]
220-
y = y[!l]
221-
1 - cor(x, y, method = method)
222-
})
223217
warning_wrap("NA exists in the matrix, calculating distance by removing NA values.")
224-
} else {
225-
dst = switch(method,
226-
pearson = as.dist(1 - cor(t(matrix), method = "pearson")),
227-
spearman = as.dist(1 - cor(t(matrix), method = "spearman")),
228-
kendall = as.dist(1 - cor(t(matrix), method = "kendall")))
229218
}
219+
dst = (1-cor(t(matrix),
220+
method = method,
221+
use = "pairwise.complete.obs"))/2
222+
dst = as.dist(dst)
230223
} else {
231224
stop_wrap(qq("method @{method} not supported"))
232225
}

0 commit comments

Comments
 (0)