in correlations.js [130:188]
function sortCorrelationData(correlationData, total_reference, total_group) {
return correlationData.sort((a, b) => {
let rule_a_len = Object.keys(a.item).length;
let rule_b_len = Object.keys(b.item).length;
if (rule_a_len < rule_b_len) {
return -1;
}
if (rule_a_len > rule_b_len) {
return 1;
}
// Then, sort by percentage difference between signature and
// overall (using the lower endpoint of the confidence interval
// of the difference).
let ciA = null;
if (a.prior) {
// If one of the two elements has a prior that alters a rule's
// distribution significantly, sort by the percentage of the rule
// given the prior.
ciA = confidenceInterval(
a.prior.count_group,
a.prior.total_group,
a.prior.count_reference,
a.prior.total_reference
);
} else {
ciA = confidenceInterval(
a.count_group,
total_group,
a.count_reference,
total_reference
);
}
let ciB = null;
if (b.prior) {
ciB = confidenceInterval(
b.prior.count_group,
b.prior.total_group,
b.prior.count_reference,
b.prior.total_reference
);
} else {
ciB = confidenceInterval(
b.count_group,
total_group,
b.count_reference,
total_reference
);
}
return (
Math.min(Math.abs(ciB[0]), Math.abs(ciB[1])) -
Math.min(Math.abs(ciA[0]), Math.abs(ciA[1]))
);
});
}