-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
44 lines (37 loc) · 1.36 KB
/
app.py
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
from shiny import App, reactive, ui
import scanpy as sc
import pickle
import json
from composition import composition_server, composition_ui
from export import export_ui, export_server
from dgea.dgea_scvi import dgea_server, dgea_ui
from tree import tree_server, tree_ui
with open("data/config.json") as f:
config = json.load(f)
adata = sc.read_h5ad("data/" + config["adata"])
tree = pickle.load(open("data/" + config["tree"], "rb")) if "tree" in config else None
name = config["name"]
model_path = config["model_path"]
categorical_columns = adata.obs.select_dtypes(include="category").columns.to_list()
app_ui = ui.page_navbar(
ui.nav_panel("Composition analysis",
composition_ui("composition")
),
ui.nav_panel("Differential expression analysis",
dgea_ui("dgea")),
ui.nav_panel("Tree", tree_ui("tree")),
ui.nav_panel("Data export",
export_ui("export")),
title=f"SIMBA🦁 downstream: {name}",
id="page"
)
def server(input, output, session):
_dataframe = reactive.value(adata.obs)
_adata = reactive.value(adata)
_tree = reactive.value(tree)
_model = reactive.value(model_path)
composition_server("composition", _dataframe)
export_server("export")
dgea_server("dgea", _adata, _model)
tree_server("tree", _tree)
app = App(app_ui, server)