-
Notifications
You must be signed in to change notification settings - Fork 1
DEVSU-2556 Genomic Alterations Table Redesign #809
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
bnguyen-bcgsc
merged 13 commits into
develop
from
feat/DEVSU-2556-key-alterations-table-redesign
Aug 25, 2026
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
0dc40e7
- DEVSU-2556
bnguyen-bcgsc 937c613
- Update columns rendered per Melissa's specs in DEVSU-2556
bnguyen-bcgsc 69ed8f0
Merge branch 'develop' into feat/DEVSU-2556-key-alterations-table-red…
bnguyen-bcgsc ef30ecd
Merge branch 'develop' into feat/DEVSU-2556-key-alterations-table-red…
bnguyen-bcgsc e1b5066
- Update unit tests of Key Alterations to provide query client contex…
bnguyen-bcgsc bfe17f6
- Pass GeneVariant record type in table component level so newly adde…
bnguyen-bcgsc 729bf4d
Merge branch 'develop' into feat/DEVSU-2556-key-alterations-table-red…
bnguyen-bcgsc 1b58187
Merge branch 'develop' into feat/DEVSU-2556-key-alterations-table-red…
kttkjl 21d1fa5
Merge branch 'develop' into feat/DEVSU-2556-key-alterations-table-red…
bnguyen-bcgsc 752d661
Merge branch 'develop' into feat/DEVSU-2556-key-alterations-table-red…
bnguyen-bcgsc cb9d18b
- Reuse exported actionColumnDef in genomic alterations table columnDefs
bnguyen-bcgsc 7633e08
- Fix any types
bnguyen-bcgsc 212fde2
- Update colId for actionsColumnDefs to 'Actions' instead of 'actions…
bnguyen-bcgsc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
106 changes: 106 additions & 0 deletions
106
...omicSummary/components/GenomicAlterationsTable/__tests__/GenomicAlterationsTable.test.tsx
This file contains hidden or 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,106 @@ | ||
| import React from 'react'; | ||
| import { | ||
| render, | ||
| screen, | ||
| waitFor, | ||
| } from '@testing-library/react'; | ||
| import { ACTIONS_COLUMN } from '@/utils/actionsColumnDef'; | ||
| import { SmallMutationType, ExpOutliersType } from '@/common'; | ||
|
|
||
| import GenomicAlterationsTable from '..'; | ||
|
|
||
| const mockDataTable = jest.fn(); | ||
| const mockPrintTable = jest.fn(); | ||
|
|
||
| jest.mock('@/components/DataTable', () => (props) => { | ||
| mockDataTable(props); | ||
| return <div data-testid="data-table">{props.titleText || 'data-table'}</div>; | ||
| }); | ||
|
|
||
| jest.mock('@/components/PrintTable', () => (props) => { | ||
| mockPrintTable(props); | ||
| return <div data-testid="print-table">print-table</div>; | ||
| }); | ||
|
|
||
| describe('GenomicAlterationsTable', () => { | ||
| beforeEach(() => { | ||
| mockDataTable.mockClear(); | ||
| mockPrintTable.mockClear(); | ||
| }); | ||
|
|
||
| test('renders DataTable for smallMutation in non-print mode', async () => { | ||
| render( | ||
| <GenomicAlterationsTable | ||
| variantCategory="smallMutation" | ||
| variantData={[{ ident: 'v1', gene: { name: 'TP53' } } as SmallMutationType]} | ||
| isPrint={false} | ||
| />, | ||
| ); | ||
|
|
||
| expect(await screen.findByTestId('data-table')).toBeInTheDocument(); | ||
| expect(screen.getByText('Small Mutations')).toBeInTheDocument(); | ||
|
|
||
| expect(mockDataTable).toHaveBeenCalled(); | ||
| const dataTableProps = mockDataTable.mock.calls[0][0]; | ||
| expect(dataTableProps.isPrint).toBe(false); | ||
| expect(dataTableProps.canExport).toBe(true); | ||
| expect(dataTableProps.titleText).toBe('Small Mutations'); | ||
|
|
||
| expect(mockPrintTable).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| test('renders PrintTable for smallMutation in print mode', async () => { | ||
| render( | ||
| <GenomicAlterationsTable | ||
| variantCategory="smallMutation" | ||
| variantData={[{ ident: 'v1', gene: { name: 'TP53' } } as SmallMutationType]} | ||
| isPrint | ||
| />, | ||
| ); | ||
|
|
||
| expect(await screen.findByTestId('print-table')).toBeInTheDocument(); | ||
| expect(screen.getByText('Small Mutations')).toBeInTheDocument(); | ||
|
|
||
| expect(mockPrintTable).toHaveBeenCalled(); | ||
| expect(mockDataTable).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| test('uses flattened expression print columns and excludes Actions', async () => { | ||
| render( | ||
| <GenomicAlterationsTable | ||
| variantCategory="expression" | ||
| variantData={[{ ident: 'v1', gene: { name: 'EGFR', copyVariants: { cnvState: 'gain' } } } as ExpOutliersType]} | ||
| isPrint | ||
| />, | ||
| ); | ||
|
|
||
| await screen.findByTestId('print-table'); | ||
|
|
||
| const printTableProps = mockPrintTable.mock.calls[0][0]; | ||
| const printHeaders = printTableProps.columnDefs.map((col) => col.headerName); | ||
|
|
||
| expect(printHeaders).toContain('Gene'); | ||
| expect(printHeaders).toContain('Expression Class'); | ||
| expect(printHeaders).toContain('Disease Perc'); | ||
| expect(printHeaders).toContain('Disease Z-Score'); | ||
| expect(printHeaders).not.toContain(ACTIONS_COLUMN); | ||
| expect(printTableProps.fullWidth).toBe(true); | ||
| }); | ||
|
|
||
| test('shows loader and no tables for unknown variantCategory', async () => { | ||
| render( | ||
| <GenomicAlterationsTable | ||
| variantCategory="unknown" | ||
| variantData={[]} | ||
| isPrint={false} | ||
| />, | ||
| ); | ||
|
|
||
| await waitFor(() => { | ||
| expect(screen.getByRole('progressbar')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| expect(mockDataTable).not.toHaveBeenCalled(); | ||
| expect(mockPrintTable).not.toHaveBeenCalled(); | ||
| }); | ||
| }); |
155 changes: 155 additions & 0 deletions
155
...ews/ReportView/components/GenomicSummary/components/GenomicAlterationsTable/columnDefs.ts
This file contains hidden or 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,155 @@ | ||
| // eslint-disable-next-line import/no-extraneous-dependencies | ||
| import { ColDef, ColGroupDef } from '@ag-grid-community/core'; | ||
| import { createGeneRelatedValueGetter } from '@/views/ReportView/components/StructuralVariants/columnDefs'; | ||
| import { actionsColDef } from '@/utils/actionsColumnDef'; | ||
|
|
||
| const collator = new Intl.Collator(undefined, { numeric: true, sensitivity: 'base' }); | ||
|
|
||
| const smallMutationsColumnDefs: ColDef[] = [{ | ||
| headerName: 'Gene', | ||
| field: 'gene.name', | ||
| cellRenderer: 'GeneCellRenderer', | ||
| cellRendererParams: { link: true }, | ||
| }, | ||
| { | ||
| headerName: 'Protein Change', | ||
| field: 'proteinChange', | ||
| }, | ||
| { | ||
| headerName: 'Transcript', | ||
| field: 'transcript', | ||
| }, | ||
| { | ||
| headerName: 'Location', | ||
| field: 'location', | ||
| valueGetter: ({ data }) => data.chromosome && `${data.chromosome}:${data.startPosition}${data.endPosition && data.startPosition !== data.endPosition | ||
| ? `-${data.endPosition}` | ||
| : '' | ||
| }`, | ||
| }, | ||
| { | ||
| headerName: 'Zygosity', | ||
| field: 'zygosity', | ||
| }, | ||
| { | ||
| headerName: 'VAF %', | ||
| colId: 'tumourAltCount/tumourDepth', | ||
| field: 'tumourAltCount/tumourDepth', | ||
| valueGetter: ({ | ||
| data: { | ||
| tumourAltCount, tumourDepth, rnaAltCount, rnaDepth, | ||
| }, | ||
| }) => { | ||
| if ((tumourAltCount && tumourDepth) || (tumourAltCount === 0 || tumourDepth === 0)) { | ||
| return ((tumourAltCount / tumourDepth) * 100).toFixed(0); | ||
| } | ||
| if ((rnaAltCount && rnaDepth) || (rnaAltCount === 0 || rnaDepth === 0)) { | ||
| return 'N/A (RNA)'; | ||
| } | ||
| return ''; | ||
| }, | ||
| comparator: collator.compare, | ||
| }, | ||
| { | ||
| ...actionsColDef, | ||
| }]; | ||
|
|
||
| const copyNumberColumnDefs: ColDef[] = [{ | ||
| headerName: 'Gene', | ||
| cellRenderer: 'GeneCellRenderer', | ||
| cellRendererParams: { link: true }, | ||
| field: 'gene.name', | ||
| }, | ||
| { | ||
| headerName: 'Copy Change', | ||
| field: 'copyChange', | ||
| valueFormatter: (params) => { | ||
| if (params.value === null || params.value === undefined) return ''; | ||
|
|
||
| const num = Number(params.value); | ||
|
|
||
| // If the number is greater than zero, prepend the "+" sign | ||
| if (num > 0) { | ||
| return `+${num}`; | ||
| } | ||
| // Zero or negative numbers will naturally format with their own sign or nothing | ||
| return num.toString(); | ||
| }, | ||
| }, | ||
| { | ||
| headerName: 'CNV State', | ||
| field: 'cnvState', | ||
| }, | ||
| { | ||
| headerName: 'Chr:band', | ||
| field: 'chromosomeBand', | ||
| }, | ||
| { | ||
| ...actionsColDef, | ||
| }]; | ||
|
|
||
| const structuralVariantsColumnDefs: ColDef[] = [{ | ||
| headerName: 'Genes 5`::3`', | ||
| colId: 'genes', | ||
| cellRenderer: 'GeneCellRenderer', | ||
| cellRendererParams: { link: true }, | ||
| valueGetter: createGeneRelatedValueGetter('name', ' :: '), | ||
| }, | ||
| { | ||
| headerName: 'Exons 5`/3`', | ||
| colId: 'exons', | ||
| valueGetter: (params) => (params.data.exon1 && params.data.exon2 | ||
| ? `${params.data.exon1}:${params.data.exon2}` | ||
| : (params.data.exon1 || params.data.exon2)), | ||
| }, | ||
| { | ||
| headerName: 'Breakpoint', | ||
| colId: 'breakpoint', | ||
| field: 'breakpoint', | ||
| }, | ||
| { | ||
| headerName: 'Event Type', | ||
| colId: 'eventType', | ||
| field: 'eventType', | ||
| }, | ||
| { | ||
| headerName: 'Sample', | ||
| colId: 'detectedIn', | ||
| field: 'detectedIn', | ||
| }, | ||
| { | ||
| headerName: 'Cytogenic Description', | ||
| colId: 'conventionalName', | ||
| field: 'conventionalName', | ||
| }, | ||
| { | ||
| ...actionsColDef, | ||
| }]; | ||
|
|
||
| const expressionColumnDefs: Array<ColDef | ColGroupDef> = [{ | ||
| headerName: 'Gene', | ||
| field: 'gene.name', | ||
| cellRenderer: 'GeneCellRenderer', | ||
| cellRendererParams: { link: true }, | ||
| }, | ||
| { | ||
| headerName: 'Expression Class', | ||
| field: 'expressionState', | ||
| }, | ||
| { | ||
| headerName: 'Disease', | ||
| children: [ | ||
| { headerName: 'Perc', field: 'diseasePercentile' }, | ||
| { headerName: 'Z-Score', field: 'diseaseZScore' }, | ||
| ], | ||
| }, | ||
| { | ||
| ...actionsColDef, | ||
| }]; | ||
|
|
||
| export { | ||
| smallMutationsColumnDefs, | ||
| copyNumberColumnDefs, | ||
| expressionColumnDefs, | ||
| structuralVariantsColumnDefs, | ||
| }; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.