|
a |
|
b/openomics_web/layouts/clinical_view.py |
|
|
1 |
import dash_core_components as dcc |
|
|
2 |
import dash_html_components as html |
|
|
3 |
import dash_table as dt |
|
|
4 |
import pandas as pd |
|
|
5 |
|
|
|
6 |
|
|
|
7 |
def ClinicalDataColumnSelect(columns): |
|
|
8 |
""" |
|
|
9 |
Args: |
|
|
10 |
columns: |
|
|
11 |
""" |
|
|
12 |
return html.Div([ |
|
|
13 |
html.Div(['Select the gene id/name column to index by:']), |
|
|
14 |
dcc.Dropdown( |
|
|
15 |
id='clinical-patient-col-name', |
|
|
16 |
options=[{'label': col, 'value': col} for col in columns], |
|
|
17 |
style={ |
|
|
18 |
'width': '100%', |
|
|
19 |
}, |
|
|
20 |
value=columns[0], |
|
|
21 |
), |
|
|
22 |
html.Div(['Select the column prefixes to import:']), |
|
|
23 |
dcc.Dropdown( |
|
|
24 |
id='clinical-data-columns-select', |
|
|
25 |
options=[{'label': col, 'value': col} for col in columns], |
|
|
26 |
style={ |
|
|
27 |
'width': '100%', |
|
|
28 |
}, |
|
|
29 |
value=columns, |
|
|
30 |
multi=True, |
|
|
31 |
) |
|
|
32 |
]) |
|
|
33 |
|
|
|
34 |
|
|
|
35 |
def ClinicalDataTable(df: pd.DataFrame): |
|
|
36 |
""" |
|
|
37 |
Args: |
|
|
38 |
df (pd.DataFrame): |
|
|
39 |
""" |
|
|
40 |
df.index.rename("id", inplace=True) |
|
|
41 |
print("df.reset_index()", df.reset_index().columns) |
|
|
42 |
|
|
|
43 |
return dt.DataTable( |
|
|
44 |
id='clinical-datatable', |
|
|
45 |
columns=[{'name': i, 'id': i, 'deletable': True} for i in df.columns], |
|
|
46 |
data=df.reset_index().to_dict('records'), |
|
|
47 |
style_as_list_view=True, |
|
|
48 |
# fixed_columns={'headers': True, 'data': 1}, |
|
|
49 |
style_cell={ |
|
|
50 |
'textAlign': 'left', |
|
|
51 |
'minWidth': '180px', 'width': '180px', 'maxWidth': '180px', |
|
|
52 |
}, |
|
|
53 |
style_data={ |
|
|
54 |
'whiteSpace': 'normal', |
|
|
55 |
'height': 'auto' |
|
|
56 |
}, |
|
|
57 |
style_data_conditional=[ |
|
|
58 |
{'if': {'row_index': 'odd'}, |
|
|
59 |
'backgroundColor': 'rgb(248, 248, 248)' |
|
|
60 |
}, |
|
|
61 |
], |
|
|
62 |
style_table={"maxHeight": '1200px', |
|
|
63 |
'width': '1000px', |
|
|
64 |
'marginTop': '5px', |
|
|
65 |
'marginBottom': '10px', |
|
|
66 |
'overflowX': 'scroll' |
|
|
67 |
}, |
|
|
68 |
style_header={ |
|
|
69 |
'backgroundColor': 'white', |
|
|
70 |
'fontWeight': 'bold' |
|
|
71 |
}, |
|
|
72 |
virtualization=True, |
|
|
73 |
filter_action="native", |
|
|
74 |
sort_action="native", |
|
|
75 |
sort_mode="multi", |
|
|
76 |
row_selectable="multi", |
|
|
77 |
selected_rows=[], |
|
|
78 |
page_action="native", |
|
|
79 |
page_current=0, |
|
|
80 |
page_size=10, |
|
|
81 |
) |