Skip to content

Commit

Permalink
fixup(browser): appease typecheck
Browse files Browse the repository at this point in the history
  • Loading branch information
rileyhgrant committed Oct 21, 2024
1 parent 72dad5d commit 8cc0010
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 26 deletions.
1 change: 1 addition & 0 deletions browser/src/GenePage/GenePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,7 @@ const GenePage = ({ datasetId, gene, geneId }: Props) => {
{showTranscripts && (
<TrackWrapper>
<GeneTranscriptsTrack
datasetId={datasetId}
isTissueExpressionAvailable={!!gene.pext}
gene={gene}
includeNonCodingTranscripts={includeNonCodingTranscripts}
Expand Down
6 changes: 4 additions & 2 deletions browser/src/GenePage/GeneTranscriptsTrack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import Link from '../Link'
import sortedTranscripts from './sortedTranscripts'
import TranscriptsTissueExpression from './TranscriptsTissueExpression'
import { Gene } from './GenePage'
import { hasStructuralVariants } from '../../../dataset-metadata/metadata'
import { DatasetId, hasStructuralVariants } from '../../../dataset-metadata/metadata'
import { GtexTissueDetail, TranscriptWithTissueExpression } from './TissueExpressionTrack'

const TranscriptsInfoWrapper = styled.div`
Expand All @@ -36,6 +36,7 @@ const RightPanel = styled.div`
`

type GeneTranscriptsTrack = {
datasetId: DatasetId
isTissueExpressionAvailable: boolean
gene: Gene
includeNonCodingTranscripts: boolean
Expand All @@ -45,6 +46,7 @@ type GeneTranscriptsTrack = {
}

const GeneTranscriptsTrack = ({
datasetId,
isTissueExpressionAvailable,
gene,
includeNonCodingTranscripts,
Expand Down Expand Up @@ -177,7 +179,7 @@ const GeneTranscriptsTrack = ({
tooltip={`Mean expression across all tissues = ${meanExpression.toFixed(
2
)} TPM\nMost expressed in ${
gtexTissues[tissueMostExpressedIn]!.fullName
gtexTissues[tissueMostExpressedIn as GtexTissueName]!.fullName
} (${maxExpression.toFixed(2)} TPM)`}
>
<rect
Expand Down
16 changes: 7 additions & 9 deletions browser/src/GenePage/TissueExpressionTrack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Track } from '@gnomad/region-viewer'
import { RegionsPlot } from '@gnomad/track-regions'
import { Badge, Button, Modal, SearchInput, Select, TooltipAnchor } from '@gnomad/ui'

import { ALL_GTEX_TISSUES, AllGtexTissues, GtexTissueName } from '../gtex'
import { ALL_GTEX_TISSUES, GtexTissueName, GtexTissues } from '../gtex'
import InfoButton from '../help/InfoButton'

import { logButtonClick } from '../analytics'
Expand Down Expand Up @@ -68,7 +68,7 @@ const TRACK_HEIGHT = 20
const heightScale = scaleLinear().domain([0, 1]).range([0, TRACK_HEIGHT]).clamp(true)

type PextRegionsPlotProps = {
gtexTissues: Partial<AllGtexTissues>
gtexTissues: Partial<GtexTissues>
color: string
regions: {
start: number
Expand Down Expand Up @@ -153,7 +153,7 @@ type ExpressedTissue = {
}

type IndividualTissueTrackProps = {
gtexTissues: Partial<AllGtexTissues>
gtexTissues: Partial<GtexTissues>
exons: {
start: number
stop: number
Expand All @@ -167,7 +167,7 @@ type IndividualTissueTrackProps = {
maxTranscriptExpressionInTissue: number
maxMeanTranscriptExpressionInAnyTissue: number
meanTranscriptExpressionInTissue: number
tissue: string
tissue: GtexTissueName
transcriptWithMaxExpressionInTissue: {
transcript_id: string
transcript_version: string
Expand Down Expand Up @@ -221,8 +221,7 @@ const IndividualTissueTrack = ({
)} (${transcriptWithMaxExpressionInTissue!.transcript_id}.${
transcriptWithMaxExpressionInTissue!.transcript_version
})`
: // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
`Gene is not expressed in ${gtexTissues[tissue].fullName}`
: `Gene is not expressed in ${gtexTissues[tissue]!.fullName}`
}
>
<rect x={12} y={2} width={25} height={27} fill="none" pointerEvents="visible" />
Expand Down Expand Up @@ -256,8 +255,7 @@ const IndividualTissueTrack = ({
<PlotWrapper key={tissue}>
<PextRegionsPlot
gtexTissues={gtexTissues}
// @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
color={gtexTissues[tissue].color}
color={gtexTissues[tissue]!.color}
regions={getPlotRegions(
expressionRegions,
(r: any) =>
Expand Down Expand Up @@ -602,7 +600,7 @@ const TissueExpressionTrack = ({
return (
<IndividualTissueTrack
gtexTissues={gtexTissues}
key={`${tissue}-${datasetId}`}
key={`${tissue}`}
exons={exons}
expressionRegions={expressionRegions}
maxTranscriptExpressionInTissue={
Expand Down
4 changes: 2 additions & 2 deletions browser/src/GenePage/TranscriptsTissueExpression.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import styled from 'styled-components'

import { Select } from '@gnomad/ui'

import { AllGtexTissues } from '../gtex'
import { GtexTissues } from '../gtex'

import sortedTranscripts from './sortedTranscripts'
import TranscriptsTissueExpressionPlot from './TranscriptsTissueExpressionPlot'
Expand All @@ -21,7 +21,7 @@ const isTranscriptCoding = (transcript: any) =>
transcript.exons.some((exon: any) => exon.feature_type === 'CDS')

type TranscriptsTissueExpressionProps = {
gtexTissues: Partial<AllGtexTissues>
gtexTissues: Partial<GtexTissues>
transcripts: TranscriptWithTissueExpression[]
includeNonCodingTranscripts: boolean
preferredTranscriptId?: string
Expand Down
19 changes: 6 additions & 13 deletions browser/src/GenePage/TranscriptsTissueExpressionPlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import React from 'react'
import { AxisBottom, AxisLeft } from '@visx/axis'

import { TooltipAnchor } from '@gnomad/ui'
import { AllGtexTissueNames, AllGtexTissues } from '../gtex'
import { TranscriptWithTissueExpression } from './TissueExpressionTrack'
import { GtexTissueName, GtexTissues } from '../gtex'

const mergeOverlappingRegions = (regions: any) => {
if (regions.length === 0) {
Expand Down Expand Up @@ -121,8 +121,8 @@ const margin = {
}

type TranscriptsTissueExpressionPlotProps = {
gtexTissues: Partial<AllGtexTissues>
tissues?: AllGtexTissueNames[]
gtexTissues: Partial<GtexTissues>
tissues?: GtexTissueName[]
transcripts: TranscriptWithTissueExpression[]
starredTranscriptId?: string
}
Expand All @@ -133,7 +133,7 @@ const TranscriptsTissueExpressionPlot = ({
transcripts,
starredTranscriptId,
}: TranscriptsTissueExpressionPlotProps) => {
type RenderedTissue = AllGtexTissueNames | 'Mean' | 'Median'
type RenderedTissue = GtexTissueName | 'Mean' | 'Median'
const renderedTissues: RenderedTissue[] = ['Mean', 'Median', ...tissues!]

const transcriptsWithMeanAndMedianExpression = transcripts.map((transcript) => {
Expand All @@ -148,7 +148,7 @@ const TranscriptsTissueExpressionPlot = ({
return {
...transcript,
gtex_tissue_expression: {
...(gtexTissueExpressionObject as Partial<Record<AllGtexTissueNames, number>>),
...(gtexTissueExpressionObject as Partial<Record<GtexTissueName, number>>),
Mean: mean(expressionValues),
Median: median(expressionValues),
},
Expand Down Expand Up @@ -279,7 +279,7 @@ const TranscriptsTissueExpressionPlot = ({
// @ts-expect-error TS(2322) FIXME: Type 'ScaleOrdinal<string, unknown, never>' is not... Remove this comment to see the full error message
scale={xAxisScale}
stroke="#333"
tickFormat={(tissue: AllGtexTissueNames) => {
tickFormat={(tissue: GtexTissueName) => {
return gtexTissues[tissue] ? gtexTissues[tissue]!.fullName : tissue
}}
tickLabelProps={(value) => ({
Expand Down Expand Up @@ -354,11 +354,4 @@ const TranscriptsTissueExpressionPlot = ({
)
}

// TranscriptsTissueExpressionPlot.defaultProps = {
// tissues: Object.entries(GTEX_TISSUE_NAMES)
// .sort((t1: any, t2: any) => t1[1].localeCompare(t2[1]))
// .map((t: any) => t[0]),
// starredTranscriptId: null,
// }

export default TranscriptsTissueExpressionPlot

0 comments on commit 8cc0010

Please sign in to comment.