... | ... |
@@ -2,6 +2,8 @@ CHANGES in VERSION 1.99.1 |
2 | 2 |
|
3 | 3 |
* add `cluster_row_slices` and `cluster_column_slices` arguments in `Heatmap()`. |
4 | 4 |
* fixed a bug when annotation_height with only one annotation |
5 |
+* order of k-means slices are reordered by slice mean of `row_reorder`/`column_reorder` |
|
6 |
+ if they are provided as vectors. |
|
5 | 7 |
|
6 | 8 |
======================= |
7 | 9 |
|
... | ... |
@@ -1089,7 +1089,7 @@ make_cluster = function(object, which = c("row", "column")) { |
1089 | 1089 |
} else { |
1090 | 1090 |
if(verbose) qqcat("no clustering is applied/exists on @{which}s\n") |
1091 | 1091 |
} |
1092 |
- |
|
1092 |
+ |
|
1093 | 1093 |
if(verbose) qq("clustering object is not pre-defined, clustering is applied to each @{which} slice\n") |
1094 | 1094 |
# make k-means clustering to add a split column |
1095 | 1095 |
if(km > 1 && is.numeric(mat)) { |
... | ... |
@@ -1109,7 +1109,13 @@ make_cluster = function(object, which = c("row", "column")) { |
1109 | 1109 |
|
1110 | 1110 |
meanmat = do.call("cbind", meanmat) |
1111 | 1111 |
hc = hclust(dist(t(meanmat))) |
1112 |
- weight = colMeans(meanmat) |
|
1112 |
+ # if `reorder` is a vector, the slice dendrogram is reordered by the mean of reorder in each slice |
|
1113 |
+ # or else, weighted by the mean of `meanmat`. |
|
1114 |
+ if(length(reorder) > 1) { |
|
1115 |
+ weight = tapply(reorder, cl, mean) |
|
1116 |
+ } else { |
|
1117 |
+ weight = colMeans(meanmat) |
|
1118 |
+ } |
|
1113 | 1119 |
hc = as.hclust(reorder(as.dendrogram(hc), weight, mean)) |
1114 | 1120 |
|
1115 | 1121 |
cl2 = numeric(length(cl)) |