sclab 0.1.8__tar.gz → 0.2.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of sclab might be problematic. Click here for more details.

Files changed (44) hide show
  1. sclab-0.2.3/LICENSE +29 -0
  2. {sclab-0.1.8 → sclab-0.2.3}/PKG-INFO +9 -4
  3. {sclab-0.1.8 → sclab-0.2.3}/pyproject.toml +7 -3
  4. {sclab-0.1.8 → sclab-0.2.3}/src/sclab/__init__.py +3 -1
  5. sclab-0.2.3/src/sclab/_io.py +109 -0
  6. sclab-0.2.3/src/sclab/_methods_registry.py +65 -0
  7. sclab-0.2.3/src/sclab/_sclab.py +288 -0
  8. {sclab-0.1.8 → sclab-0.2.3}/src/sclab/dataset/_dataset.py +2 -4
  9. {sclab-0.1.8 → sclab-0.2.3}/src/sclab/dataset/processor/_processor.py +22 -15
  10. sclab-0.2.3/src/sclab/dataset/processor/_results_panel.py +80 -0
  11. {sclab-0.1.8 → sclab-0.2.3}/src/sclab/dataset/processor/step/_processor_step_base.py +12 -6
  12. {sclab-0.1.8 → sclab-0.2.3}/src/sclab/examples/processor_steps/__init__.py +2 -0
  13. {sclab-0.1.8 → sclab-0.2.3}/src/sclab/examples/processor_steps/_cluster.py +2 -2
  14. sclab-0.2.3/src/sclab/examples/processor_steps/_differential_expression.py +328 -0
  15. {sclab-0.1.8 → sclab-0.2.3}/src/sclab/examples/processor_steps/_neighbors.py +2 -2
  16. {sclab-0.1.8 → sclab-0.2.3}/src/sclab/examples/processor_steps/_pca.py +2 -2
  17. {sclab-0.1.8 → sclab-0.2.3}/src/sclab/examples/processor_steps/_preprocess.py +2 -2
  18. {sclab-0.1.8 → sclab-0.2.3}/src/sclab/examples/processor_steps/_qc.py +2 -2
  19. {sclab-0.1.8 → sclab-0.2.3}/src/sclab/examples/processor_steps/_umap.py +2 -2
  20. sclab-0.2.3/src/sclab/methods/__init__.py +28 -0
  21. sclab-0.2.3/src/sclab/scanpy/_compat.py +92 -0
  22. sclab-0.2.3/src/sclab/scanpy/_settings.py +526 -0
  23. sclab-0.2.3/src/sclab/scanpy/logging.py +290 -0
  24. sclab-0.2.3/src/sclab/scanpy/plotting/__init__.py +0 -0
  25. sclab-0.2.3/src/sclab/scanpy/plotting/_rcmod.py +73 -0
  26. sclab-0.2.3/src/sclab/scanpy/plotting/palettes.py +221 -0
  27. sclab-0.2.3/src/sclab/scanpy/readwrite.py +1108 -0
  28. sclab-0.1.8/src/sclab/_io.py +0 -32
  29. sclab-0.1.8/src/sclab/_sclab.py +0 -80
  30. {sclab-0.1.8 → sclab-0.2.3}/README.md +0 -0
  31. {sclab-0.1.8 → sclab-0.2.3}/src/sclab/dataset/__init__.py +0 -0
  32. {sclab-0.1.8 → sclab-0.2.3}/src/sclab/dataset/_exceptions.py +0 -0
  33. {sclab-0.1.8 → sclab-0.2.3}/src/sclab/dataset/plotter/__init__.py +0 -0
  34. {sclab-0.1.8 → sclab-0.2.3}/src/sclab/dataset/plotter/_controls.py +0 -0
  35. {sclab-0.1.8 → sclab-0.2.3}/src/sclab/dataset/plotter/_plotter.py +0 -0
  36. {sclab-0.1.8 → sclab-0.2.3}/src/sclab/dataset/plotter/_utils.py +0 -0
  37. {sclab-0.1.8 → sclab-0.2.3}/src/sclab/dataset/processor/__init__.py +0 -0
  38. {sclab-0.1.8 → sclab-0.2.3}/src/sclab/dataset/processor/step/__init__.py +0 -0
  39. {sclab-0.1.8 → sclab-0.2.3}/src/sclab/dataset/processor/step/_basic_processor_step.py +0 -0
  40. {sclab-0.1.8 → sclab-0.2.3}/src/sclab/event/__init__.py +0 -0
  41. {sclab-0.1.8 → sclab-0.2.3}/src/sclab/event/_broker.py +0 -0
  42. {sclab-0.1.8 → sclab-0.2.3}/src/sclab/event/_client.py +0 -0
  43. {sclab-0.1.8 → sclab-0.2.3}/src/sclab/event/_utils.py +0 -0
  44. {sclab-0.1.8 → sclab-0.2.3}/src/sclab/examples/__init__.py +0 -0
sclab-0.2.3/LICENSE ADDED
@@ -0,0 +1,29 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2025 Argenis Arriojas
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ 1. Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ 2. Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ 3. Neither the name of the copyright holder nor the names of its
17
+ contributors may be used to endorse or promote products derived from
18
+ this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: sclab
3
- Version: 0.1.8
3
+ Version: 0.2.3
4
4
  Summary: sclab
5
5
  Author-email: Argenis Arriojas <ArriojasMaldonado001@umb.edu>
6
6
  Requires-Python: >=3.10,<3.13
@@ -10,6 +10,7 @@ Classifier: Programming Language :: Python :: 3
10
10
  Classifier: Programming Language :: Python :: 3.10
11
11
  Classifier: Programming Language :: Python :: 3.11
12
12
  Classifier: Programming Language :: Python :: 3.12
13
+ License-File: LICENSE
13
14
  Requires-Dist: anndata
14
15
  Requires-Dist: anywidget
15
16
  Requires-Dist: ipywidgets
@@ -17,16 +18,20 @@ Requires-Dist: itables
17
18
  Requires-Dist: numpy<2.2
18
19
  Requires-Dist: pandas
19
20
  Requires-Dist: plotly<6.0
20
- Requires-Dist: scanpy
21
+ Requires-Dist: requests
21
22
  Requires-Dist: scikit-learn
22
- Requires-Dist: scikit-misc
23
23
  Requires-Dist: svgpathtools
24
+ Requires-Dist: tqdm
25
+ Requires-Dist: jupyterlab>=4.3.6 ; extra == "jupyter"
26
+ Requires-Dist: scanpy[leiden, skmisc]>=1.10 ; extra == "scanpy"
24
27
  Requires-Dist: pytest>=8.3.4 ; extra == "test"
25
28
  Project-URL: Bug Tracker, https://github.com/umbibio/sclab/issues
26
29
  Project-URL: Changelog, https://github.com/umbibio/sclab/blob/main/CHANGELOG.md
27
30
  Project-URL: Documentation, https://github.com/umbibio/sclab/docs
28
31
  Project-URL: Homepage, https://github.com/umbibio/sclab
29
32
  Project-URL: Repository, https://github.com/umbibio/sclab.git
33
+ Provides-Extra: jupyter
34
+ Provides-Extra: scanpy
30
35
  Provides-Extra: test
31
36
 
32
37
  # SCLab
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "sclab"
3
- version = "0.1.8"
3
+ version = "0.2.3"
4
4
  description = "sclab"
5
5
  readme = "README.md"
6
6
  authors = [
@@ -22,10 +22,10 @@ dependencies = [
22
22
  "numpy<2.2",
23
23
  "pandas",
24
24
  "plotly<6.0",
25
- "scanpy",
25
+ "requests",
26
26
  "scikit-learn",
27
- "scikit-misc",
28
27
  "svgpathtools",
28
+ "tqdm",
29
29
  ]
30
30
 
31
31
  [project.urls]
@@ -37,6 +37,8 @@ dependencies = [
37
37
 
38
38
  [project.optional-dependencies]
39
39
  test = ["pytest>=8.3.4"]
40
+ scanpy = ["scanpy[leiden,skmisc]>=1.10"]
41
+ jupyter = ["jupyterlab>=4.3.6"]
40
42
 
41
43
  [build-system]
42
44
  requires = ["flit_core>=3.2,<4"]
@@ -56,4 +58,6 @@ dev = [
56
58
  "mkdocs>=1.6.1",
57
59
  "mkdocs-material>=9.6.3",
58
60
  "mkdocs-jupyter>=0.25.1",
61
+ "scanpy[leiden]>=1.10.4",
62
+ "jupyterlab>=4.3.6",
59
63
  ]
@@ -1,7 +1,9 @@
1
+ from . import methods
1
2
  from ._sclab import SCLabDashboard
2
3
 
3
4
  __all__ = [
5
+ "methods",
4
6
  "SCLabDashboard",
5
7
  ]
6
8
 
7
- __version__ = "0.1.8"
9
+ __version__ = "0.2.3"
@@ -0,0 +1,109 @@
1
+ from io import BytesIO
2
+ from pathlib import Path
3
+ from urllib.parse import urlparse
4
+
5
+ import requests
6
+ from anndata import AnnData, read_h5ad
7
+ from tqdm.auto import tqdm
8
+
9
+
10
+ def read_adata(path: str | Path, var_names: str = "gene_ids") -> AnnData:
11
+ from .scanpy.readwrite import read_10x_h5, read_10x_mtx
12
+
13
+ path = Path(path)
14
+
15
+ match path.suffix:
16
+ case ".h5":
17
+ adata = read_10x_h5(path)
18
+ case ".h5ad":
19
+ adata = read_h5ad(path)
20
+ case "":
21
+ assert path.is_dir()
22
+ adata = read_10x_mtx(path)
23
+ case _:
24
+ raise ValueError(
25
+ "Input file must be a 10x h5, h5ad or a folder of 10x mtx files"
26
+ )
27
+
28
+ if var_names in adata.var:
29
+ adata.var = adata.var.set_index(var_names)
30
+
31
+ return adata
32
+
33
+
34
+ def load_adata_from_url(
35
+ url: str,
36
+ var_names: str = "gene_ids",
37
+ progress: bool = True,
38
+ ) -> AnnData:
39
+ """
40
+ Load an AnnData object from a URL to an .h5ad file.
41
+
42
+ Parameters:
43
+ -----------
44
+ url : str
45
+ URL to the .h5ad file
46
+ var_names : str
47
+ Name of the variable column in the .h5ad file
48
+ progress : bool
49
+ Whether to show a progress bar
50
+
51
+ Returns:
52
+ --------
53
+ anndata.AnnData
54
+ Loaded AnnData object
55
+ """
56
+ from .scanpy.readwrite import read_10x_h5
57
+
58
+ assert is_valid_url(url), "URL is not valid"
59
+ url_path = Path(urlparse(url).path)
60
+
61
+ if url_path.suffix == ".h5":
62
+ try:
63
+ import scanpy as sc
64
+ except ImportError:
65
+ raise ImportError("Please install scanpy: `pip install scanpy`")
66
+
67
+ file_content = fetch_file(url, progress=progress)
68
+ match url_path.suffix:
69
+ case ".h5":
70
+ adata = read_10x_h5(file_content)
71
+ case ".h5ad":
72
+ adata = read_h5ad(file_content)
73
+ case _:
74
+ raise ValueError("Input file must be a 10x h5 or h5ad file")
75
+
76
+ if var_names in adata.var:
77
+ adata.var = adata.var.set_index(var_names)
78
+
79
+ return adata
80
+
81
+
82
+ def fetch_file(url: str, progress: bool = True) -> BytesIO:
83
+ response = requests.get(url, stream=True)
84
+ response.raise_for_status()
85
+
86
+ total_size_in_bytes = int(response.headers.get("content-length", 0))
87
+ block_size = 1024 # 1 Kibibyte
88
+
89
+ if progress:
90
+ progress_bar = tqdm(total=total_size_in_bytes, unit="iB", unit_scale=True)
91
+
92
+ result = BytesIO()
93
+ for data in response.iter_content(block_size):
94
+ result.write(data)
95
+ if progress:
96
+ progress_bar.update(len(data))
97
+
98
+ if progress:
99
+ progress_bar.close()
100
+
101
+ return result
102
+
103
+
104
+ def is_valid_url(url: str) -> bool:
105
+ if not isinstance(url, str):
106
+ return False
107
+
108
+ result = urlparse(url)
109
+ return all([result.scheme, result.netloc])
@@ -0,0 +1,65 @@
1
+ from typing import Callable, Type
2
+
3
+
4
+ # full class definition is in .dataset/processor/step/_processor_step_base.py
5
+ class ProcessorStepBase:
6
+ name: str
7
+ description: str
8
+
9
+
10
+ methods_registry: dict[str, list[ProcessorStepBase]] = {}
11
+
12
+
13
+ def register_sclab_method(
14
+ category: str,
15
+ name: str | None = None,
16
+ description: str | None = None,
17
+ order: int | None = None,
18
+ ) -> Callable:
19
+ """
20
+ Decorator to register a class as a sclab method.
21
+
22
+ Args:
23
+ category: The category to register the method under (e.g., "Processing")
24
+ name: Optional display name for the method. If None, uses the class name.
25
+ description: Optional description of the method.
26
+ order: Optional ordering within the category. Lower numbers appear first.
27
+
28
+ Returns:
29
+ Decorated class
30
+ """
31
+
32
+ def decorator(cls: Type[ProcessorStepBase]) -> Type[ProcessorStepBase]:
33
+ if name:
34
+ cls.name = name
35
+
36
+ if description:
37
+ cls.description = description
38
+
39
+ if order is not None:
40
+ cls.order = order
41
+
42
+ # Initialize the category in the registry if it doesn't exist
43
+ if category not in methods_registry:
44
+ methods_registry[category] = []
45
+
46
+ methods_list = methods_registry[category]
47
+
48
+ # Add the class to the registry
49
+ methods_list.append(cls)
50
+
51
+ # Sort the methods by order
52
+ methods_registry[category] = sorted(methods_list, key=lambda x: x.order)
53
+
54
+ return cls
55
+
56
+ return decorator
57
+
58
+
59
+ def get_sclab_methods():
60
+ methods = {}
61
+
62
+ for category, methods_list in methods_registry.items():
63
+ methods[category] = sorted(methods_list, key=lambda x: x.order)
64
+
65
+ return methods
@@ -0,0 +1,288 @@
1
+ import inspect
2
+ from io import BytesIO
3
+ from pathlib import Path
4
+
5
+ from anndata import AnnData
6
+ from IPython.display import display
7
+ from ipywidgets.widgets import (
8
+ Button,
9
+ FileUpload,
10
+ GridBox,
11
+ HBox,
12
+ Label,
13
+ Layout,
14
+ Output,
15
+ Tab,
16
+ Text,
17
+ ToggleButtons,
18
+ VBox,
19
+ )
20
+
21
+ from ._io import is_valid_url, load_adata_from_url, read_adata
22
+ from .dataset import SCLabDataset
23
+ from .dataset.plotter import Plotter
24
+ from .dataset.processor import Processor
25
+ from .event import EventBroker
26
+
27
+
28
+ class SCLabDashboard(GridBox):
29
+ broker: EventBroker
30
+ dataset: SCLabDataset
31
+ plotter: Plotter
32
+ processor: Processor
33
+ main_content: Tab
34
+
35
+ def __init__(
36
+ self,
37
+ adata_or_filepath_or_url: AnnData | str | None = None,
38
+ name: str = "SCLab Dashboard",
39
+ counts_layer: str = "counts",
40
+ batch_key: str | None = None,
41
+ copy: bool = False,
42
+ ):
43
+ if adata_or_filepath_or_url is None:
44
+ adata = None
45
+
46
+ elif isinstance(adata_or_filepath_or_url, AnnData):
47
+ adata = adata_or_filepath_or_url
48
+
49
+ elif is_valid_url(adata_or_filepath_or_url):
50
+ url = adata_or_filepath_or_url
51
+ adata = load_adata_from_url(url)
52
+
53
+ elif isinstance(adata_or_filepath_or_url, str):
54
+ filepath = adata_or_filepath_or_url
55
+ adata = read_adata(filepath)
56
+
57
+ self.name = name
58
+ self.counts_layer = counts_layer
59
+ self.batch_key = batch_key
60
+
61
+ self.broker = EventBroker()
62
+
63
+ self.dataset = None
64
+ self.plotter = None
65
+ self.processor = None
66
+ self.main_content = None
67
+
68
+ self.data_loader_layout = Layout(
69
+ width="100%",
70
+ height="500px",
71
+ grid_template_columns="auto",
72
+ grid_template_areas=""" "data_loader" """,
73
+ border="0px solid black",
74
+ )
75
+
76
+ self.dashboard_layout = Layout(
77
+ width="100%",
78
+ height="100%",
79
+ grid_template_columns="350px auto",
80
+ grid_template_areas=""" "processor plotter" """,
81
+ border="0px solid black",
82
+ )
83
+
84
+ self.data_loader = DataLoader(self)
85
+
86
+ GridBox.__init__(self)
87
+ if adata is not None:
88
+ self._load(adata, copy=copy)
89
+ else:
90
+ self.children = (self.data_loader,)
91
+ self.layout = self.data_loader_layout
92
+
93
+ def _load(self, adata: AnnData, copy: bool = False):
94
+ self.dataset = SCLabDataset(
95
+ adata,
96
+ name=self.name,
97
+ counts_layer=self.counts_layer,
98
+ copy=copy,
99
+ broker=self.broker,
100
+ )
101
+ self.plotter = Plotter(self.dataset)
102
+ self.processor = Processor(
103
+ self.dataset,
104
+ self.plotter,
105
+ batch_key=self.batch_key,
106
+ )
107
+
108
+ self.main_content = Tab(
109
+ children=[
110
+ self.plotter,
111
+ self.processor.results_panel,
112
+ self.dataset.obs_table,
113
+ self.dataset.var_table,
114
+ self.broker.logs_tab,
115
+ ],
116
+ titles=[
117
+ "Main graph",
118
+ "Results",
119
+ "Observations",
120
+ "Genes",
121
+ "Logs",
122
+ ],
123
+ )
124
+
125
+ self.children = (
126
+ self.processor.main_accordion,
127
+ self.main_content,
128
+ )
129
+ self.layout = self.dashboard_layout
130
+
131
+ @property
132
+ def ds(self):
133
+ return self.dataset
134
+
135
+ @property
136
+ def pr(self):
137
+ return self.processor
138
+
139
+ @property
140
+ def pl(self):
141
+ return self.plotter
142
+
143
+
144
+ class DataLoader(VBox):
145
+ dashboard: SCLabDashboard
146
+ adata: AnnData
147
+
148
+ upload: FileUpload
149
+ upload_info: Output
150
+ upload_row: HBox
151
+ upload_row_label: Label
152
+
153
+ url: Text
154
+ load_button: Button
155
+ url_row: HBox
156
+ url_row_label: Label
157
+
158
+ defined_adatas_dict: dict[str, AnnData]
159
+ defined_adatas: ToggleButtons
160
+ defined_adatas_row: HBox
161
+ defined_adatas_label: Label
162
+
163
+ progress_output: Output
164
+ continue_button: Button
165
+
166
+ def __init__(self, dashboard: SCLabDashboard):
167
+ self.dashboard = dashboard
168
+
169
+ self.upload_row_label = Label("Load from file:", layout=Layout(width="120px"))
170
+ self.upload = FileUpload(layout=Layout(width="200px"))
171
+ self.upload_info = Output(layout=Layout(width="95%"))
172
+ self.upload_row = HBox(
173
+ [self.upload_row_label, self.upload, self.upload_info],
174
+ layout=Layout(width="100%"),
175
+ )
176
+ self.upload.observe(self.on_upload, "value")
177
+
178
+ self.url_row_label = Label("Load from URL:", layout=Layout(width="120px"))
179
+ self.url = Text(placeholder="https://...", layout=Layout(width="100%"))
180
+ self.load_button = Button(description="Load", layout=Layout(width="200px"))
181
+ self.url_row = HBox(
182
+ [self.url_row_label, self.url, self.load_button],
183
+ layout=Layout(width="100%"),
184
+ )
185
+ self.load_button.on_click(self.on_load_url)
186
+
187
+ user_f_locals = inspect.stack()[2].frame.f_locals
188
+ self.defined_adatas_dict = {}
189
+ for name, variable_type in [(k, type(v)) for k, v in user_f_locals.items()]:
190
+ if variable_type is AnnData:
191
+ self.defined_adatas_dict[name] = user_f_locals[name]
192
+
193
+ self.defined_adatas_label = Label(
194
+ "Defined datasets:", layout=Layout(width="120px")
195
+ )
196
+ self.defined_adatas = ToggleButtons(
197
+ options=list(self.defined_adatas_dict.keys()),
198
+ value=None,
199
+ layout=Layout(width="100%"),
200
+ )
201
+ self.defined_adatas_row = HBox(
202
+ [self.defined_adatas_label, self.defined_adatas],
203
+ layout=Layout(width="100%"),
204
+ )
205
+ self.defined_adatas.observe(self.on_defined_adatas_toggle, "value")
206
+
207
+ self.progress_output = Output(layout=Layout(width="95%"))
208
+ self.continue_button = Button(
209
+ description="Continue", layout=Layout(width="100%"), button_style="success"
210
+ )
211
+ self.continue_button.on_click(self.on_continue)
212
+
213
+ VBox.__init__(
214
+ self,
215
+ [
216
+ self.url_row,
217
+ self.upload_row,
218
+ self.defined_adatas_row,
219
+ self.progress_output,
220
+ ],
221
+ layout=Layout(width="100%"),
222
+ )
223
+
224
+ def on_defined_adatas_toggle(self, *args, **kwargs):
225
+ adata = self.defined_adatas_dict[self.defined_adatas.value]
226
+
227
+ self.progress_output.clear_output()
228
+ with self.progress_output:
229
+ print(f"Loaded {adata.shape[0]} observations and {adata.shape[1]} genes\n")
230
+ print(adata)
231
+ display(self.continue_button)
232
+
233
+ self.adata = adata
234
+
235
+ def on_upload(self, *args, **kwargs):
236
+ from .scanpy.readwrite import read_10x_h5, read_h5ad
237
+
238
+ files = self.upload.value
239
+ if len(files) == 0:
240
+ return
241
+
242
+ file = files[0]
243
+
244
+ self.upload_info.clear_output()
245
+ with self.upload_info:
246
+ for k, v in file.items():
247
+ if k == "content":
248
+ continue
249
+ print(f"{k}: {v}")
250
+
251
+ filename = file["name"]
252
+ contents = BytesIO(file["content"].tobytes())
253
+ var_names = "gene_ids"
254
+
255
+ path = Path(filename)
256
+
257
+ match path.suffix:
258
+ case ".h5":
259
+ adata = read_10x_h5(contents)
260
+ case ".h5ad":
261
+ adata = read_h5ad(contents)
262
+ case _:
263
+ self.upload_info.clear_output()
264
+ with self.upload_info:
265
+ print(f"`{filename}` is not valid")
266
+ print("Please upload a 10x h5 or h5ad file")
267
+ return
268
+
269
+ if var_names in adata.var:
270
+ adata.var = adata.var.set_index(var_names)
271
+
272
+ with self.progress_output:
273
+ print(f"Loaded {adata.shape[0]} observations and {adata.shape[1]} genes\n")
274
+ print(adata)
275
+ display(self.continue_button)
276
+
277
+ self.adata = adata
278
+
279
+ def on_load_url(self, *args, **kwargs):
280
+ self.progress_output.clear_output()
281
+ with self.progress_output:
282
+ self.adata = load_adata_from_url(self.url.value)
283
+ display(self.continue_button)
284
+
285
+ def on_continue(self, *args, **kwargs):
286
+ self.dashboard._load(self.adata)
287
+ self.adata = None
288
+ self.defined_adatas_dict = {}
@@ -120,7 +120,6 @@ class SCLabDataset(EventClient):
120
120
  },
121
121
  "copyHtml5",
122
122
  {"extend": "csvHtml5", "title": f"{self.name}_cells"},
123
- {"extend": "excelHtml5", "title": f"{self.name}_cells"},
124
123
  ],
125
124
  columnDefs=[
126
125
  {"visible": True, "targets": [0]},
@@ -128,7 +127,7 @@ class SCLabDataset(EventClient):
128
127
  ],
129
128
  style="width:100%",
130
129
  classes="display cell-border",
131
- stateSave=True,
130
+ stateSave=False,
132
131
  )
133
132
 
134
133
  def update_var_table(incoming_change: pd.DataFrame | dict, *args, **kvargs):
@@ -154,7 +153,6 @@ class SCLabDataset(EventClient):
154
153
  },
155
154
  "copyHtml5",
156
155
  {"extend": "csvHtml5", "title": f"{self.name}_genes"},
157
- {"extend": "excelHtml5", "title": f"{self.name}_genes"},
158
156
  ],
159
157
  columnDefs=[
160
158
  {"visible": True, "targets": [0]},
@@ -162,7 +160,7 @@ class SCLabDataset(EventClient):
162
160
  ],
163
161
  style="width:100%",
164
162
  classes="display cell-border",
165
- stateSave=True,
163
+ stateSave=False,
166
164
  )
167
165
 
168
166
  update_obs_table(self.adata.obs)