Arts-of-coding commited on
Commit
6f1f3b5
1 Parent(s): 737cc7b

Upload 7 files

Browse files
Files changed (7) hide show
  1. Dockerfile +55 -0
  2. LICENSE +201 -0
  3. README.md +4 -11
  4. dash_plotly_QC_scRNA.py +422 -0
  5. main.py +63 -0
  6. mount-blobfuse.sh +9 -0
  7. requirements.txt +12 -0
Dockerfile ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use an official Python runtime as a base image
2
+ FROM ubuntu:18.04
3
+ FROM python:3.9-slim
4
+
5
+ # Expose the port to run it
6
+ ENV LISTEN_PORT=5000
7
+ EXPOSE 5000
8
+
9
+ LABEL Maintainer="arts-of-coding"
10
+
11
+ WORKDIR /
12
+
13
+ # fix locales
14
+ RUN apt-get update \
15
+ && apt-get install -y --no-install-recommends locales \
16
+ && rm -rf /var/lib/apt/lists/* \
17
+ && localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
18
+
19
+ ENV LANG en_US.utf8
20
+
21
+ # install blobfuse
22
+ RUN apt-get update \
23
+ && apt-get install -y wget apt-utils \
24
+ && wget https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb \
25
+ && dpkg -i packages-microsoft-prod.deb \
26
+ && apt-get remove -y wget \
27
+ && apt-get update \
28
+ && apt-get install -y --no-install-recommends fuse blobfuse libcurl3-gnutls libgnutls30 \
29
+ && rm -rf /var/lib/apt/lists/*
30
+
31
+ COPY mount-blobfuse.sh /
32
+ RUN chmod +x /mount-blobfuse.sh
33
+ #COPY --from=compiler /opt/venv/bin/activate /usr/local/bin/activate_venv
34
+ COPY /mount-blobfuse.sh /app/mount-blobfuse.sh
35
+
36
+ #ADD /data/ /app/data/
37
+
38
+ #WORKDIR /app/
39
+
40
+ # Preset the volume change this to the actual azure folder
41
+ #VOLUME /dash_plotly_QC_scRNA/./data
42
+
43
+ WORKDIR /
44
+
45
+ COPY ./requirements.txt ./
46
+ RUN pip install --requirement ./requirements.txt
47
+
48
+ COPY ./dash_plotly_QC_scRNA.py ./
49
+
50
+ COPY ./main.py ./
51
+
52
+ # How the docker app will run
53
+ ENTRYPOINT ["/bin/bash", "-c", "/mount-blobfuse.sh; exec $SHELL"]
54
+
55
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "5000"]
LICENSE ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
README.md CHANGED
@@ -1,11 +1,4 @@
1
- ---
2
- title: Testazurectrl
3
- emoji: 🌍
4
- colorFrom: yellow
5
- colorTo: pink
6
- sdk: docker
7
- pinned: false
8
- license: apache-2.0
9
- ---
10
-
11
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
+ [<img src="https://img.shields.io/badge/dockerhub-images-blue.svg?logo=Docker">](https://hub.docker.com/repository/docker/artsofcoding/daqcs/general)
2
+
3
+ # dash_plotly_QC_scRNA (daqcs)
4
+ Dash app to visualize scRNA-seq data quality control metrics from scanpy objects
 
 
 
 
 
 
 
dash_plotly_QC_scRNA.py ADDED
@@ -0,0 +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 = "./app/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
main.py ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import uvicorn
2
+ from fastapi import FastAPI
3
+ from fastapi.middleware.wsgi import WSGIMiddleware
4
+ from dash_plotly_QC_scRNA import app as dashboard1
5
+ #from app2 import app as dashboard2
6
+
7
+ #########################################################
8
+ import dash
9
+ from dash import dcc, html, Output, Input
10
+ import plotly.express as px
11
+ import dash_callback_chain
12
+ import yaml
13
+ import polars as pl
14
+ pl.enable_string_cache(False)
15
+
16
+ # Set custom resolution for plots:
17
+ config_fig = {
18
+ 'toImageButtonOptions': {
19
+ 'format': 'svg',
20
+ 'filename': 'custom_image',
21
+ 'height': 600,
22
+ 'width': 700,
23
+ 'scale': 1,
24
+ }
25
+ }
26
+
27
+ config_path = "./app/azure/config.yaml"
28
+
29
+ # Add the read-in data from the yaml file
30
+ def read_config(filename):
31
+ with open(filename, 'r') as yaml_file:
32
+ config = yaml.safe_load(yaml_file)
33
+ return config
34
+
35
+ config = read_config(config_path)
36
+ path_parquet = config.get("path_parquet")
37
+ conditions = config.get("conditions")
38
+ col_features = config.get("col_features")
39
+ col_counts = config.get("col_counts")
40
+ col_mt = config.get("col_mt")
41
+
42
+ # Import the data from one .parquet file
43
+ df = pl.read_parquet(path_parquet)
44
+ #df = df.rename({"__index_level_0__": "Unnamed: 0"})
45
+
46
+ # Setup the app
47
+ external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
48
+
49
+ ######################################################################
50
+ # Define the FastAPI server
51
+ app = FastAPI()
52
+ # Mount the Dash app as a sub-application in the FastAPI server
53
+ app.mount("/dashboard1", WSGIMiddleware(dashboard1.server))
54
+ #app.mount("/dashboard2", WSGIMiddleware(dashboard2.server))
55
+
56
+ # Define the main API endpoint
57
+ @app.get("/")
58
+ def index():
59
+ return "Hello"
60
+
61
+ # Start the FastAPI server
62
+ if __name__ == "__main__":
63
+ uvicorn.run(app, host="0.0.0.0")
mount-blobfuse.sh ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ # mount our blobstore
2
+ test ${AZURE_MOUNT_POINT}
3
+ rm -rf ${AZURE_MOUNT_POINT}
4
+ mkdir ${AZURE_MOUNT_POINT}
5
+
6
+ blobfuse ${AZURE_MOUNT_POINT} --use-https=true --tmp-path=/tmp/blobfuse/${AZURE_STORAGE_ACCOUNT} --container-name=${AZURE_STORAGE_ACCOUNT_CONTAINER} -o allow_other
7
+
8
+ # run the command passed to us
9
+ #exec "uvicorn main:app --host 0.0.0.0 --port 5000"
requirements.txt ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ dash==2.13.0
2
+ dash_callback_chain==0.0.2
3
+ numpy==1.24.4
4
+ pandas==2.1.0
5
+ plotly==5.16.1
6
+ pyarrow==13.0.0
7
+ polars==0.19.2
8
+ PyYAML==6.0.1
9
+ scanpy==1.9.4
10
+ umap_learn==0.5.3
11
+ fastapi==0.74.*
12
+ uvicorn[standard]==0.17.*