-
Notifications
You must be signed in to change notification settings - Fork 318
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add column formatter and fisher two sided unit tests
- Loading branch information
Bryan Lai
committed
Jul 7, 2023
1 parent
de2bf9c
commit 73cd7bc
Showing
12 changed files
with
840 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/pages/resultsView/mutualExclusivity/MutualExclusivityUtil.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
140 changes: 140 additions & 0 deletions
140
src/shared/components/mutationTable/column/EnrichedInColumnFormatter.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
import { assert } from 'chai'; | ||
import { initMutation } from 'test/MutationMockUtils'; | ||
import { Mutation } from 'cbioportal-ts-api-client'; | ||
import { GroupComparisonMutation } from 'shared/model/GroupComparisonMutation'; | ||
import { enrichedInRenderFunction } from './EnrichedInColumnFormatter'; | ||
import { mount, ReactWrapper } from 'enzyme'; | ||
import { ComparisonGroup } from 'pages/groupComparison/GroupComparisonUtils'; | ||
import styles from 'pages/resultsView/enrichments/styles.module.scss'; | ||
|
||
describe('EnrichedInColumnFormatter', () => { | ||
const mutation1: Mutation = initMutation({ | ||
proteinChange: 'L702H', | ||
}); | ||
|
||
const mutation2: Mutation = initMutation({ | ||
proteinChange: 'H875Y', | ||
}); | ||
|
||
const mutation3: Mutation = initMutation({ | ||
proteinChange: 'A646D', | ||
}); | ||
|
||
const rowDataByProteinChange: { | ||
[proteinChange: string]: GroupComparisonMutation; | ||
} = { | ||
L702H: { | ||
proteinChange: 'L702H', | ||
enrichedGroup: '(A) Metastasis', | ||
groupAMutatedCount: 9, | ||
groupAMutatedPercentage: 3.2490974729241873, | ||
groupBMutatedCount: 0, | ||
groupBMutatedPercentage: 0, | ||
logRatio: Infinity, | ||
pValue: 0.00036917378321091467, | ||
qValue: 0.005906780531374635, | ||
}, | ||
H875Y: { | ||
proteinChange: 'H875Y', | ||
enrichedGroup: '(A) Metastasis', | ||
groupAMutatedCount: 9, | ||
groupBMutatedCount: 1, | ||
groupAMutatedPercentage: 3.2490974729241873, | ||
groupBMutatedPercentage: 0.26041666666666663, | ||
logRatio: 3.6411453361142803, | ||
pValue: 0.0023260213212133113, | ||
qValue: 0.01860817056970649, | ||
}, | ||
A646D: { | ||
proteinChange: 'A646D', | ||
enrichedGroup: '(B) Primary', | ||
groupAMutatedCount: 0, | ||
groupBMutatedCount: 1, | ||
groupAMutatedPercentage: 0, | ||
groupBMutatedPercentage: 0.26041666666666663, | ||
logRatio: -Infinity, | ||
pValue: 0.999999999999234, | ||
qValue: 0.999999999999234, | ||
}, | ||
}; | ||
|
||
const groups: ComparisonGroup[] = [ | ||
{ | ||
color: '#DC3912', | ||
uid: 'Metastasis', | ||
name: 'Metastasis', | ||
nameWithOrdinal: '(A) Metastasis', | ||
ordinal: 'A', | ||
studies: [], | ||
nonExistentSamples: [], | ||
origin: ['msk_impact_2017'], | ||
description: '', | ||
}, | ||
{ | ||
color: '#2986E2', | ||
uid: 'Primary', | ||
name: 'Primary', | ||
nameWithOrdinal: '(B) Primary', | ||
ordinal: 'B', | ||
studies: [], | ||
nonExistentSamples: [], | ||
origin: ['msk_impact_2017'], | ||
description: '', | ||
}, | ||
]; | ||
|
||
let component1: ReactWrapper<any, any>; | ||
let component2: ReactWrapper<any, any>; | ||
let component3: ReactWrapper<any, any>; | ||
|
||
beforeAll(() => { | ||
component1 = mount( | ||
enrichedInRenderFunction( | ||
rowDataByProteinChange, | ||
[mutation1], | ||
groups | ||
) | ||
); | ||
component2 = mount( | ||
enrichedInRenderFunction( | ||
rowDataByProteinChange, | ||
[mutation2], | ||
groups | ||
) | ||
); | ||
component3 = mount( | ||
enrichedInRenderFunction( | ||
rowDataByProteinChange, | ||
[mutation3], | ||
groups | ||
) | ||
); | ||
}); | ||
|
||
function testRenderedValues( | ||
component: ReactWrapper<any, any>, | ||
classNames: string[], | ||
value: string | ||
) { | ||
assert.isTrue( | ||
classNames.every(c => | ||
component.find(`div.${(styles as any)[c]}`).exists() | ||
) | ||
); | ||
assert.equal(component.find(`div`).text(), value); | ||
} | ||
|
||
it('renders enriched in column correctly', () => { | ||
testRenderedValues( | ||
component1, | ||
['Tendency', 'Significant', 'ColoredBackground'], | ||
'(A) Metastasis' | ||
); | ||
testRenderedValues( | ||
component2, | ||
['Tendency', 'Significant', 'ColoredBackground'], | ||
'(A) Metastasis' | ||
); | ||
testRenderedValues(component3, ['Tendency'], '(B) Primary'); | ||
}); | ||
}); |
98 changes: 98 additions & 0 deletions
98
...hared/components/mutationTable/column/GroupMutatedCountPercentageColumnFormatter.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import { assert } from 'chai'; | ||
import { initMutation } from 'test/MutationMockUtils'; | ||
import { Mutation } from 'cbioportal-ts-api-client'; | ||
import { getGroupMutatedCountPercentageTextValue } from './GroupMutatedCountPercentageColumnFormatter'; | ||
import { GroupComparisonMutation } from 'shared/model/GroupComparisonMutation'; | ||
|
||
describe('GroupMutatedCountPercentageColumnFormatter', () => { | ||
const mutation1: Mutation = initMutation({ | ||
proteinChange: 'L702H', | ||
}); | ||
|
||
const mutation2: Mutation = initMutation({ | ||
proteinChange: 'H875Y', | ||
}); | ||
|
||
const mutation3: Mutation = initMutation({ | ||
proteinChange: 'A646D', | ||
}); | ||
|
||
const rowDataByProteinChange: { | ||
[proteinChange: string]: GroupComparisonMutation; | ||
} = { | ||
L702H: { | ||
proteinChange: 'L702H', | ||
enrichedGroup: '(A) Metastasis', | ||
groupAMutatedCount: 9, | ||
groupAMutatedPercentage: 3.2490974729241873, | ||
groupBMutatedCount: 0, | ||
groupBMutatedPercentage: 0, | ||
logRatio: Infinity, | ||
pValue: 0.00036917378321091467, | ||
qValue: 0.005906780531374635, | ||
}, | ||
H875Y: { | ||
proteinChange: 'H875Y', | ||
enrichedGroup: '(A) Metastasis', | ||
groupAMutatedCount: 9, | ||
groupBMutatedCount: 1, | ||
groupAMutatedPercentage: 3.2490974729241873, | ||
groupBMutatedPercentage: 0.26041666666666663, | ||
logRatio: 3.6411453361142803, | ||
pValue: 0.0023260213212133113, | ||
qValue: 0.01860817056970649, | ||
}, | ||
A646D: { | ||
proteinChange: 'A646D', | ||
enrichedGroup: '(B) Primary', | ||
groupAMutatedCount: 0, | ||
groupBMutatedCount: 1, | ||
groupAMutatedPercentage: 0, | ||
groupBMutatedPercentage: 0.26041666666666663, | ||
logRatio: -Infinity, | ||
pValue: 0.999999999999234, | ||
qValue: 0.999999999999234, | ||
}, | ||
}; | ||
|
||
it('gets mutated count percentage text value properly', () => { | ||
assert.equal( | ||
getGroupMutatedCountPercentageTextValue(rowDataByProteinChange, 0, [ | ||
mutation1, | ||
]), | ||
'9 (3.25%)' | ||
); | ||
assert.equal( | ||
getGroupMutatedCountPercentageTextValue(rowDataByProteinChange, 1, [ | ||
mutation1, | ||
]), | ||
'0 (0.00%)' | ||
); | ||
|
||
assert.equal( | ||
getGroupMutatedCountPercentageTextValue(rowDataByProteinChange, 0, [ | ||
mutation2, | ||
]), | ||
'9 (3.25%)' | ||
); | ||
assert.equal( | ||
getGroupMutatedCountPercentageTextValue(rowDataByProteinChange, 1, [ | ||
mutation2, | ||
]), | ||
'1 (0.26%)' | ||
); | ||
|
||
assert.equal( | ||
getGroupMutatedCountPercentageTextValue(rowDataByProteinChange, 0, [ | ||
mutation3, | ||
]), | ||
'0 (0.00%)' | ||
); | ||
assert.equal( | ||
getGroupMutatedCountPercentageTextValue(rowDataByProteinChange, 1, [ | ||
mutation3, | ||
]), | ||
'1 (0.26%)' | ||
); | ||
}); | ||
}); |
74 changes: 74 additions & 0 deletions
74
src/shared/components/mutationTable/column/LogRatioColumnFormatter.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { assert } from 'chai'; | ||
import { initMutation } from 'test/MutationMockUtils'; | ||
import { Mutation } from 'cbioportal-ts-api-client'; | ||
import { GroupComparisonMutation } from 'shared/model/GroupComparisonMutation'; | ||
import { getLogRatioTextValue } from './LogRatioColumnFormatter'; | ||
|
||
describe('LogRatioColumnFormatter', () => { | ||
const mutation1: Mutation = initMutation({ | ||
proteinChange: 'L702H', | ||
}); | ||
|
||
const mutation2: Mutation = initMutation({ | ||
proteinChange: 'H875Y', | ||
}); | ||
|
||
const mutation3: Mutation = initMutation({ | ||
proteinChange: 'A646D', | ||
}); | ||
|
||
const rowDataByProteinChange: { | ||
[proteinChange: string]: GroupComparisonMutation; | ||
} = { | ||
L702H: { | ||
proteinChange: 'L702H', | ||
enrichedGroup: '(A) Metastasis', | ||
groupAMutatedCount: 9, | ||
groupAMutatedPercentage: 3.2490974729241873, | ||
groupBMutatedCount: 0, | ||
groupBMutatedPercentage: 0, | ||
logRatio: Infinity, | ||
pValue: 0.00036917378321091467, | ||
qValue: 0.005906780531374635, | ||
}, | ||
H875Y: { | ||
proteinChange: 'H875Y', | ||
enrichedGroup: '(A) Metastasis', | ||
groupAMutatedCount: 9, | ||
groupBMutatedCount: 1, | ||
groupAMutatedPercentage: 3.2490974729241873, | ||
groupBMutatedPercentage: 0.26041666666666663, | ||
logRatio: 3.6411453361142803, | ||
pValue: 0.0023260213212133113, | ||
qValue: 0.01860817056970649, | ||
}, | ||
A646D: { | ||
proteinChange: 'A646D', | ||
enrichedGroup: '(B) Primary', | ||
groupAMutatedCount: 0, | ||
groupBMutatedCount: 1, | ||
groupAMutatedPercentage: 0, | ||
groupBMutatedPercentage: 0.26041666666666663, | ||
logRatio: -Infinity, | ||
pValue: 0.999999999999234, | ||
qValue: 0.999999999999234, | ||
}, | ||
}; | ||
|
||
it('gets mutated count percentage text value properly', () => { | ||
assert.equal( | ||
getLogRatioTextValue(rowDataByProteinChange, [mutation1]), | ||
'>10' | ||
); | ||
|
||
assert.equal( | ||
getLogRatioTextValue(rowDataByProteinChange, [mutation2]), | ||
'3.64' | ||
); | ||
|
||
assert.equal( | ||
getLogRatioTextValue(rowDataByProteinChange, [mutation3]), | ||
'<-10' | ||
); | ||
}); | ||
}); |
Oops, something went wrong.