File size: 20,069 Bytes
a672baa
 
 
 
 
d40e98f
a672baa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6c1dada
a672baa
 
 
 
 
 
 
 
 
 
 
 
6c1dada
a672baa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6c1dada
a672baa
 
 
 
 
 
 
 
 
 
 
 
 
6c1dada
a672baa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
# Dash app to visualize scRNA-seq data quality control metrics from scanpy objects
# Shoutout to Coding-with-Adam for the initial template of the project: 
# https://github.com/Coding-with-Adam/Dash-by-Plotly/blob/master/Dash%20Components/Graph/dash-graph.py

import dash
from dash import dcc, html, Output, Input, callback
import plotly.express as px
import dash_callback_chain
import yaml
import polars as pl
import os
pl.enable_string_cache(False)

dash.register_page(__name__)

dataset = "data10xflex/corg/10xflexcorg_umap_clusres"

# Set custom resolution for plots:
config_fig = {
  'toImageButtonOptions': {
    'format': 'svg',
    'filename': 'custom_image',
    'height': 600,
    'width': 700,
    'scale': 1,
  }
}
from adlfs import AzureBlobFileSystem
mountpount=os.environ['AZURE_MOUNT_POINT'],
AZURE_STORAGE_ACCESS_KEY=os.getenv('AZURE_STORAGE_ACCESS_KEY')
AZURE_STORAGE_ACCOUNT=os.getenv('AZURE_STORAGE_ACCOUNT')

# Load in config file
config_path = "./data/config.yaml"

# Add the read-in data from the yaml file
def read_config(filename):
    with open(filename, 'r') as yaml_file:
        config = yaml.safe_load(yaml_file)
    return config

config = read_config(config_path)
path_parquet = config.get("path_parquet")
col_batch = config.get("col_batch")
col_features = config.get("col_features")
col_counts = config.get("col_counts")
col_mt = config.get("col_mt")

#filepath = f"az://{path_parquet}"

storage_options={'account_name': AZURE_STORAGE_ACCOUNT, 'account_key': AZURE_STORAGE_ACCESS_KEY,'anon': False}
#azfs = AzureBlobFileSystem(**storage_options )

# Load in multiple dataframes
df = pl.read_parquet(f"az://{dataset}.parquet", storage_options=storage_options)

# Setup the app
#external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
#app = dash.Dash(__name__, use_pages=True) #, requests_pathname_prefix='/dashboard1/'

#df = pl.read_parquet(filepath,storage_options=storage_options)
#df = pl.DataFrame()
#abfs = AzureBlobFileSystem(account_name=accountname,account_key=accountkey)
#df = df.rename({"__index_level_0__": "Unnamed: 0"})

#df1 = pl.read_parquet(filepath, storage_options=storage_options)

#df2 = pl.read_parquet(f"az://data10xflex/{dataset_chosen}.parquet", storage_options=storage_options)

#tab0_content = html.Div([
#    html.Label("Dataset chosen"),    
#    dcc.Dropdown(id='dpdn1', value="corg/10xflexcorg_umap_clusres", multi=False,
#                 options=["corg/10xflexcorg_umap_clusres","d1011/10xflexd1011_umap_clusres"])
#])

#@app.callback(
#    Input(component_id='dpdn1', component_property='value')
#)

#def update_filepath(dpdn1):
#    global df
#    if str(f"az://data10xflex/{dpdn1}.parquet") != str(filepath):
#        print("not identical filepath, chosing other")
#        df2 = pl.read_parquet(f"az://data10xflex/{dpdn1}.parquet", storage_options=storage_options)
#        df = df2
#    return

#df = pl.read_parquet(filepath, storage_options=storage_options)
min_value = df[col_features].min()
max_value = df[col_features].max()

min_value_2 = df[col_counts].min()
min_value_2 = round(min_value_2)
max_value_2 = df[col_counts].max()
max_value_2 = round(max_value_2)

min_value_3 = df[col_mt].min()
min_value_3 = round(min_value_3, 1)
max_value_3 = df[col_mt].max()
max_value_3 = round(max_value_3, 1)

# Loads in the conditions specified in the yaml file

# Note: Future version perhaps all values from a column in the dataframe of the parquet file
# Note 2: This could also be a tsv of the categories and own specified colors
#conditions = df[col_batch].unique().to_list()
# Create the first tab content
# Add Sliders for three QC params: N genes by counts, total amount of reads and pct MT reads

tab1_content = html.Div([
    html.Label("Column chosen"),    
    dcc.Dropdown(id='dpdn2', value="batch", multi=False,
                 options=df.columns),
    html.Label("N Genes by Counts"),
    dcc.RangeSlider(
        id='range-slider-1',
        step=250,
        value=[min_value, max_value],
        marks={i: str(i) for i in range(min_value, max_value + 1, 250)},
    ),
    dcc.Input(id='min-slider-1', type='number', value=min_value, debounce=True),
    dcc.Input(id='max-slider-1', type='number', value=max_value, debounce=True),
    html.Label("Total Counts"),
    dcc.RangeSlider(
        id='range-slider-2',
        step=7500,
        value=[min_value_2, max_value_2],
        marks={i: str(i) for i in range(min_value_2, max_value_2 + 1, 7500)},
    ),
    dcc.Input(id='min-slider-2', type='number', value=min_value_2, debounce=True),
    dcc.Input(id='max-slider-2', type='number', value=max_value_2, debounce=True),
    html.Label("Percent Mitochondrial Genes"),
    dcc.RangeSlider(
        id='range-slider-3',
        step=5,
        min=0,
        max=100,
        value=[min_value_3, max_value_3],
    ),
    dcc.Input(id='min-slider-3', type='number', value=min_value_3, debounce=True),
    dcc.Input(id='max-slider-3', type='number', value=max_value_3, debounce=True),
    html.Div([
        dcc.Graph(id='pie-graph', figure={}, className='four columns',config=config_fig),
        dcc.Graph(id='my-graph', figure={}, clickData=None, hoverData=None,
                  className='four columns',config=config_fig
                  ),
        dcc.Graph(id='scatter-plot', figure={}, className='four columns',config=config_fig)
    ]),
    html.Div([
        dcc.Graph(id='scatter-plot-2', figure={}, className='four columns',config=config_fig)
    ]),
    html.Div([
        dcc.Graph(id='scatter-plot-3', figure={}, className='four columns',config=config_fig)
    ]),
    html.Div([
        dcc.Graph(id='scatter-plot-4', figure={}, className='four columns',config=config_fig)
    ]),
])

# Create the second tab content with scatter-plot-5 and scatter-plot-6
tab2_content = html.Div([
    html.Div([
            html.Label("S-cycle genes"),
            dcc.Dropdown(id='dpdn3', value="MCM5", multi=False,
                 options=[
    "MCM5",
    "PCNA",
    "TYMS",
    "FEN1",
    "MCM2",
    "MCM4",
    "RRM1",
    "UNG",
    "GINS2",
    "MCM6",
    "CDCA7",
    "DTL",
    "PRIM1",
    "UHRF1",
    "MLF1IP",
    "HELLS",
    "RFC2",
    "RPA2",
    "NASP",
    "RAD51AP1",
    "GMNN",
    "WDR76",
    "SLBP",
    "CCNE2",
    "UBR7",
    "POLD3",
    "MSH2",
    "ATAD2",
    "RAD51",
    "RRM2",
    "CDC45",
    "CDC6",
    "EXO1",
    "TIPIN",
    "DSCC1",
    "BLM",
    "CASP8AP2",
    "USP1",
    "CLSPN",
    "POLA1",
    "CHAF1B",
    "BRIP1",
    "E2F8"
]),
            html.Label("G2M-cycle genes"),
            dcc.Dropdown(id='dpdn4', value="TOP2A", multi=False,
                 options=[
    'HMGB2', 'CDK1', 'NUSAP1', 'UBE2C', 'BIRC5', 'TPX2', 'TOP2A', 'NDC80', 'CKS2', 'NUF2', 'CKS1B', 'MKI67', 'TMPO', 'CENPF', 'TACC3', 'FAM64A', 'SMC4', 'CCNB2', 'CKAP2L', 'CKAP2', 'AURKB', 'BUB1', 'KIF11', 'ANP32E', 'TUBB4B', 'GTSE1', 'KIF20B', 'HJURP', 'CDCA3', 'HN1', 'CDC20', 'TTK', 'CDC25C', 'KIF2C', 'RANGAP1', 'NCAPD2', 'DLGAP5', 'CDCA2', 'CDCA8', 'ECT2', 'KIF23', 'HMMR', 'AURKA', 'PSRC1', 'ANLN', 'LBR', 'CKAP5', 
                     'CENPE', 'CTCF', 'NEK2', 'G2E3', 'GAS2L3', 'CBX5', 'CENPA'
]),
    ]),
    html.Div([
        dcc.Graph(id='scatter-plot-5', figure={}, className='three columns',config=config_fig)
    ]),
    html.Div([
        dcc.Graph(id='scatter-plot-6', figure={}, className='three columns',config=config_fig)
    ]),
    html.Div([
        dcc.Graph(id='scatter-plot-7', figure={}, className='three columns',config=config_fig)
    ]),
    html.Div([
        dcc.Graph(id='scatter-plot-8', figure={}, className='three columns',config=config_fig)
    ]),
])

# Create the second tab content with scatter-plot-5 and scatter-plot-6
tab3_content = html.Div([
    html.Div([
            html.Label("UMAP condition 1"),
            dcc.Dropdown(id='dpdn5', value="batch", multi=False,
                 options=df.columns),
            html.Label("UMAP condition 2"),
            dcc.Dropdown(id='dpdn6', value="n_genes_by_counts", multi=False,
                 options=df.columns),
    html.Div([
        dcc.Graph(id='scatter-plot-9', figure={}, className='four columns',config=config_fig)
    ]),
    html.Div([
        dcc.Graph(id='scatter-plot-10', figure={}, className='four columns',config=config_fig)
    ]),
    html.Div([
        dcc.Graph(id='scatter-plot-11', figure={}, className='four columns',config=config_fig)
    ]),
    html.Div([
            dcc.Graph(id='my-graph2', figure={}, clickData=None, hoverData=None,
                  className='four columns',config=config_fig
                  )
    ]),
    ]),
])
#    html.Div([
#        dcc.Graph(id='scatter-plot-12', figure={}, className='four columns',config=config_fig)
#    ]),


tab4_content = html.Div([
    html.Div([
            html.Label("Multi gene"),
            dcc.Dropdown(id='dpdn7', value=["PAX6","TP63","S100A9"], multi=True,
                 options=df.columns),
]),
    html.Div([
        dcc.Graph(id='scatter-plot-12', figure={}, className='four columns',config=config_fig)
    ]),
])

# Define the tabs layout
layout = html.Div([
    dcc.Tabs(id='tabs', style= {'width': 600,
        'font-size': '100%',
        'height': 50}, value='tab1',children=[
        #dcc.Tab(label='Dataset', value='tab0', children=tab0_content),
        dcc.Tab(label='QC', value='tab1', children=tab1_content),
        dcc.Tab(label='Cell cycle', value='tab2', children=tab2_content),
        dcc.Tab(label='Custom', value='tab3', children=tab3_content),
        dcc.Tab(label='Multi dot', value='tab4', children=tab4_content),
    ]),
])

# Define the circular callback
@callback(
    Output("min-slider-1", "value"),
    Output("max-slider-1", "value"),
    Output("min-slider-2", "value"),
    Output("max-slider-2", "value"),
    Output("min-slider-3", "value"),
    Output("max-slider-3", "value"),
    Input("min-slider-1", "value"),
    Input("max-slider-1", "value"),
    Input("min-slider-2", "value"),
    Input("max-slider-2", "value"),
    Input("min-slider-3", "value"),
    Input("max-slider-3", "value"),
)
def circular_callback(min_1, max_1, min_2, max_2, min_3, max_3):
    return min_1, max_1, min_2, max_2, min_3, max_3

@callback(
    Output('range-slider-1', 'value'),
    Output('range-slider-2', 'value'),
    Output('range-slider-3', 'value'),
    Input('min-slider-1', 'value'),
    Input('max-slider-1', 'value'),
    Input('min-slider-2', 'value'),
    Input('max-slider-2', 'value'),
    Input('min-slider-3', 'value'),
    Input('max-slider-3', 'value'),
)
def update_slider_values(min_1, max_1, min_2, max_2, min_3, max_3):
    return [min_1, max_1], [min_2, max_2], [min_3, max_3]

@callback(
    Output(component_id='my-graph', component_property='figure'),
    Output(component_id='pie-graph', component_property='figure'),
    Output(component_id='scatter-plot', component_property='figure'),
    Output(component_id='scatter-plot-2', component_property='figure'),
    Output(component_id='scatter-plot-3', component_property='figure'),
    Output(component_id='scatter-plot-4', component_property='figure'),  # Add this new scatter plot
    Output(component_id='scatter-plot-5', component_property='figure'),
    Output(component_id='scatter-plot-6', component_property='figure'),
    Output(component_id='scatter-plot-7', component_property='figure'),
    Output(component_id='scatter-plot-8', component_property='figure'),
    Output(component_id='scatter-plot-9', component_property='figure'),
    Output(component_id='scatter-plot-10', component_property='figure'),
    Output(component_id='scatter-plot-11', component_property='figure'),
    Output(component_id='scatter-plot-12', component_property='figure'),
    Output(component_id='my-graph2', component_property='figure'),
    Input(component_id='dpdn2', component_property='value'),
    Input(component_id='dpdn3', component_property='value'),
    Input(component_id='dpdn4', component_property='value'),
    Input(component_id='dpdn5', component_property='value'),
    Input(component_id='dpdn6', component_property='value'),
    Input(component_id='dpdn7', component_property='value'),
    Input(component_id='range-slider-1', component_property='value'),
    Input(component_id='range-slider-2', component_property='value'),
    Input(component_id='range-slider-3', component_property='value')
)

def update_graph_and_pie_chart(col_chosen, s_chosen, g2m_chosen, condition1_chosen, condition2_chosen, condition3_chosen, range_value_1, range_value_2, range_value_3): #batch_chosen, 
    batch_chosen = df[col_chosen].unique().to_list()
    dff = df.filter(
        (pl.col(col_chosen).cast(str).is_in(batch_chosen)) &
        (pl.col(col_features) >= range_value_1[0]) &
        (pl.col(col_features) <= range_value_1[1]) &
        (pl.col(col_counts) >= range_value_2[0]) &
        (pl.col(col_counts) <= range_value_2[1]) &
        (pl.col(col_mt) >= range_value_3[0]) &
        (pl.col(col_mt) <= range_value_3[1])
)
    
    #Drop categories that are not in the filtered data
    dff = dff.with_columns(dff[col_chosen].cast(pl.Categorical))

    dff = dff.sort(col_chosen)
    
    # Plot figures
    fig_violin = px.violin(data_frame=dff, x=col_chosen, y=col_features, box=True, points="all",
                            color=col_chosen, hover_name=col_chosen,template="seaborn")

    # Cache commonly used subexpressions
    total_count = pl.lit(len(dff))
    category_counts = dff.group_by(col_chosen).agg(pl.col(col_chosen).count().alias("count"))
    category_counts = category_counts.with_columns(((pl.col("count") / total_count * 100).round(decimals=2)).alias("normalized_count"))

    # Sort the dataframe
    #category_counts = category_counts.sort(col_chosen) does not work check if the names are different ...
    
    # Display the result
    total_cells = total_count  # Calculate total number of cells
    pie_title = f'Percentage of Total Cells: {total_cells}'  # Include total cells in the title

    # Calculate the mean expression
    
    # Melt wide format DataFrame into long format
    # Specify batch column as string type and gene columns as float type
    list_conds = condition3_chosen
    list_conds += [col_chosen]
    dff_pre = dff.select(list_conds)
    
    # Melt wide format DataFrame into long format
    dff_long = dff_pre.melt(id_vars=col_chosen, variable_name="Gene", value_name="Mean expression")

    # Calculate the mean expression levels for each gene in each region
    expression_means = dff_long.lazy().group_by([col_chosen, "Gene"]).agg(pl.mean("Mean expression")).collect()
    
    # Calculate the percentage total expressed
    dff_long1 = dff_pre.melt(id_vars=col_chosen, variable_name="Gene")#.group_by(pl.all()).agg(pl.len())
    count = 1
    dff_long2 = dff_long1.with_columns(pl.lit(count).alias("len"))
    dff_long3 = dff_long2.filter(pl.col("value") > 0).group_by([col_chosen, "Gene"]).agg(pl.sum("len").alias("len"))
    dff_long4 = dff_long2.group_by([col_chosen, "Gene"]).agg(pl.sum("len").alias("total"))
    dff_5 = dff_long4.join(dff_long3, on=[col_chosen,"Gene"], how="outer")
    result = dff_5.select([
        pl.when((pl.col('len').is_not_null()) & (pl.col('total').is_not_null()))
              .then(pl.col('len') / pl.col('total')*100)
              .otherwise(None).alias("%"),
    ])
    result = result.with_columns(pl.col("%").fill_null(100))
    dff_5[["percentage"]] = result[["%"]]
    dff_5 = dff_5.select(pl.col(col_chosen,"Gene","percentage"))

    # Final part to join the percentage expressed and mean expression levels
    # TO DO
    expression_means = expression_means.join(dff_5, on=[col_chosen,"Gene"], how="inner")

    # Order the dataframe on ascending categories
    expression_means = expression_means.sort(col_chosen, descending=True)
    
    #expression_means = expression_means.select(["batch", "Gene", "Expression"] + condition3_chosen)
    category_counts = category_counts.sort(col_chosen)
    
    fig_pie = px.pie(category_counts, values="normalized_count", names=col_chosen, labels=col_chosen, hole=.3, title=pie_title, template="seaborn")

    #labels = category_counts[col_chosen].to_list()
    #values = category_counts["normalized_count"].to_list()

    # Create the scatter plots
    fig_scatter = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color=col_chosen,
                             labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
                             hover_name='batch',template="seaborn")

    fig_scatter_2 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color=col_mt,
                             labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
                             hover_name='batch',template="seaborn")

    fig_scatter_3 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color=col_features,
                             labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
                             hover_name='batch',template="seaborn")


    fig_scatter_4 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color=col_counts,
                             labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
                             hover_name='batch',template="seaborn")
    
    fig_scatter_5 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color=s_chosen,
                            labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
                            hover_name='batch', title="S-cycle gene:",template="seaborn")

    fig_scatter_6 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color=g2m_chosen,
                            labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
                            hover_name='batch', title="G2M-cycle gene:",template="seaborn")
    
    fig_scatter_7 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color="S_score",
                            labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
                            hover_name='batch', title="S score:",template="seaborn")
    
    fig_scatter_8 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color="G2M_score",
                            labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
                            hover_name='batch', title="G2M score:",template="seaborn")

    # Sort values of custom in-between
    dff = dff.sort(condition1_chosen)
    
    fig_scatter_9 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color=condition1_chosen,
                            labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
                            hover_name='batch',template="seaborn")
    
    fig_scatter_10 = px.scatter(data_frame=dff, x='X_umap-0', y='X_umap-1', color=condition2_chosen,
                            labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
                            hover_name='batch',template="seaborn")
    
    fig_scatter_11 = px.scatter(data_frame=dff, x=condition1_chosen, y=condition2_chosen, color=condition1_chosen,
                            #labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
                            hover_name='batch',template="seaborn")
    
    fig_scatter_12 = px.scatter(data_frame=expression_means, x="Gene", y=col_chosen, color="Mean expression",
                                size="percentage", size_max = 20,
                            #labels={'X_umap-0': 'umap1' , 'X_umap-1': 'umap2'},
                            hover_name=col_chosen,template="seaborn")
    
    fig_violin2 = px.violin(data_frame=dff, x=condition1_chosen, y=condition2_chosen, box=True, points="all",
                            color=condition1_chosen, hover_name=condition1_chosen,template="seaborn")


    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_scatter_12, fig_violin2

# Set http://localhost:5000/ in web browser
# Now create your regular FASTAPI application

#if __name__ == '__main__':
#    app.run_server(debug=False, use_reloader=False, host='0.0.0.0', port=5000) #