Skip to content

Commit

Permalink
Update function logScalePossible for generic assay negative data (cBi…
Browse files Browse the repository at this point in the history
…oPortal#5084)

* Update logScalePossible for generic assay negative data

* make sure that return type is always boolean

* Add test for negative and positive data of type number
  • Loading branch information
TJMKuijpers authored and olzhasmukayev committed Jan 16, 2025
1 parent afe709e commit d705fa6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
15 changes: 13 additions & 2 deletions src/shared/components/plots/PlotsTabUtils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -767,17 +767,28 @@ describe('PlotsTabUtils', () => {
});

describe('logScalePossible', () => {
it('should return true when data is type number', () => {
it('should return true when positive data is type number', () => {
const axisData = ({
datatype: 'number',
data: [{ value: 1 }, { value: -2 }],
data: [{ value: 1 }, { value: 2 }],
} as any) as IAxisData;
const axisMenuSelection = ({
dataType: CLIN_ATTR_DATA_TYPE,
genericAssayDataType: DataTypeConstants.LIMITVALUE,
} as any) as AxisMenuSelection;
assert.isTrue(logScalePossible(axisMenuSelection, axisData));
});
it('should return false when negative data is type number', () => {
const axisData = ({
datatype: 'number',
data: [{ value: 1 }, { value: -2 }],
} as any) as IAxisData;
const axisMenuSelection = ({
dataType: CLIN_ATTR_DATA_TYPE,
genericAssayDataType: DataTypeConstants.LIMITVALUE,
} as any) as AxisMenuSelection;
assert.isFalse(logScalePossible(axisMenuSelection, axisData));
});
});

describe('axisHasNegativeNumbers', () => {
Expand Down
5 changes: 3 additions & 2 deletions src/shared/components/plots/PlotsTabUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2583,11 +2583,12 @@ export function logScalePossible(
) {
return true;
} else if (
axisData &&
isGenericAssaySelected(axisSelection) &&
axisSelection.genericAssayDataType === DataTypeConstants.LIMITVALUE
) {
// Generic Assay numeric profile is log scale possible
return true;
// Check negative values in log scale
return axisHasNegativeNumbers(axisData) ? false : true;
} else {
// molecular profile
return !!(
Expand Down

0 comments on commit d705fa6

Please sign in to comment.