@@ -2,7 +2,7 @@ import PropTypes from 'prop-types'
22import React from 'react'
33import styled from 'styled-components'
44
5- import { BaseTable , ExternalLink , Tabs } from '@gnomad/ui'
5+ import { BaseTable , ExternalLink } from '@gnomad/ui'
66
77import HelpButton from '../base/HelpButton'
88
@@ -23,6 +23,22 @@ const renderOddsRatio = (value) => {
2323 return value . toPrecision ( 3 )
2424}
2525
26+ const safeReturnValue = ( object , fieldName ) => {
27+ return object [ fieldName ] === null ? '-' : object [ fieldName ]
28+ }
29+
30+ const createGeneTableRow = ( object , category , categoryAbbrev ) => {
31+ return (
32+ < tr >
33+ < th scope = "row" > { category } </ th >
34+ < td > { safeReturnValue ( object , `${ categoryAbbrev } _case_carrier` ) } </ td >
35+ < td > { safeReturnValue ( object , `${ categoryAbbrev } _ctrl_carrier` ) } </ td >
36+ < td > { safeReturnValue ( object , `${ categoryAbbrev } _p_value` ) } </ td >
37+ < td > { renderOddsRatio ( object [ `${ categoryAbbrev } _odds_ratio` ] ) } </ td >
38+ </ tr >
39+ )
40+ }
41+
2642const BipExGeneResult = ( { result } ) => (
2743 < div >
2844 < Table >
@@ -36,69 +52,42 @@ const BipExGeneResult = ({ result }) => (
3652 </ tr >
3753 </ thead >
3854 < tbody >
39- < tr >
40- < th scope = "row" > Protein-truncating</ th >
41- < td > { result . ptv_case_carrier === null ? '-' : result . ptv_case_carrier } </ td >
42- < td > { result . ptv_ctrl_carrier === null ? '-' : result . ptv_ctrl_carrier } </ td >
43- < td > { result . ptv_p_value === null ? '-' : result . ptv_p_value } </ td >
44- < td > { result . ptv_odds_ratio === null ? '-' : result . ptv_odds_ratio } </ td >
45- </ tr >
46- < tr >
47- < th scope = "row" > Missense</ th >
48- < td > { result . mis_case_carrier === null ? '-' : result . mis_case_carrier } </ td >
49- < td > { result . mis_ctrl_carrier === null ? '-' : result . mis_ctrl_carrier } </ td >
50- < td > { result . mis_p_value === null ? '-' : result . mis_p_value } </ td >
51- < td > { result . mis_odds_ratio === null ? '-' : result . mis_odds_ratio } </ td >
52- </ tr >
53- < tr >
54- < th scope = "row" > Missense + Protein-truncating</ th >
55- < td > { result . ptv_mis_case_carrier === null ? '-' : result . ptv_mis_case_carrier } </ td >
56- < td > { result . ptv_mis_ctrl_carrier === null ? '-' : result . ptv_mis_ctrl_carrier } </ td >
57- < td > { result . ptv_mis_p_value === null ? '-' : result . ptv_mis_p_value } </ td >
58- < td > { result . ptv_mis_odds_ratio === null ? '-' : result . ptv_mis_odds_ratio } </ td >
59- </ tr >
60- < tr >
61- < th scope = "row" > Synonymous</ th >
62- < td > { result . syn_case_carrier === null ? '-' : result . syn_case_carrier } </ td >
63- < td > { result . syn_ctrl_carrier === null ? '-' : result . syn_ctrl_carrier } </ td >
64- < td > { result . syn_p_value === null ? '-' : result . syn_p_value } </ td >
65- < td > { result . syn_odds_ratio === null ? '-' : result . syn_odds_ratio } </ td >
66- </ tr >
55+ { createGeneTableRow ( result , 'Protein-truncating' , 'ptv' ) }
56+ { createGeneTableRow ( result , 'Missense' , 'mis' ) }
57+ { createGeneTableRow ( result , 'Missense + Protein-truncating' , 'ptv_mis' ) }
58+ { createGeneTableRow ( result , 'Synonmymous' , 'syn' ) }
6759 </ tbody >
6860 </ Table >
6961
70-
7162 < p style = { { marginTop : '2em' } } >
7263 < strong > Total cases: { result . n_cases } </ strong >
7364 </ p >
7465 < p >
7566 < strong > Total controls: { result . n_controls } </ strong >
7667 </ p >
77-
7868 </ div >
7969)
8070
8171BipExGeneResult . propTypes = {
8272 result : PropTypes . shape ( {
8373 n_cases : PropTypes . number ,
8474 n_controls : PropTypes . number ,
85- ptv_case_count : PropTypes . number ,
86- ptv_control_count : PropTypes . number ,
87- ptv_fisher_gnom_non_psych_case_count : PropTypes . number ,
88- ptv_fisher_gnom_non_psych_control_count : PropTypes . number ,
89- ptv_fisher_gnom_non_psych_pval : PropTypes . number ,
90- // Odds ratio values may be a string 'inf' or a number
91- ptv_fisher_gnom_non_psych_OR : PropTypes . oneOfType ( [ PropTypes . number , PropTypes . string ] ) ,
92- damaging_missense_case_count : PropTypes . number ,
93- damaging_missense_control_count : PropTypes . number ,
94- damaging_missense_fisher_gnom_non_psych_case_count : PropTypes . number ,
95- damaging_missense_fisher_gnom_non_psych_control_count : PropTypes . number ,
96- damaging_missense_fisher_gnom_non_psych_pval : PropTypes . number ,
97- // Odds ratio values may be a string 'inf' or a number
98- damaging_missense_fisher_gnom_non_psych_OR : PropTypes . oneOfType ( [
99- PropTypes . number ,
100- PropTypes . string ,
101- ] ) ,
75+ ptv_case_carrier : PropTypes . number ,
76+ ptv_ctrl_carrier : PropTypes . number ,
77+ ptv_p_value : PropTypes . number ,
78+ ptv_odds_ratio : PropTypes . number ,
79+ mis_case_carrier : PropTypes . number ,
80+ mis_ctrl_carrier : PropTypes . number ,
81+ mis_p_value : PropTypes . number ,
82+ mis_odds_ratio : PropTypes . number ,
83+ ptv_mis_case_carrier : PropTypes . number ,
84+ ptv_mis_ctrl_carrier : PropTypes . number ,
85+ ptv_mis_p_value : PropTypes . number ,
86+ ptv_mis_odds_ratio : PropTypes . number ,
87+ syn_case_carrier : PropTypes . number ,
88+ syn_ctrl_carrier : PropTypes . number ,
89+ syn_p_value : PropTypes . number ,
90+ syn_odds_ratio : PropTypes . number ,
10291 } ) . isRequired ,
10392}
10493
@@ -148,30 +137,7 @@ const BipExGeneResults = ({ results }) => (
148137 />
149138 </ h2 >
150139
151- { /*
152- <Tabs
153- tabs={[
154- 'Bipolar Disorder',
155- 'Bipolar Disorder 1',
156- 'Bipolar Disorder 2',
157- 'Bipolar Disorder with Psychosis',
158- 'Bipolar Disorder without Psychosis',
159- 'Bipolar Disorder (including Schizoaffective)',
160- ].map((group) => ({
161- id: group,
162- label: group,
163- render: () =>
164- results[group] ? (
165- <BipExGeneResult result={results[group]} />
166- ) : (
167- <p>No result for {group} in this gene.</p>
168- ),
169- })) }
170- />
171- */ }
172-
173- < BipExGeneResult result = { results [ "meta" ] } />
174-
140+ < BipExGeneResult result = { results . meta } />
175141 </ >
176142)
177143
0 commit comments