-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjupyter_support.py
51 lines (41 loc) · 1.31 KB
/
jupyter_support.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
45
46
47
48
49
50
51
import anndata as ad
import pandas as pd
__name__ = "jupyter_support"
from dash import jupyter_dash
# Configure the viewing mode
# external = display a link to click
# tab = open in a new browser tab
# jupyterlab = display in tab if run in jupyterlab
jupyter_dash.default_mode = "external"
# Support notebooks behind a proxy
try:
jupyter_dash.infer_jupyter_proxy_config()
except: pass
from viz import data
def run_app_in_jupyter(
interactions: pd.DataFrame,
adata: ad.AnnData,
deg_adata: ad.AnnData,
target_stats: pd.DataFrame,
condition_name: str,
skip_compile: bool,
port: int
):
"""
Run the visualization within a Jupyter notebook.
:param interactions: The interactions file run with ContactTracing.
:param adata: The contactTracing results output data.
:param port: The port to host the app in.
"""
# Remove cin-tme specific references
data.EXCLUDED_CELL_TYPES = []
if not skip_compile:
print("Compiling the provided dataset...This may take awhile.", flush=True)
data.compile_custom_dataset(adata, deg_adata, target_stats, interactions, condition_name)
from app import app
return app.run(
port=port,
jupyter_mode='external',
jupyter_width='100%',
jupyter_height=1000,
)