Skip to content

Commit

Permalink
Merge pull request #44 from cBioPortal/cluster-NA-to-end
Browse files Browse the repository at this point in the history
Put all NaN at end in clustering
  • Loading branch information
adamabeshouse authored and alisman committed Jun 2, 2022
1 parent 9f7a9d7 commit b0ef58e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/oncoprintjs/dist/oncoprint.bundle.js

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion packages/oncoprintjs/src/js/workers/clustering-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,25 @@ var preRankedSpearmanDist = function(item1, item2) {
*/
var _prepareForDistanceFunction = function(inputItems) {
//pre-calculate ranks and configure to use last step of SPEARMAN as distance function:
// and put all NaNs items at the end
var allNaN = [];
var notAllNaN = [];
for (var i = 0; i < inputItems.length; i++) {
var inputItem = inputItems[i];
//check if all NaNs:
inputItem.isAllNaNs = isAllNaNs(inputItem.orderedValueList);
if (inputItem.isAllNaNs) {
allNaN.push(inputItem);
continue;
} else {
notAllNaN.push(inputItem);
}
//rank using fractional ranking:
var ranks = jStat.rank(inputItem.orderedValueList);
//calculate deviation:
inputItem.preProcessedValueList = ranks;
}
return notAllNaN.concat(allNaN);
}

/**
Expand Down Expand Up @@ -169,7 +176,7 @@ var hclusterCases = function(casesAndEntitites) {
return inputItems;
}
//else, normal clustering:
_prepareForDistanceFunction(inputItems);
inputItems = _prepareForDistanceFunction(inputItems);
var clusters = clusterfck.hcluster(inputItems, preRankedSpearmanDist);
return clusters.clusters(1)[0];
}
Expand Down

0 comments on commit b0ef58e

Please sign in to comment.