INNER CODE UNIT · JavaScript
sampleDisplayName
oncologylab/fp-tools · src/fp_tools/resources/static_browser/app.js:64
function sampleDisplayName(sample, condition = "") {
if (sample && typeof sample === "object" && sample.display_name)
return String(sample.display_name);
const name = String(sample?.name ?? sample ?? "");
if (name.includes("::")) return name.split("::").slice(1).join("::");
const prefix = condition ? `${condition}_` : "";
return prefix && name.startsWith(prefix) ? name.slice(prefix.length) : name;
}
function logp(value) {
return -Math.log10(Math.max(1e-300, finite(value, 1)));
}
function niceStep(range, count = 5) {
const raw = Math.max(range / count, 1e-12),
power = 10 ** Math.floor(Math.log10(raw)),
scaled = raw / power;
return (scaled <= 1 ? 1 : scaled <= 2 ? 2 : scaled <= 5 ? 5 : 10) * power;
}
function niceLimit(value) {