Skip to content

Commit

Permalink
Merge pull request #201 from bigomics/fix-1310
Browse files Browse the repository at this point in the history
Fix #1310: Heatmap, filter by one protein/gene breaks it
  • Loading branch information
ivokwee authored Dec 20, 2024
2 parents b312603 + 2bfd48a commit 7fced2e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions R/pgx-plotting.R
Original file line number Diff line number Diff line change
Expand Up @@ -5653,14 +5653,17 @@ pgx.splitHeatmapFromMatrix <- function(X, annot = NULL, idx = NULL, splitx = NUL

## ------ split Y-axis (genes) by factor
hc.order <- function(x) {
if (nrow(x) == 1) {
return(rownames(x))
}
suppressWarnings(dd <- stats::as.dist(1 - stats::cor(t(x), use = "pairwise")))
if (sum(is.na(dd))) dd[is.na(dd) | is.nan(dd)] <- 1
hc <- fastcluster::hclust(dd, method = "ward.D2")
rownames(x)[hc$order]
}
if (!is.null(idx)) {
if (row_clust) {
kk <- tapply(rownames(X), idx, function(k) c(hc.order(X[k, ]), " "))
kk <- tapply(rownames(X), idx, function(k) c(hc.order(X[k, , drop = FALSE]), " "))
} else {
kk <- tapply(rownames(X), idx, function(k) c(k, " "))
}
Expand All @@ -5676,7 +5679,7 @@ pgx.splitHeatmapFromMatrix <- function(X, annot = NULL, idx = NULL, splitx = NUL
idx <- rev(idx)
} else {
if (row_clust) {
kk <- hc.order(X[, ])
kk <- hc.order(X[, , drop = FALSE])
X <- X[kk, ]
}
}
Expand Down

0 comments on commit 7fced2e

Please sign in to comment.