@@ -3,17 +3,17 @@ import { client } from "../../common/utils"
3
3
import { DataTable } from "@weng-lab/psychscreen-ui-components"
4
4
import React , { useState } from "react"
5
5
import { ApolloError , useQuery } from "@apollo/client"
6
- import { gql } from "@apollo/client"
7
6
import { ReadonlyURLSearchParams , useSearchParams , useRouter } from "next/navigation"
8
7
import Grid2 from "@mui/material/Unstable_Grid2/Grid2"
9
8
import { StyledTab } from "../../common/utils"
10
- import { CircularProgress , Collapse , List , ListItemButton , ListItemIcon , ListItemText , Stack , Tooltip , Typography } from "@mui/material"
9
+ import { CircularProgress , Collapse , List , ListItemButton , ListItemText , Stack , Tooltip , Typography } from "@mui/material"
11
10
import { Tabs } from "@mui/material"
12
11
import { ICRES_ACTIVE_EXPERIMENTS , ICRES_QUERY } from "./queries"
13
12
import { experimentInfo } from "../../common/consts"
14
13
import { getCellDisplayName } from "../celllineage/utils"
15
- import { ExpandLess , ExpandMore , InfoOutlined , StarBorder } from "@mui/icons-material"
16
- import { CellQueryValue } from "../celllineage/types"
14
+ import { ExpandLess , ExpandMore , InfoOutlined } from "@mui/icons-material"
15
+ import { ICRE_Data , Experiment_Data } from "./types"
16
+ import { ActiveCellTypesList , ActiveExperimentList } from "./utils"
17
17
18
18
export const IcresByRegion = ( props ) => {
19
19
const searchParams : ReadonlyURLSearchParams = useSearchParams ( ) !
@@ -23,9 +23,6 @@ export const IcresByRegion = (props) => {
23
23
setValue ( newValue )
24
24
}
25
25
26
- type ICRE_Data = { accession : string , rdhs : string , celltypes : CellQueryValue [ ] , coordinates : { chromosome : string , start : number , end : number , } }
27
- type Experiment_Data = { grouping : string , description : string , name : string , start : number , value : number }
28
-
29
26
const { loading : loading_icres , data : data_icres , error : error_icres } : { loading : boolean , data : { iCREQuery : ICRE_Data [ ] } , error ?: ApolloError } = useQuery ( ICRES_QUERY , {
30
27
variables : {
31
28
coordinates : {
@@ -125,42 +122,16 @@ export const IcresByRegion = (props) => {
125
122
< Typography variant = "body2" >
126
123
Active Cell Types
127
124
</ Typography >
128
- < Tooltip title = "Activity in cell types determined by aggregated ATAC-seq signal z-score of >1.64 (95th percentile)" >
125
+ < Tooltip arrow title = "Activity in cell types determined by aggregated ATAC-seq signal z-score of >1.64 (95th percentile)" >
129
126
< InfoOutlined />
130
127
</ Tooltip >
131
128
</ Stack >
132
129
)
133
130
} ,
134
131
value : ( row ) => row . celltypes . map ( x => getCellDisplayName ( x ) ) . length ,
135
132
FunctionalRender : ( row ) => {
136
- const [ open , setOpen ] = useState ( false )
137
-
138
- const celltypes = [ ... new Set ( row . celltypes . map ( x => getCellDisplayName ( x , true ) ) ) ] . sort ( )
139
-
140
- const handleClick = ( event : React . MouseEvent < HTMLDivElement , MouseEvent > ) => {
141
- event . stopPropagation ( )
142
- setOpen ( ! open ) ;
143
- } ;
144
-
145
133
return (
146
- celltypes . length > 0 ?
147
- < List >
148
- < ListItemButton onClick = { ( event : React . MouseEvent < HTMLDivElement , MouseEvent > ) => handleClick ( event ) } >
149
- < ListItemText primary = { "Active in " + celltypes . length + " immune cell types" } />
150
- { open ? < ExpandLess /> : < ExpandMore /> }
151
- </ ListItemButton >
152
- < Collapse in = { open } timeout = "auto" unmountOnExit >
153
- < List sx = { { pl : 2 } } component = "div" disablePadding >
154
- {
155
- celltypes . map ( ( cell : string ) =>
156
- < ListItemText key = { cell } primary = { "\u2022 " + cell } />
157
- )
158
- }
159
- </ List >
160
- </ Collapse >
161
- </ List >
162
- :
163
- < Typography pl = { 2 } > Not Active</ Typography >
134
+ < ActiveCellTypesList celltypes = { row . celltypes } />
164
135
)
165
136
}
166
137
} ,
@@ -172,73 +143,17 @@ export const IcresByRegion = (props) => {
172
143
< Typography variant = "body2" >
173
144
Active Experiments
174
145
</ Typography >
175
- < Tooltip title = "Activity in individual experiments determined by an ATAC-seq signal z-score of >1.64 (95th percentile)" >
146
+ < Tooltip arrow title = "Activity in individual experiments determined by an ATAC-seq signal z-score of >1.64 (95th percentile)" >
176
147
< InfoOutlined />
177
148
</ Tooltip >
178
149
</ Stack >
179
150
)
180
151
} ,
181
152
value : ( row : ICRE_Row ) => row ?. activeExps ? Object . values ( row . activeExps ) . flat ( ) . length : 0 ,
182
153
FunctionalRender : ( row : ICRE_Row ) => {
183
- const [ open , setOpen ] = useState ( false )
184
-
185
- const handleClick = ( event : React . MouseEvent < HTMLDivElement , MouseEvent > ) => {
186
- event . stopPropagation ( )
187
- setOpen ( ! open ) ;
188
- } ;
189
-
190
-
191
- type GroupListProps = { exps : Experiment_Data [ ] , grouping : string }
192
-
193
- const GroupList : React . FC < GroupListProps > = ( props : GroupListProps ) => {
194
- const [ openGroup , setOpenGroup ] = useState ( false )
195
-
196
- const handleClick = ( event : React . MouseEvent < HTMLDivElement , MouseEvent > ) => {
197
- event . stopPropagation ( )
198
- setOpenGroup ( ! openGroup ) ;
199
- } ;
200
-
201
- return (
202
- < List disablePadding >
203
- < ListItemButton onClick = { ( event : React . MouseEvent < HTMLDivElement , MouseEvent > ) => handleClick ( event ) } >
204
- < ListItemText primary = { `${ props . grouping } (${ props . exps . length } )` } />
205
- { openGroup ? < ExpandLess /> : < ExpandMore /> }
206
- </ ListItemButton >
207
- < Collapse in = { openGroup } timeout = "auto" unmountOnExit >
208
- < List sx = { { pl : 2 } } component = "div" disablePadding >
209
- {
210
- props . exps . sort ( ( a , b ) => experimentInfo [ a . name ] . order - experimentInfo [ b . name ] . order ) . map ( ( exp ) =>
211
- < Tooltip key = { exp . name } title = { exp . description } >
212
- < Stack direction = { "row" } alignItems = { "center" } >
213
- < ListItemText primary = { "\u2022 " + exp . name } />
214
- < InfoOutlined fontSize = "small" />
215
- </ Stack >
216
- </ Tooltip >
217
- )
218
- }
219
- </ List >
220
- </ Collapse >
221
- </ List >
222
- )
223
- }
224
-
225
154
return (
226
155
row ?. activeExps ?
227
- < List disablePadding >
228
- < ListItemButton onClick = { ( event : React . MouseEvent < HTMLDivElement , MouseEvent > ) => handleClick ( event ) } >
229
- < ListItemText primary = { "Active in " + Object . values ( row . activeExps ) . flat ( ) . length + " experiments" } />
230
- { open ? < ExpandLess /> : < ExpandMore /> }
231
- </ ListItemButton >
232
- < Collapse in = { open } timeout = "auto" unmountOnExit >
233
- < List sx = { { pl : 2 } } component = "div" disablePadding >
234
- {
235
- Object . entries ( row . activeExps ) . map ( ( [ grouping , exps ] : [ string , Experiment_Data [ ] ] ) =>
236
- < GroupList key = { grouping } exps = { exps } grouping = { grouping } />
237
- )
238
- }
239
- </ List >
240
- </ Collapse >
241
- </ List >
156
+ < ActiveExperimentList activeExps = { row . activeExps } />
242
157
:
243
158
< CircularProgress />
244
159
)
0 commit comments