Spaces:
Sleeping
Sleeping
Update dash_plotly_QC_scRNA.py
Browse files- dash_plotly_QC_scRNA.py +422 -422
dash_plotly_QC_scRNA.py
CHANGED
|
@@ -1,422 +1,422 @@
|
|
| 1 |
-
# Dash app to visualize scRNA-seq data quality control metrics from scanpy objects
|
| 2 |
-
# Shoutout to Coding-with-Adam for the initial template of the project:
|
| 3 |
-
# https://github.com/Coding-with-Adam/Dash-by-Plotly/blob/master/Dash%20Components/Graph/dash-graph.py
|
| 4 |
-
|
| 5 |
-
import dash
|
| 6 |
-
from dash import dcc, html, Output, Input
|
| 7 |
-
import plotly.express as px
|
| 8 |
-
import dash_callback_chain
|
| 9 |
-
import yaml
|
| 10 |
-
import polars as pl
|
| 11 |
-
pl.enable_string_cache(False)
|
| 12 |
-
|
| 13 |
-
# Set custom resolution for plots:
|
| 14 |
-
config_fig = {
|
| 15 |
-
'toImageButtonOptions': {
|
| 16 |
-
'format': 'svg',
|
| 17 |
-
'filename': 'custom_image',
|
| 18 |
-
'height': 600,
|
| 19 |
-
'width': 700,
|
| 20 |
-
'scale': 1,
|
| 21 |
-
}
|
| 22 |
-
}
|
| 23 |
-
|
| 24 |
-
config_path = "./
|
| 25 |
-
|
| 26 |
-
# Add the read-in data from the yaml file
|
| 27 |
-
def read_config(filename):
|
| 28 |
-
with open(filename, 'r') as yaml_file:
|
| 29 |
-
config = yaml.safe_load(yaml_file)
|
| 30 |
-
return config
|
| 31 |
-
|
| 32 |
-
config = read_config(config_path)
|
| 33 |
-
path_parquet = config.get("path_parquet")
|
| 34 |
-
conditions = config.get("conditions")
|
| 35 |
-
col_features = config.get("col_features")
|
| 36 |
-
col_counts = config.get("col_counts")
|
| 37 |
-
col_mt = config.get("col_mt")
|
| 38 |
-
|
| 39 |
-
# Import the data from one .parquet file
|
| 40 |
-
df = pl.read_parquet(path_parquet)
|
| 41 |
-
#df = df.rename({"__index_level_0__": "Unnamed: 0"})
|
| 42 |
-
|
| 43 |
-
# Setup the app
|
| 44 |
-
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
|
| 45 |
-
app = dash.Dash(__name__, external_stylesheets=external_stylesheets, requests_pathname_prefix='/dashboard1/')
|
| 46 |
-
|
| 47 |
-
min_value = df[col_features].min()
|
| 48 |
-
max_value = df[col_features].max()
|
| 49 |
-
|
| 50 |
-
min_value_2 = df[col_counts].min()
|
| 51 |
-
min_value_2 = round(min_value_2)
|
| 52 |
-
max_value_2 = df[col_counts].max()
|
| 53 |
-
max_value_2 = round(max_value_2)
|
| 54 |
-
|
| 55 |
-
min_value_3 = df[col_mt].min()
|
| 56 |
-
min_value_3 = round(min_value_3, 1)
|
| 57 |
-
max_value_3 = df[col_mt].max()
|
| 58 |
-
max_value_3 = round(max_value_3, 1)
|
| 59 |
-
|
| 60 |
-
# Loads in the conditions specified in the yaml file
|
| 61 |
-
|
| 62 |
-
# Note: Future version perhaps all values from a column in the dataframe of the parquet file
|
| 63 |
-
# Note 2: This could also be a tsv of the categories and own specified colors
|
| 64 |
-
|
| 65 |
-
# Create the first tab content
|
| 66 |
-
# Add Sliders for three QC params: N genes by counts, total amount of reads and pct MT reads
|
| 67 |
-
|
| 68 |
-
tab1_content = html.Div([
|
| 69 |
-
dcc.Dropdown(id='dpdn2', value=conditions, multi=True,
|
| 70 |
-
options=conditions),
|
| 71 |
-
html.Label("N Genes by Counts"),
|
| 72 |
-
dcc.RangeSlider(
|
| 73 |
-
id='range-slider-1',
|
| 74 |
-
step=250,
|
| 75 |
-
value=[min_value, max_value],
|
| 76 |
-
marks={i: str(i) for i in range(min_value, max_value + 1, 250)},
|
| 77 |
-
),
|
| 78 |
-
dcc.Input(id='min-slider-1', type='number', value=min_value, debounce=True),
|
| 79 |
-
dcc.Input(id='max-slider-1', type='number', value=max_value, debounce=True),
|
| 80 |
-
html.Label("Total Counts"),
|
| 81 |
-
dcc.RangeSlider(
|
| 82 |
-
id='range-slider-2',
|
| 83 |
-
step=7500,
|
| 84 |
-
value=[min_value_2, max_value_2],
|
| 85 |
-
marks={i: str(i) for i in range(min_value_2, max_value_2 + 1, 7500)},
|
| 86 |
-
),
|
| 87 |
-
dcc.Input(id='min-slider-2', type='number', value=min_value_2, debounce=True),
|
| 88 |
-
dcc.Input(id='max-slider-2', type='number', value=max_value_2, debounce=True),
|
| 89 |
-
html.Label("Percent Mitochondrial Genes"),
|
| 90 |
-
dcc.RangeSlider(
|
| 91 |
-
id='range-slider-3',
|
| 92 |
-
step=0.1,
|
| 93 |
-
min=0,
|
| 94 |
-
max=1,
|
| 95 |
-
value=[min_value_3, max_value_3],
|
| 96 |
-
),
|
| 97 |
-
dcc.Input(id='min-slider-3', type='number', value=min_value_3, debounce=True),
|
| 98 |
-
dcc.Input(id='max-slider-3', type='number', value=max_value_3, debounce=True),
|
| 99 |
-
html.Div([
|
| 100 |
-
dcc.Graph(id='pie-graph', figure={}, className='four columns',config=config_fig),
|
| 101 |
-
dcc.Graph(id='my-graph', figure={}, clickData=None, hoverData=None,
|
| 102 |
-
className='four columns',config=config_fig
|
| 103 |
-
),
|
| 104 |
-
dcc.Graph(id='scatter-plot', figure={}, className='four columns',config=config_fig)
|
| 105 |
-
]),
|
| 106 |
-
html.Div([
|
| 107 |
-
dcc.Graph(id='scatter-plot-2', figure={}, className='four columns',config=config_fig)
|
| 108 |
-
]),
|
| 109 |
-
html.Div([
|
| 110 |
-
dcc.Graph(id='scatter-plot-3', figure={}, className='four columns',config=config_fig)
|
| 111 |
-
]),
|
| 112 |
-
html.Div([
|
| 113 |
-
dcc.Graph(id='scatter-plot-4', figure={}, className='four columns',config=config_fig)
|
| 114 |
-
]),
|
| 115 |
-
])
|
| 116 |
-
|
| 117 |
-
# Create the second tab content with scatter-plot-5 and scatter-plot-6
|
| 118 |
-
tab2_content = html.Div([
|
| 119 |
-
html.Div([
|
| 120 |
-
html.Label("S-cycle genes"),
|
| 121 |
-
dcc.Dropdown(id='dpdn3', value="Cdc45", multi=False,
|
| 122 |
-
options=[
|
| 123 |
-
"Cdc45",
|
| 124 |
-
"Uhrf1",
|
| 125 |
-
"Mcm2",
|
| 126 |
-
"Slbp",
|
| 127 |
-
"Mcm5",
|
| 128 |
-
"Pola1",
|
| 129 |
-
"Gmnn",
|
| 130 |
-
"Cdc6",
|
| 131 |
-
"Rrm2",
|
| 132 |
-
"Atad2",
|
| 133 |
-
"Dscc1",
|
| 134 |
-
"Mcm4",
|
| 135 |
-
"Chaf1b",
|
| 136 |
-
"Rfc2",
|
| 137 |
-
"Msh2",
|
| 138 |
-
"Fen1",
|
| 139 |
-
"Hells",
|
| 140 |
-
"Prim1",
|
| 141 |
-
"Tyms",
|
| 142 |
-
"Mcm6",
|
| 143 |
-
"Wdr76",
|
| 144 |
-
"Rad51",
|
| 145 |
-
"Pcna",
|
| 146 |
-
"Ccne2",
|
| 147 |
-
"Casp8ap2",
|
| 148 |
-
"Usp1",
|
| 149 |
-
"Nasp",
|
| 150 |
-
"Rpa2",
|
| 151 |
-
"Ung",
|
| 152 |
-
"Rad51ap1",
|
| 153 |
-
"Blm",
|
| 154 |
-
"Pold3",
|
| 155 |
-
"Rrm1",
|
| 156 |
-
"Cenpu",
|
| 157 |
-
"Gins2",
|
| 158 |
-
"Tipin",
|
| 159 |
-
"Brip1",
|
| 160 |
-
"Dtl",
|
| 161 |
-
"Exo1",
|
| 162 |
-
"Ubr7",
|
| 163 |
-
"Clspn",
|
| 164 |
-
"E2f8",
|
| 165 |
-
"Cdca7"
|
| 166 |
-
]),
|
| 167 |
-
html.Label("G2M-cycle genes"),
|
| 168 |
-
dcc.Dropdown(id='dpdn4', value="Top2a", multi=False,
|
| 169 |
-
options=[
|
| 170 |
-
"Ube2c",
|
| 171 |
-
"Lbr",
|
| 172 |
-
"Ctcf",
|
| 173 |
-
"Cdc20",
|
| 174 |
-
"Cbx5",
|
| 175 |
-
"Kif11",
|
| 176 |
-
"Anp32e",
|
| 177 |
-
"Birc5",
|
| 178 |
-
"Cdk1",
|
| 179 |
-
"Tmpo",
|
| 180 |
-
"Hmmr",
|
| 181 |
-
"Pimreg",
|
| 182 |
-
"Aurkb",
|
| 183 |
-
"Top2a",
|
| 184 |
-
"Gtse1",
|
| 185 |
-
"Rangap1",
|
| 186 |
-
"Cdca3",
|
| 187 |
-
"Ndc80",
|
| 188 |
-
"Kif20b",
|
| 189 |
-
"Cenpf",
|
| 190 |
-
"Nek2",
|
| 191 |
-
"Nuf2",
|
| 192 |
-
"Nusap1",
|
| 193 |
-
"Bub1",
|
| 194 |
-
"Tpx2",
|
| 195 |
-
"Aurka",
|
| 196 |
-
"Ect2",
|
| 197 |
-
"Cks1b",
|
| 198 |
-
"Kif2c",
|
| 199 |
-
"Cdca8",
|
| 200 |
-
"Cenpa",
|
| 201 |
-
"Mki67",
|
| 202 |
-
"Ccnb2",
|
| 203 |
-
"Kif23",
|
| 204 |
-
"Smc4",
|
| 205 |
-
"G2e3",
|
| 206 |
-
"Tubb4b",
|
| 207 |
-
"Anln",
|
| 208 |
-
"Tacc3",
|
| 209 |
-
"Dlgap5",
|
| 210 |
-
"Ckap2",
|
| 211 |
-
"Ncapd2",
|
| 212 |
-
"Ttk",
|
| 213 |
-
"Ckap5",
|
| 214 |
-
"Cdc25c",
|
| 215 |
-
"Hjurp",
|
| 216 |
-
"Cenpe",
|
| 217 |
-
"Ckap2l",
|
| 218 |
-
"Cdca2",
|
| 219 |
-
"Hmgb2",
|
| 220 |
-
"Cks2",
|
| 221 |
-
"Psrc1",
|
| 222 |
-
"Gas2l3"
|
| 223 |
-
]),
|
| 224 |
-
]),
|
| 225 |
-
html.Div([
|
| 226 |
-
dcc.Graph(id='scatter-plot-5', figure={}, className='three columns',config=config_fig)
|
| 227 |
-
]),
|
| 228 |
-
html.Div([
|
| 229 |
-
dcc.Graph(id='scatter-plot-6', figure={}, className='three columns',config=config_fig)
|
| 230 |
-
]),
|
| 231 |
-
html.Div([
|
| 232 |
-
dcc.Graph(id='scatter-plot-7', figure={}, className='three columns',config=config_fig)
|
| 233 |
-
]),
|
| 234 |
-
html.Div([
|
| 235 |
-
dcc.Graph(id='scatter-plot-8', figure={}, className='three columns',config=config_fig)
|
| 236 |
-
]),
|
| 237 |
-
])
|
| 238 |
-
|
| 239 |
-
# Create the second tab content with scatter-plot-5 and scatter-plot-6
|
| 240 |
-
tab3_content = html.Div([
|
| 241 |
-
html.Div([
|
| 242 |
-
html.Label("UMAP condition 1"),
|
| 243 |
-
dcc.Dropdown(id='dpdn5', value="total_counts", multi=False,
|
| 244 |
-
options=df.columns),
|
| 245 |
-
html.Label("UMAP condition 2"),
|
| 246 |
-
dcc.Dropdown(id='dpdn6', value="n_genes_by_counts", multi=False,
|
| 247 |
-
options=df.columns),
|
| 248 |
-
]),
|
| 249 |
-
html.Div([
|
| 250 |
-
dcc.Graph(id='scatter-plot-9', figure={}, className='four columns',config=config_fig)
|
| 251 |
-
]),
|
| 252 |
-
html.Div([
|
| 253 |
-
dcc.Graph(id='scatter-plot-10', figure={}, className='four columns',config=config_fig)
|
| 254 |
-
]),
|
| 255 |
-
html.Div([
|
| 256 |
-
dcc.Graph(id='scatter-plot-11', figure={}, className='four columns',config=config_fig)
|
| 257 |
-
]),
|
| 258 |
-
html.Div([
|
| 259 |
-
dcc.Graph(id='my-graph2', figure={}, clickData=None, hoverData=None,
|
| 260 |
-
className='four columns',config=config_fig
|
| 261 |
-
)
|
| 262 |
-
]),
|
| 263 |
-
])
|
| 264 |
-
|
| 265 |
-
# Define the tabs layout
|
| 266 |
-
app.layout = html.Div([
|
| 267 |
-
dcc.Tabs(id='tabs', style= {'width': 400,
|
| 268 |
-
'font-size': '100%',
|
| 269 |
-
'height': 50}, value='tab1',children=[
|
| 270 |
-
dcc.Tab(label='QC', value='tab1', children=tab1_content),
|
| 271 |
-
dcc.Tab(label='Cell cycle', value='tab2', children=tab2_content),
|
| 272 |
-
dcc.Tab(label='Custom', value='tab3', children=tab3_content),
|
| 273 |
-
]),
|
| 274 |
-
])
|
| 275 |
-
|
| 276 |
-
# Define the circular callback
|
| 277 |
-
@app.callback(
|
| 278 |
-
Output("min-slider-1", "value"),
|
| 279 |
-
Output("max-slider-1", "value"),
|
| 280 |
-
Output("min-slider-2", "value"),
|
| 281 |
-
Output("max-slider-2", "value"),
|
| 282 |
-
Output("min-slider-3", "value"),
|
| 283 |
-
Output("max-slider-3", "value"),
|
| 284 |
-
Input("min-slider-1", "value"),
|
| 285 |
-
Input("max-slider-1", "value"),
|
| 286 |
-
Input("min-slider-2", "value"),
|
| 287 |
-
Input("max-slider-2", "value"),
|
| 288 |
-
Input("min-slider-3", "value"),
|
| 289 |
-
Input("max-slider-3", "value"),
|
| 290 |
-
)
|
| 291 |
-
def circular_callback(min_1, max_1, min_2, max_2, min_3, max_3):
|
| 292 |
-
return min_1, max_1, min_2, max_2, min_3, max_3
|
| 293 |
-
|
| 294 |
-
@app.callback(
|
| 295 |
-
Output('range-slider-1', 'value'),
|
| 296 |
-
Output('range-slider-2', 'value'),
|
| 297 |
-
Output('range-slider-3', 'value'),
|
| 298 |
-
Input('min-slider-1', 'value'),
|
| 299 |
-
Input('max-slider-1', 'value'),
|
| 300 |
-
Input('min-slider-2', 'value'),
|
| 301 |
-
Input('max-slider-2', 'value'),
|
| 302 |
-
Input('min-slider-3', 'value'),
|
| 303 |
-
Input('max-slider-3', 'value'),
|
| 304 |
-
)
|
| 305 |
-
def update_slider_values(min_1, max_1, min_2, max_2, min_3, max_3):
|
| 306 |
-
return [min_1, max_1], [min_2, max_2], [min_3, max_3]
|
| 307 |
-
|
| 308 |
-
@app.callback(
|
| 309 |
-
Output(component_id='my-graph', component_property='figure'),
|
| 310 |
-
Output(component_id='pie-graph', component_property='figure'),
|
| 311 |
-
Output(component_id='scatter-plot', component_property='figure'),
|
| 312 |
-
Output(component_id='scatter-plot-2', component_property='figure'),
|
| 313 |
-
Output(component_id='scatter-plot-3', component_property='figure'),
|
| 314 |
-
Output(component_id='scatter-plot-4', component_property='figure'), # Add this new scatter plot
|
| 315 |
-
Output(component_id='scatter-plot-5', component_property='figure'),
|
| 316 |
-
Output(component_id='scatter-plot-6', component_property='figure'),
|
| 317 |
-
Output(component_id='scatter-plot-7', component_property='figure'),
|
| 318 |
-
Output(component_id='scatter-plot-8', component_property='figure'),
|
| 319 |
-
Output(component_id='scatter-plot-9', component_property='figure'),
|
| 320 |
-
Output(component_id='scatter-plot-10', component_property='figure'),
|
| 321 |
-
Output(component_id='scatter-plot-11', component_property='figure'),
|
| 322 |
-
Output(component_id='my-graph2', component_property='figure'),
|
| 323 |
-
Input(component_id='dpdn2', component_property='value'),
|
| 324 |
-
Input(component_id='dpdn3', component_property='value'),
|
| 325 |
-
Input(component_id='dpdn4', component_property='value'),
|
| 326 |
-
Input(component_id='dpdn5', component_property='value'),
|
| 327 |
-
Input(component_id='dpdn6', component_property='value'),
|
| 328 |
-
Input(component_id='range-slider-1', component_property='value'),
|
| 329 |
-
Input(component_id='range-slider-2', component_property='value'),
|
| 330 |
-
Input(component_id='range-slider-3', component_property='value')
|
| 331 |
-
)
|
| 332 |
-
|
| 333 |
-
def update_graph_and_pie_chart(batch_chosen, s_chosen, g2m_chosen, condition1_chosen, condition2_chosen, range_value_1, range_value_2, range_value_3):
|
| 334 |
-
dff = df.filter(
|
| 335 |
-
(pl.col('batch').cast(str).is_in(batch_chosen)) &
|
| 336 |
-
(pl.col(col_features) >= range_value_1[0]) &
|
| 337 |
-
(pl.col(col_features) <= range_value_1[1]) &
|
| 338 |
-
(pl.col(col_counts) >= range_value_2[0]) &
|
| 339 |
-
(pl.col(col_counts) <= range_value_2[1]) &
|
| 340 |
-
(pl.col(col_mt) >= range_value_3[0]) &
|
| 341 |
-
(pl.col(col_mt) <= range_value_3[1])
|
| 342 |
-
)
|
| 343 |
-
|
| 344 |
-
#Drop categories that are not in the filtered data
|
| 345 |
-
dff = dff.with_columns(dff['batch'].cast(str))
|
| 346 |
-
dff = dff.with_columns(dff['batch'].cast(pl.Categorical))
|
| 347 |
-
|
| 348 |
-
# Plot figures
|
| 349 |
-
fig_violin = px.violin(data_frame=dff, x='batch', y=col_features, box=True, points="all",
|
| 350 |
-
color='batch', hover_name='batch',template="seaborn")
|
| 351 |
-
|
| 352 |
-
# Calculate the percentage of each category (normalized_count) for pie chart
|
| 353 |
-
category_counts = dff.group_by("batch").agg(pl.col("batch").count().alias("count"))
|
| 354 |
-
total_count = len(dff)
|
| 355 |
-
category_counts = category_counts.with_columns((pl.col("count") / total_count * 100).alias("normalized_count"))
|
| 356 |
-
|
| 357 |
-
# Display the result
|
| 358 |
-
labels = category_counts["batch"].to_list()
|
| 359 |
-
values = category_counts["normalized_count"].to_list()
|
| 360 |
-
|
| 361 |
-
total_cells = total_count # Calculate total number of cells
|
| 362 |
-
pie_title = f'Percentage of Total Cells: {total_cells}' # Include total cells in the title
|
| 363 |
-
|
| 364 |
-
fig_pie = px.pie(names=labels, values=values, title=pie_title,template="seaborn")
|
| 365 |
-
|
| 366 |
-
# Create the scatter plots
|
| 367 |
-
fig_scatter = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color='batch',
|
| 368 |
-
labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
|
| 369 |
-
hover_name='batch',template="seaborn")
|
| 370 |
-
|
| 371 |
-
fig_scatter_2 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color=col_mt,
|
| 372 |
-
labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
|
| 373 |
-
hover_name='batch',template="seaborn")
|
| 374 |
-
|
| 375 |
-
fig_scatter_3 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color=col_features,
|
| 376 |
-
labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
|
| 377 |
-
hover_name='batch',template="seaborn")
|
| 378 |
-
|
| 379 |
-
|
| 380 |
-
fig_scatter_4 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color=col_counts,
|
| 381 |
-
labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
|
| 382 |
-
hover_name='batch',template="seaborn")
|
| 383 |
-
|
| 384 |
-
fig_scatter_5 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color=s_chosen,
|
| 385 |
-
labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
|
| 386 |
-
hover_name='batch', title="S-cycle gene:",template="seaborn")
|
| 387 |
-
|
| 388 |
-
fig_scatter_6 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color=g2m_chosen,
|
| 389 |
-
labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
|
| 390 |
-
hover_name='batch', title="G2M-cycle gene:",template="seaborn")
|
| 391 |
-
|
| 392 |
-
fig_scatter_7 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color="S_score",
|
| 393 |
-
labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
|
| 394 |
-
hover_name='batch', title="S score:",template="seaborn")
|
| 395 |
-
|
| 396 |
-
fig_scatter_8 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color="G2M_score",
|
| 397 |
-
labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
|
| 398 |
-
hover_name='batch', title="G2M score:",template="seaborn")
|
| 399 |
-
|
| 400 |
-
fig_scatter_9 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color=condition1_chosen,
|
| 401 |
-
labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
|
| 402 |
-
hover_name='batch',template="seaborn")
|
| 403 |
-
|
| 404 |
-
fig_scatter_10 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color=condition2_chosen,
|
| 405 |
-
labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
|
| 406 |
-
hover_name='batch',template="seaborn")
|
| 407 |
-
|
| 408 |
-
fig_scatter_11 = px.scatter(data_frame=dff, x=condition1_chosen, y=condition2_chosen, color='batch',
|
| 409 |
-
#labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
|
| 410 |
-
hover_name='batch',template="seaborn")
|
| 411 |
-
|
| 412 |
-
fig_violin2 = px.violin(data_frame=dff, x=condition1_chosen, y=condition2_chosen, box=True, points="all",
|
| 413 |
-
color=condition1_chosen, hover_name=condition1_chosen,template="seaborn")
|
| 414 |
-
|
| 415 |
-
|
| 416 |
-
return fig_violin, fig_pie, fig_scatter, fig_scatter_2, fig_scatter_3, fig_scatter_4, fig_scatter_5, fig_scatter_6, fig_scatter_7, fig_scatter_8, fig_scatter_9, fig_scatter_10, fig_scatter_11, fig_violin2
|
| 417 |
-
|
| 418 |
-
# Set http://localhost:5000/ in web browser
|
| 419 |
-
# Now create your regular FASTAPI application
|
| 420 |
-
|
| 421 |
-
if __name__ == '__main__':
|
| 422 |
-
app.run_server(debug=True, use_reloader=False) #host='0.0.0.0', #, port=5000
|
|
|
|
| 1 |
+
# Dash app to visualize scRNA-seq data quality control metrics from scanpy objects
|
| 2 |
+
# Shoutout to Coding-with-Adam for the initial template of the project:
|
| 3 |
+
# https://github.com/Coding-with-Adam/Dash-by-Plotly/blob/master/Dash%20Components/Graph/dash-graph.py
|
| 4 |
+
|
| 5 |
+
import dash
|
| 6 |
+
from dash import dcc, html, Output, Input
|
| 7 |
+
import plotly.express as px
|
| 8 |
+
import dash_callback_chain
|
| 9 |
+
import yaml
|
| 10 |
+
import polars as pl
|
| 11 |
+
pl.enable_string_cache(False)
|
| 12 |
+
|
| 13 |
+
# Set custom resolution for plots:
|
| 14 |
+
config_fig = {
|
| 15 |
+
'toImageButtonOptions': {
|
| 16 |
+
'format': 'svg',
|
| 17 |
+
'filename': 'custom_image',
|
| 18 |
+
'height': 600,
|
| 19 |
+
'width': 700,
|
| 20 |
+
'scale': 1,
|
| 21 |
+
}
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
config_path = "./azure/config.yaml"
|
| 25 |
+
|
| 26 |
+
# Add the read-in data from the yaml file
|
| 27 |
+
def read_config(filename):
|
| 28 |
+
with open(filename, 'r') as yaml_file:
|
| 29 |
+
config = yaml.safe_load(yaml_file)
|
| 30 |
+
return config
|
| 31 |
+
|
| 32 |
+
config = read_config(config_path)
|
| 33 |
+
path_parquet = config.get("path_parquet")
|
| 34 |
+
conditions = config.get("conditions")
|
| 35 |
+
col_features = config.get("col_features")
|
| 36 |
+
col_counts = config.get("col_counts")
|
| 37 |
+
col_mt = config.get("col_mt")
|
| 38 |
+
|
| 39 |
+
# Import the data from one .parquet file
|
| 40 |
+
df = pl.read_parquet(path_parquet)
|
| 41 |
+
#df = df.rename({"__index_level_0__": "Unnamed: 0"})
|
| 42 |
+
|
| 43 |
+
# Setup the app
|
| 44 |
+
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
|
| 45 |
+
app = dash.Dash(__name__, external_stylesheets=external_stylesheets, requests_pathname_prefix='/dashboard1/')
|
| 46 |
+
|
| 47 |
+
min_value = df[col_features].min()
|
| 48 |
+
max_value = df[col_features].max()
|
| 49 |
+
|
| 50 |
+
min_value_2 = df[col_counts].min()
|
| 51 |
+
min_value_2 = round(min_value_2)
|
| 52 |
+
max_value_2 = df[col_counts].max()
|
| 53 |
+
max_value_2 = round(max_value_2)
|
| 54 |
+
|
| 55 |
+
min_value_3 = df[col_mt].min()
|
| 56 |
+
min_value_3 = round(min_value_3, 1)
|
| 57 |
+
max_value_3 = df[col_mt].max()
|
| 58 |
+
max_value_3 = round(max_value_3, 1)
|
| 59 |
+
|
| 60 |
+
# Loads in the conditions specified in the yaml file
|
| 61 |
+
|
| 62 |
+
# Note: Future version perhaps all values from a column in the dataframe of the parquet file
|
| 63 |
+
# Note 2: This could also be a tsv of the categories and own specified colors
|
| 64 |
+
|
| 65 |
+
# Create the first tab content
|
| 66 |
+
# Add Sliders for three QC params: N genes by counts, total amount of reads and pct MT reads
|
| 67 |
+
|
| 68 |
+
tab1_content = html.Div([
|
| 69 |
+
dcc.Dropdown(id='dpdn2', value=conditions, multi=True,
|
| 70 |
+
options=conditions),
|
| 71 |
+
html.Label("N Genes by Counts"),
|
| 72 |
+
dcc.RangeSlider(
|
| 73 |
+
id='range-slider-1',
|
| 74 |
+
step=250,
|
| 75 |
+
value=[min_value, max_value],
|
| 76 |
+
marks={i: str(i) for i in range(min_value, max_value + 1, 250)},
|
| 77 |
+
),
|
| 78 |
+
dcc.Input(id='min-slider-1', type='number', value=min_value, debounce=True),
|
| 79 |
+
dcc.Input(id='max-slider-1', type='number', value=max_value, debounce=True),
|
| 80 |
+
html.Label("Total Counts"),
|
| 81 |
+
dcc.RangeSlider(
|
| 82 |
+
id='range-slider-2',
|
| 83 |
+
step=7500,
|
| 84 |
+
value=[min_value_2, max_value_2],
|
| 85 |
+
marks={i: str(i) for i in range(min_value_2, max_value_2 + 1, 7500)},
|
| 86 |
+
),
|
| 87 |
+
dcc.Input(id='min-slider-2', type='number', value=min_value_2, debounce=True),
|
| 88 |
+
dcc.Input(id='max-slider-2', type='number', value=max_value_2, debounce=True),
|
| 89 |
+
html.Label("Percent Mitochondrial Genes"),
|
| 90 |
+
dcc.RangeSlider(
|
| 91 |
+
id='range-slider-3',
|
| 92 |
+
step=0.1,
|
| 93 |
+
min=0,
|
| 94 |
+
max=1,
|
| 95 |
+
value=[min_value_3, max_value_3],
|
| 96 |
+
),
|
| 97 |
+
dcc.Input(id='min-slider-3', type='number', value=min_value_3, debounce=True),
|
| 98 |
+
dcc.Input(id='max-slider-3', type='number', value=max_value_3, debounce=True),
|
| 99 |
+
html.Div([
|
| 100 |
+
dcc.Graph(id='pie-graph', figure={}, className='four columns',config=config_fig),
|
| 101 |
+
dcc.Graph(id='my-graph', figure={}, clickData=None, hoverData=None,
|
| 102 |
+
className='four columns',config=config_fig
|
| 103 |
+
),
|
| 104 |
+
dcc.Graph(id='scatter-plot', figure={}, className='four columns',config=config_fig)
|
| 105 |
+
]),
|
| 106 |
+
html.Div([
|
| 107 |
+
dcc.Graph(id='scatter-plot-2', figure={}, className='four columns',config=config_fig)
|
| 108 |
+
]),
|
| 109 |
+
html.Div([
|
| 110 |
+
dcc.Graph(id='scatter-plot-3', figure={}, className='four columns',config=config_fig)
|
| 111 |
+
]),
|
| 112 |
+
html.Div([
|
| 113 |
+
dcc.Graph(id='scatter-plot-4', figure={}, className='four columns',config=config_fig)
|
| 114 |
+
]),
|
| 115 |
+
])
|
| 116 |
+
|
| 117 |
+
# Create the second tab content with scatter-plot-5 and scatter-plot-6
|
| 118 |
+
tab2_content = html.Div([
|
| 119 |
+
html.Div([
|
| 120 |
+
html.Label("S-cycle genes"),
|
| 121 |
+
dcc.Dropdown(id='dpdn3', value="Cdc45", multi=False,
|
| 122 |
+
options=[
|
| 123 |
+
"Cdc45",
|
| 124 |
+
"Uhrf1",
|
| 125 |
+
"Mcm2",
|
| 126 |
+
"Slbp",
|
| 127 |
+
"Mcm5",
|
| 128 |
+
"Pola1",
|
| 129 |
+
"Gmnn",
|
| 130 |
+
"Cdc6",
|
| 131 |
+
"Rrm2",
|
| 132 |
+
"Atad2",
|
| 133 |
+
"Dscc1",
|
| 134 |
+
"Mcm4",
|
| 135 |
+
"Chaf1b",
|
| 136 |
+
"Rfc2",
|
| 137 |
+
"Msh2",
|
| 138 |
+
"Fen1",
|
| 139 |
+
"Hells",
|
| 140 |
+
"Prim1",
|
| 141 |
+
"Tyms",
|
| 142 |
+
"Mcm6",
|
| 143 |
+
"Wdr76",
|
| 144 |
+
"Rad51",
|
| 145 |
+
"Pcna",
|
| 146 |
+
"Ccne2",
|
| 147 |
+
"Casp8ap2",
|
| 148 |
+
"Usp1",
|
| 149 |
+
"Nasp",
|
| 150 |
+
"Rpa2",
|
| 151 |
+
"Ung",
|
| 152 |
+
"Rad51ap1",
|
| 153 |
+
"Blm",
|
| 154 |
+
"Pold3",
|
| 155 |
+
"Rrm1",
|
| 156 |
+
"Cenpu",
|
| 157 |
+
"Gins2",
|
| 158 |
+
"Tipin",
|
| 159 |
+
"Brip1",
|
| 160 |
+
"Dtl",
|
| 161 |
+
"Exo1",
|
| 162 |
+
"Ubr7",
|
| 163 |
+
"Clspn",
|
| 164 |
+
"E2f8",
|
| 165 |
+
"Cdca7"
|
| 166 |
+
]),
|
| 167 |
+
html.Label("G2M-cycle genes"),
|
| 168 |
+
dcc.Dropdown(id='dpdn4', value="Top2a", multi=False,
|
| 169 |
+
options=[
|
| 170 |
+
"Ube2c",
|
| 171 |
+
"Lbr",
|
| 172 |
+
"Ctcf",
|
| 173 |
+
"Cdc20",
|
| 174 |
+
"Cbx5",
|
| 175 |
+
"Kif11",
|
| 176 |
+
"Anp32e",
|
| 177 |
+
"Birc5",
|
| 178 |
+
"Cdk1",
|
| 179 |
+
"Tmpo",
|
| 180 |
+
"Hmmr",
|
| 181 |
+
"Pimreg",
|
| 182 |
+
"Aurkb",
|
| 183 |
+
"Top2a",
|
| 184 |
+
"Gtse1",
|
| 185 |
+
"Rangap1",
|
| 186 |
+
"Cdca3",
|
| 187 |
+
"Ndc80",
|
| 188 |
+
"Kif20b",
|
| 189 |
+
"Cenpf",
|
| 190 |
+
"Nek2",
|
| 191 |
+
"Nuf2",
|
| 192 |
+
"Nusap1",
|
| 193 |
+
"Bub1",
|
| 194 |
+
"Tpx2",
|
| 195 |
+
"Aurka",
|
| 196 |
+
"Ect2",
|
| 197 |
+
"Cks1b",
|
| 198 |
+
"Kif2c",
|
| 199 |
+
"Cdca8",
|
| 200 |
+
"Cenpa",
|
| 201 |
+
"Mki67",
|
| 202 |
+
"Ccnb2",
|
| 203 |
+
"Kif23",
|
| 204 |
+
"Smc4",
|
| 205 |
+
"G2e3",
|
| 206 |
+
"Tubb4b",
|
| 207 |
+
"Anln",
|
| 208 |
+
"Tacc3",
|
| 209 |
+
"Dlgap5",
|
| 210 |
+
"Ckap2",
|
| 211 |
+
"Ncapd2",
|
| 212 |
+
"Ttk",
|
| 213 |
+
"Ckap5",
|
| 214 |
+
"Cdc25c",
|
| 215 |
+
"Hjurp",
|
| 216 |
+
"Cenpe",
|
| 217 |
+
"Ckap2l",
|
| 218 |
+
"Cdca2",
|
| 219 |
+
"Hmgb2",
|
| 220 |
+
"Cks2",
|
| 221 |
+
"Psrc1",
|
| 222 |
+
"Gas2l3"
|
| 223 |
+
]),
|
| 224 |
+
]),
|
| 225 |
+
html.Div([
|
| 226 |
+
dcc.Graph(id='scatter-plot-5', figure={}, className='three columns',config=config_fig)
|
| 227 |
+
]),
|
| 228 |
+
html.Div([
|
| 229 |
+
dcc.Graph(id='scatter-plot-6', figure={}, className='three columns',config=config_fig)
|
| 230 |
+
]),
|
| 231 |
+
html.Div([
|
| 232 |
+
dcc.Graph(id='scatter-plot-7', figure={}, className='three columns',config=config_fig)
|
| 233 |
+
]),
|
| 234 |
+
html.Div([
|
| 235 |
+
dcc.Graph(id='scatter-plot-8', figure={}, className='three columns',config=config_fig)
|
| 236 |
+
]),
|
| 237 |
+
])
|
| 238 |
+
|
| 239 |
+
# Create the second tab content with scatter-plot-5 and scatter-plot-6
|
| 240 |
+
tab3_content = html.Div([
|
| 241 |
+
html.Div([
|
| 242 |
+
html.Label("UMAP condition 1"),
|
| 243 |
+
dcc.Dropdown(id='dpdn5', value="total_counts", multi=False,
|
| 244 |
+
options=df.columns),
|
| 245 |
+
html.Label("UMAP condition 2"),
|
| 246 |
+
dcc.Dropdown(id='dpdn6', value="n_genes_by_counts", multi=False,
|
| 247 |
+
options=df.columns),
|
| 248 |
+
]),
|
| 249 |
+
html.Div([
|
| 250 |
+
dcc.Graph(id='scatter-plot-9', figure={}, className='four columns',config=config_fig)
|
| 251 |
+
]),
|
| 252 |
+
html.Div([
|
| 253 |
+
dcc.Graph(id='scatter-plot-10', figure={}, className='four columns',config=config_fig)
|
| 254 |
+
]),
|
| 255 |
+
html.Div([
|
| 256 |
+
dcc.Graph(id='scatter-plot-11', figure={}, className='four columns',config=config_fig)
|
| 257 |
+
]),
|
| 258 |
+
html.Div([
|
| 259 |
+
dcc.Graph(id='my-graph2', figure={}, clickData=None, hoverData=None,
|
| 260 |
+
className='four columns',config=config_fig
|
| 261 |
+
)
|
| 262 |
+
]),
|
| 263 |
+
])
|
| 264 |
+
|
| 265 |
+
# Define the tabs layout
|
| 266 |
+
app.layout = html.Div([
|
| 267 |
+
dcc.Tabs(id='tabs', style= {'width': 400,
|
| 268 |
+
'font-size': '100%',
|
| 269 |
+
'height': 50}, value='tab1',children=[
|
| 270 |
+
dcc.Tab(label='QC', value='tab1', children=tab1_content),
|
| 271 |
+
dcc.Tab(label='Cell cycle', value='tab2', children=tab2_content),
|
| 272 |
+
dcc.Tab(label='Custom', value='tab3', children=tab3_content),
|
| 273 |
+
]),
|
| 274 |
+
])
|
| 275 |
+
|
| 276 |
+
# Define the circular callback
|
| 277 |
+
@app.callback(
|
| 278 |
+
Output("min-slider-1", "value"),
|
| 279 |
+
Output("max-slider-1", "value"),
|
| 280 |
+
Output("min-slider-2", "value"),
|
| 281 |
+
Output("max-slider-2", "value"),
|
| 282 |
+
Output("min-slider-3", "value"),
|
| 283 |
+
Output("max-slider-3", "value"),
|
| 284 |
+
Input("min-slider-1", "value"),
|
| 285 |
+
Input("max-slider-1", "value"),
|
| 286 |
+
Input("min-slider-2", "value"),
|
| 287 |
+
Input("max-slider-2", "value"),
|
| 288 |
+
Input("min-slider-3", "value"),
|
| 289 |
+
Input("max-slider-3", "value"),
|
| 290 |
+
)
|
| 291 |
+
def circular_callback(min_1, max_1, min_2, max_2, min_3, max_3):
|
| 292 |
+
return min_1, max_1, min_2, max_2, min_3, max_3
|
| 293 |
+
|
| 294 |
+
@app.callback(
|
| 295 |
+
Output('range-slider-1', 'value'),
|
| 296 |
+
Output('range-slider-2', 'value'),
|
| 297 |
+
Output('range-slider-3', 'value'),
|
| 298 |
+
Input('min-slider-1', 'value'),
|
| 299 |
+
Input('max-slider-1', 'value'),
|
| 300 |
+
Input('min-slider-2', 'value'),
|
| 301 |
+
Input('max-slider-2', 'value'),
|
| 302 |
+
Input('min-slider-3', 'value'),
|
| 303 |
+
Input('max-slider-3', 'value'),
|
| 304 |
+
)
|
| 305 |
+
def update_slider_values(min_1, max_1, min_2, max_2, min_3, max_3):
|
| 306 |
+
return [min_1, max_1], [min_2, max_2], [min_3, max_3]
|
| 307 |
+
|
| 308 |
+
@app.callback(
|
| 309 |
+
Output(component_id='my-graph', component_property='figure'),
|
| 310 |
+
Output(component_id='pie-graph', component_property='figure'),
|
| 311 |
+
Output(component_id='scatter-plot', component_property='figure'),
|
| 312 |
+
Output(component_id='scatter-plot-2', component_property='figure'),
|
| 313 |
+
Output(component_id='scatter-plot-3', component_property='figure'),
|
| 314 |
+
Output(component_id='scatter-plot-4', component_property='figure'), # Add this new scatter plot
|
| 315 |
+
Output(component_id='scatter-plot-5', component_property='figure'),
|
| 316 |
+
Output(component_id='scatter-plot-6', component_property='figure'),
|
| 317 |
+
Output(component_id='scatter-plot-7', component_property='figure'),
|
| 318 |
+
Output(component_id='scatter-plot-8', component_property='figure'),
|
| 319 |
+
Output(component_id='scatter-plot-9', component_property='figure'),
|
| 320 |
+
Output(component_id='scatter-plot-10', component_property='figure'),
|
| 321 |
+
Output(component_id='scatter-plot-11', component_property='figure'),
|
| 322 |
+
Output(component_id='my-graph2', component_property='figure'),
|
| 323 |
+
Input(component_id='dpdn2', component_property='value'),
|
| 324 |
+
Input(component_id='dpdn3', component_property='value'),
|
| 325 |
+
Input(component_id='dpdn4', component_property='value'),
|
| 326 |
+
Input(component_id='dpdn5', component_property='value'),
|
| 327 |
+
Input(component_id='dpdn6', component_property='value'),
|
| 328 |
+
Input(component_id='range-slider-1', component_property='value'),
|
| 329 |
+
Input(component_id='range-slider-2', component_property='value'),
|
| 330 |
+
Input(component_id='range-slider-3', component_property='value')
|
| 331 |
+
)
|
| 332 |
+
|
| 333 |
+
def update_graph_and_pie_chart(batch_chosen, s_chosen, g2m_chosen, condition1_chosen, condition2_chosen, range_value_1, range_value_2, range_value_3):
|
| 334 |
+
dff = df.filter(
|
| 335 |
+
(pl.col('batch').cast(str).is_in(batch_chosen)) &
|
| 336 |
+
(pl.col(col_features) >= range_value_1[0]) &
|
| 337 |
+
(pl.col(col_features) <= range_value_1[1]) &
|
| 338 |
+
(pl.col(col_counts) >= range_value_2[0]) &
|
| 339 |
+
(pl.col(col_counts) <= range_value_2[1]) &
|
| 340 |
+
(pl.col(col_mt) >= range_value_3[0]) &
|
| 341 |
+
(pl.col(col_mt) <= range_value_3[1])
|
| 342 |
+
)
|
| 343 |
+
|
| 344 |
+
#Drop categories that are not in the filtered data
|
| 345 |
+
dff = dff.with_columns(dff['batch'].cast(str))
|
| 346 |
+
dff = dff.with_columns(dff['batch'].cast(pl.Categorical))
|
| 347 |
+
|
| 348 |
+
# Plot figures
|
| 349 |
+
fig_violin = px.violin(data_frame=dff, x='batch', y=col_features, box=True, points="all",
|
| 350 |
+
color='batch', hover_name='batch',template="seaborn")
|
| 351 |
+
|
| 352 |
+
# Calculate the percentage of each category (normalized_count) for pie chart
|
| 353 |
+
category_counts = dff.group_by("batch").agg(pl.col("batch").count().alias("count"))
|
| 354 |
+
total_count = len(dff)
|
| 355 |
+
category_counts = category_counts.with_columns((pl.col("count") / total_count * 100).alias("normalized_count"))
|
| 356 |
+
|
| 357 |
+
# Display the result
|
| 358 |
+
labels = category_counts["batch"].to_list()
|
| 359 |
+
values = category_counts["normalized_count"].to_list()
|
| 360 |
+
|
| 361 |
+
total_cells = total_count # Calculate total number of cells
|
| 362 |
+
pie_title = f'Percentage of Total Cells: {total_cells}' # Include total cells in the title
|
| 363 |
+
|
| 364 |
+
fig_pie = px.pie(names=labels, values=values, title=pie_title,template="seaborn")
|
| 365 |
+
|
| 366 |
+
# Create the scatter plots
|
| 367 |
+
fig_scatter = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color='batch',
|
| 368 |
+
labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
|
| 369 |
+
hover_name='batch',template="seaborn")
|
| 370 |
+
|
| 371 |
+
fig_scatter_2 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color=col_mt,
|
| 372 |
+
labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
|
| 373 |
+
hover_name='batch',template="seaborn")
|
| 374 |
+
|
| 375 |
+
fig_scatter_3 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color=col_features,
|
| 376 |
+
labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
|
| 377 |
+
hover_name='batch',template="seaborn")
|
| 378 |
+
|
| 379 |
+
|
| 380 |
+
fig_scatter_4 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color=col_counts,
|
| 381 |
+
labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
|
| 382 |
+
hover_name='batch',template="seaborn")
|
| 383 |
+
|
| 384 |
+
fig_scatter_5 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color=s_chosen,
|
| 385 |
+
labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
|
| 386 |
+
hover_name='batch', title="S-cycle gene:",template="seaborn")
|
| 387 |
+
|
| 388 |
+
fig_scatter_6 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color=g2m_chosen,
|
| 389 |
+
labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
|
| 390 |
+
hover_name='batch', title="G2M-cycle gene:",template="seaborn")
|
| 391 |
+
|
| 392 |
+
fig_scatter_7 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color="S_score",
|
| 393 |
+
labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
|
| 394 |
+
hover_name='batch', title="S score:",template="seaborn")
|
| 395 |
+
|
| 396 |
+
fig_scatter_8 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color="G2M_score",
|
| 397 |
+
labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
|
| 398 |
+
hover_name='batch', title="G2M score:",template="seaborn")
|
| 399 |
+
|
| 400 |
+
fig_scatter_9 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color=condition1_chosen,
|
| 401 |
+
labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
|
| 402 |
+
hover_name='batch',template="seaborn")
|
| 403 |
+
|
| 404 |
+
fig_scatter_10 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color=condition2_chosen,
|
| 405 |
+
labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
|
| 406 |
+
hover_name='batch',template="seaborn")
|
| 407 |
+
|
| 408 |
+
fig_scatter_11 = px.scatter(data_frame=dff, x=condition1_chosen, y=condition2_chosen, color='batch',
|
| 409 |
+
#labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
|
| 410 |
+
hover_name='batch',template="seaborn")
|
| 411 |
+
|
| 412 |
+
fig_violin2 = px.violin(data_frame=dff, x=condition1_chosen, y=condition2_chosen, box=True, points="all",
|
| 413 |
+
color=condition1_chosen, hover_name=condition1_chosen,template="seaborn")
|
| 414 |
+
|
| 415 |
+
|
| 416 |
+
return fig_violin, fig_pie, fig_scatter, fig_scatter_2, fig_scatter_3, fig_scatter_4, fig_scatter_5, fig_scatter_6, fig_scatter_7, fig_scatter_8, fig_scatter_9, fig_scatter_10, fig_scatter_11, fig_violin2
|
| 417 |
+
|
| 418 |
+
# Set http://localhost:5000/ in web browser
|
| 419 |
+
# Now create your regular FASTAPI application
|
| 420 |
+
|
| 421 |
+
if __name__ == '__main__':
|
| 422 |
+
app.run_server(debug=True, use_reloader=False) #host='0.0.0.0', #, port=5000
|