diff --git a/browser/src/GenePage/TissueExpressionTrack.spec.tsx b/browser/src/GenePage/TissueExpressionTrack.spec.tsx new file mode 100644 index 000000000..cd32fde3d --- /dev/null +++ b/browser/src/GenePage/TissueExpressionTrack.spec.tsx @@ -0,0 +1,65 @@ +import React from 'react' +import renderer from 'react-test-renderer' +import { jest, describe, expect, test } from '@jest/globals' + +import TissueExpressionTrack, { TranscriptWithTissueExpression } from './TissueExpressionTrack' + +import { BrowserRouter } from 'react-router-dom' +import { RegionViewerContext } from '@gnomad/region-viewer' + +import geneFactory from '../__factories__/Gene' + +describe('TissueExpressionTrack', () => { + const childProps = { + centerPanelWidth: 500, + isPositionDefined: true, + leftPanelWidth: 100, + // same regions as pext factory regions + regions: [ + { + start: 0, + stop: 100, + }, + ], + rightPanelWidth: 100, + scalePosition: (i: number) => i, + } + + test('has no unexpected changes', () => { + const testTranscriptId = 'transcript-1337' + const gene = geneFactory.build({ canonical_transcript_id: testTranscriptId }) + + const testExons = [ + { + feature_type: 'CDS', + start: 10, + stop: 20, + }, + { + feature_type: 'CDS', + start: 20, + stop: 30, + }, + { + feature_type: 'CDS', + start: 40, + stop: 60, + }, + ] + + const tree = renderer.create( + + + + ) + + expect(tree).toMatchSnapshot() + }) +}) diff --git a/browser/src/GenePage/__snapshots__/TissueExpressionTrack.spec.tsx.snap b/browser/src/GenePage/__snapshots__/TissueExpressionTrack.spec.tsx.snap new file mode 100644 index 000000000..c85a6bce2 --- /dev/null +++ b/browser/src/GenePage/__snapshots__/TissueExpressionTrack.spec.tsx.snap @@ -0,0 +1,284 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`TissueExpressionTrack has no unexpected changes 1`] = ` +
+
+
+
+
+
+ + + Mean pext + + +
+
+
+
+ + + + + + + + + + + + + + + + + + + + +
+
+
+ + + + + + 1 + + + + + + 0 + + + +
+
+
+
+
+`; diff --git a/browser/src/__factories__/Gene.ts b/browser/src/__factories__/Gene.ts index 857ec6a49..fc74f60aa 100644 --- a/browser/src/__factories__/Gene.ts +++ b/browser/src/__factories__/Gene.ts @@ -1,11 +1,12 @@ import { Factory } from 'fishery' -import { Gene, GeneMetadata } from '../GenePage/GenePage' +import { Gene, GeneMetadata, Pext } from '../GenePage/GenePage' import { Transcript } from '../TranscriptPage/TranscriptPage' import transcriptFactory from './Transcript' import { HeterozygousVariantCooccurrenceCountsPerSeverityAndAfFactory, HomozygousVariantCooccurrenceCountsPerSeverityAndAfFactory, } from './VariantCooccurrenceCountsPerSeverityAndAf' +import { pextFactory } from './TissueExpression' const geneFactory = Factory.define(({ params, associations }) => { const { @@ -50,6 +51,8 @@ const geneFactory = Factory.define(({ params, associations }) => { ] : [] + const pext = pextFactory.build() + return { gene_id, gene_version, @@ -69,6 +72,7 @@ const geneFactory = Factory.define(({ params, associations }) => { structural_variants, clinvar_variants, copy_number_variants, + pext, } }) diff --git a/browser/src/__factories__/TissueExpression.tsx b/browser/src/__factories__/TissueExpression.tsx index ea6eecaa0..8da8b68f5 100644 --- a/browser/src/__factories__/TissueExpression.tsx +++ b/browser/src/__factories__/TissueExpression.tsx @@ -1,5 +1,62 @@ import { Factory } from 'fishery' import { GtexTissueExpression } from '../GenePage/TranscriptsTissueExpression' +import { Pext } from '../GenePage/GenePage' + +type PextParams = { + tissues?: string[] + regions?: { + start: number + stop: number + }[] +} + +export const pextFactory = Factory.define(({ params }) => { + const defaultTissues = ['adipose_subcutaneous', 'adipose_visceral_omentum', 'adrenal_gland'] + + const { tissues: paramTissues, regions: paramRegions } = params as PextParams + + const tissues = [...defaultTissues, ...(paramTissues ?? [])] + + const defaultRegions = [ + { + start: 10, + stop: 20, + }, + { + start: 20, + stop: 30, + }, + { + start: 40, + stop: 60, + }, + ] + + const regions = [...defaultRegions, ...(paramRegions ?? [])] + + const pextObject: Pext = { + regions: regions.map((region, i) => { + const dummyValue = i / Object.keys(tissues).length + + const tissueObjects = tissues.map((tissue) => { + return { + tissue: tissue, + value: dummyValue, + } + }) + + return { + start: region.start, + stop: region.stop, + mean: dummyValue, + tissues: tissueObjects, + } + }), + flags: [], + } + + return pextObject +}) export const gtexTissueExpressionFactory = Factory.define(({ params }) => { const defaultTissues = {