Skip to content

Commit 8383113

Browse files
committed
Remove logFC-checker - always expect log FC from now on
1 parent f90da01 commit 8383113

File tree

2 files changed

+25
-60
lines changed

2 files changed

+25
-60
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "Webcomponent biowc-pathwaygraph following open-wc recommendations",
44
"license": "Apache-2.0",
55
"author": "biowc-pathwaygraph",
6-
"version": "0.1.8",
6+
"version": "0.1.9",
77
"main": "dist/src/index.js",
88
"module": "dist/src/index.js",
99
"exports": {

src/BiowcPathwaygraph.ts

Lines changed: 24 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,6 @@ export class BiowcPathwaygraph extends LitElement {
270270

271271
anyUpgoingPTMs?: boolean;
272272

273-
isLogFoldChange?: boolean;
274-
275273
isNodeExpandAndCollapseAllowed: boolean = false;
276274

277275
currentTimeoutId?: NodeJS.Timeout;
@@ -2383,8 +2381,8 @@ export class BiowcPathwaygraph extends LitElement {
23832381
'--unregulated-color-light'
23842382
);
23852383
// Interpolate between up and not or down and not, depending on direction
2386-
// The center of interpolation is 0 for log fold change and 1 for fold change
2387-
const interpolationCenter = this.isLogFoldChange ? 0 : 1;
2384+
// BiowcPathwayGraph expects log Fold Changes, therefore the interpolation center is always 0
2385+
const interpolationCenter = 0;
23882386
const nodeFoldChange = BiowcPathwaygraph._getNodeFoldChange(node);
23892387
if (nodeFoldChange > interpolationCenter) {
23902388
return d3v6.interpolate(
@@ -2422,37 +2420,21 @@ export class BiowcPathwaygraph extends LitElement {
24222420
case 'foldchange':
24232421
/* eslint-disable no-case-declarations */
24242422

2425-
// Determine if fold change is log or not
2426-
// For this, check if PTMs have "Log Fold Change" or "Fold Change" property.
2427-
// If "Fold Change", check if there are any negative values - then it's actually log fold change
2428-
this.isLogFoldChange = this.d3Nodes?.some(
2429-
node =>
2430-
node.type === 'ptm' &&
2431-
Object.hasOwn((<PTMNodeD3>node).details!, 'Log Fold Change')
2432-
);
2433-
if (!this.isLogFoldChange) {
2434-
this.isLogFoldChange = this.d3Nodes
2435-
?.filter(
2436-
node =>
2437-
node.type === 'ptm' &&
2438-
Object.hasOwn((<PTMNodeD3>node).details!, 'Fold Change')
2439-
)
2440-
.some(node => (<PTMNodeD3>node).details!['Fold Change'] < 0);
2441-
}
2442-
2443-
const foldChangeCenter = this.isLogFoldChange ? 0 : 1;
2423+
// Interpolate between up and not or down and not, depending on direction
2424+
// BiowcPathwayGraph expects log Fold Changes, therefore the interpolation center is always 0
2425+
const interpolationCenter = 0;
24442426
this.anyDowngoingPTMs = this.d3Nodes
24452427
?.filter(node => node.type === 'ptm')
24462428
.some(
24472429
node =>
2448-
BiowcPathwaygraph._getNodeFoldChange(node) < foldChangeCenter
2430+
BiowcPathwaygraph._getNodeFoldChange(node) < interpolationCenter
24492431
);
24502432

24512433
this.anyUpgoingPTMs = this.d3Nodes
24522434
?.filter(node => node.type === 'ptm')
24532435
.some(
24542436
node =>
2455-
BiowcPathwaygraph._getNodeFoldChange(node) > foldChangeCenter
2437+
BiowcPathwaygraph._getNodeFoldChange(node) > interpolationCenter
24562438
);
24572439

24582440
this.maxPosFoldChange = this.d3Nodes
@@ -3239,41 +3221,24 @@ export class BiowcPathwaygraph extends LitElement {
32393221
)((d - 0.5) / 0.5);
32403222
});
32413223

3242-
// The domain of the x axis depends on whether the fold change is log transformed
3243-
// Log FC goes from -inf to +inf, with 0 in the center
3244-
// Non-log FC goes from 0 to +inf, with 1 in the center
3224+
// The domain of the x axis goes from -inf to +inf, with 0 in the center
32453225
const domain: string[] = [];
3246-
if (this.isLogFoldChange) {
3247-
if (this.anyDowngoingPTMs) {
3248-
domain.push(
3249-
...[
3250-
`${this.maxNegFoldChange!.toPrecision(2)}`,
3251-
`${(this.maxNegFoldChange! / 2).toPrecision(2)}`,
3252-
]
3253-
);
3254-
}
3255-
domain.push('0');
3256-
if (this.anyUpgoingPTMs) {
3257-
domain.push(
3258-
...[
3259-
`${(this.maxPosFoldChange! / 2).toPrecision(2)}`,
3260-
`${this.maxPosFoldChange!.toPrecision(2)}`,
3261-
]
3262-
);
3263-
}
3264-
} else {
3265-
if (this.anyDowngoingPTMs) {
3266-
domain.push(...['0', '0.5']);
3267-
}
3268-
domain.push('1');
3269-
if (this.anyUpgoingPTMs) {
3270-
domain.push(
3271-
...[
3272-
`${(this.maxPosFoldChange! / 2).toPrecision(2)}`,
3273-
`${this.maxPosFoldChange!.toPrecision(2)}`,
3274-
]
3275-
);
3276-
}
3226+
if (this.anyDowngoingPTMs) {
3227+
domain.push(
3228+
...[
3229+
`${this.maxNegFoldChange!.toPrecision(2)}`,
3230+
`${(this.maxNegFoldChange! / 2).toPrecision(2)}`,
3231+
]
3232+
);
3233+
}
3234+
domain.push('0');
3235+
if (this.anyUpgoingPTMs) {
3236+
domain.push(
3237+
...[
3238+
`${(this.maxPosFoldChange! / 2).toPrecision(2)}`,
3239+
`${this.maxPosFoldChange!.toPrecision(2)}`,
3240+
]
3241+
);
32773242
}
32783243

32793244
colorLegendXAxisScale

0 commit comments

Comments
 (0)