@@ -5,36 +5,66 @@ import {
5
5
RNAMitochondrialGeneConstraint ,
6
6
} from '../GenePage/GenePage'
7
7
import { BaseTable } from '@gnomad/ui'
8
+ import { ConstraintHighlight } from './constraintMetrics'
8
9
9
10
const isProteinMitochondrialGeneConstraint = (
10
11
constraint : MitochondrialGeneConstraint
11
12
) : constraint is ProteinMitochondrialGeneConstraint =>
12
13
Object . prototype . hasOwnProperty . call ( constraint , 'exp_lof' )
13
14
15
+ type Highlight = {
16
+ threshold : number
17
+ color : string
18
+ }
19
+
20
+ type ConstraintRowProps = {
21
+ category : string
22
+ expected : number
23
+ observed : number
24
+ oe : number
25
+ oeLower : number
26
+ oeUpper : number
27
+ highlight ?: Highlight
28
+ }
29
+
30
+ const PROTEIN_GENE_HIGHLIGHT : Highlight = {
31
+ threshold : 0.058 ,
32
+ color : '#ff2600' ,
33
+ }
34
+
35
+ const RNA_GENE_HIGHLIGHT : Highlight = {
36
+ threshold : 0.27 ,
37
+ color : PROTEIN_GENE_HIGHLIGHT . color ,
38
+ }
39
+
14
40
const ConstraintRow = ( {
15
41
category,
16
42
expected,
17
43
observed,
18
44
oe,
19
45
oeLower,
20
46
oeUpper,
21
- } : {
22
- category : string
23
- expected : number
24
- observed : number
25
- oe : number
26
- oeLower : number
27
- oeUpper : number
28
- } ) => (
29
- < tr >
30
- < th scope = "row" > { category } </ th >
31
- < td > { expected < 10 ? expected . toFixed ( 2 ) : expected . toFixed ( 1 ) } </ td >
32
- < td > { observed < 10 ? observed . toFixed ( 2 ) : observed . toFixed ( 1 ) } </ td >
33
- < td >
34
- o/e = { oe . toFixed ( 2 ) } ({ oeLower . toFixed ( 2 ) } - { oeUpper . toFixed ( 2 ) } )
35
- </ td >
36
- </ tr >
37
- )
47
+ highlight,
48
+ } : ConstraintRowProps ) => {
49
+ const oeUpperFixed = oeUpper . toFixed ( 2 )
50
+ const oeUpperContent =
51
+ highlight && oeUpper < highlight . threshold ? (
52
+ < ConstraintHighlight highlightColor = { highlight . color } > { oeUpperFixed } </ ConstraintHighlight >
53
+ ) : (
54
+ oeUpperFixed
55
+ )
56
+
57
+ return (
58
+ < tr >
59
+ < th scope = "row" > { category } </ th >
60
+ < td > { expected < 10 ? expected . toFixed ( 2 ) : expected . toFixed ( 1 ) } </ td >
61
+ < td > { observed < 10 ? observed . toFixed ( 2 ) : observed . toFixed ( 1 ) } </ td >
62
+ < td >
63
+ o/e = { oe . toFixed ( 2 ) } ({ oeLower . toFixed ( 2 ) } - { oeUpperContent } )
64
+ </ td >
65
+ </ tr >
66
+ )
67
+ }
38
68
39
69
const ProteinConstraintMetrics = ( {
40
70
constraint,
@@ -83,6 +113,7 @@ const ProteinConstraintMetrics = ({
83
113
oe = { oe_lof }
84
114
oeLower = { oe_lof_lower }
85
115
oeUpper = { oe_lof_upper }
116
+ highlight = { PROTEIN_GENE_HIGHLIGHT }
86
117
/>
87
118
</ tbody >
88
119
)
@@ -99,6 +130,7 @@ const RNAConstraintMetrics = ({ constraint }: { constraint: RNAMitochondrialGene
99
130
oe = { oe }
100
131
oeLower = { oe_lower }
101
132
oeUpper = { oe_upper }
133
+ highlight = { RNA_GENE_HIGHLIGHT }
102
134
/>
103
135
</ tbody >
104
136
)
0 commit comments