sclab 0.1.7__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 (30) hide show
  1. sclab-0.1.7/PKG-INFO +139 -0
  2. sclab-0.1.7/README.md +107 -0
  3. sclab-0.1.7/pyproject.toml +56 -0
  4. sclab-0.1.7/src/sclab/__init__.py +7 -0
  5. sclab-0.1.7/src/sclab/_io.py +32 -0
  6. sclab-0.1.7/src/sclab/_sclab.py +80 -0
  7. sclab-0.1.7/src/sclab/dataset/__init__.py +8 -0
  8. sclab-0.1.7/src/sclab/dataset/_dataset.py +398 -0
  9. sclab-0.1.7/src/sclab/dataset/_exceptions.py +2 -0
  10. sclab-0.1.7/src/sclab/dataset/plotter/__init__.py +7 -0
  11. sclab-0.1.7/src/sclab/dataset/plotter/_controls.py +594 -0
  12. sclab-0.1.7/src/sclab/dataset/plotter/_plotter.py +1017 -0
  13. sclab-0.1.7/src/sclab/dataset/plotter/_utils.py +437 -0
  14. sclab-0.1.7/src/sclab/dataset/processor/__init__.py +7 -0
  15. sclab-0.1.7/src/sclab/dataset/processor/_processor.py +1063 -0
  16. sclab-0.1.7/src/sclab/dataset/processor/step/__init__.py +7 -0
  17. sclab-0.1.7/src/sclab/dataset/processor/step/_basic_processor_step.py +109 -0
  18. sclab-0.1.7/src/sclab/dataset/processor/step/_processor_step_base.py +120 -0
  19. sclab-0.1.7/src/sclab/event/__init__.py +7 -0
  20. sclab-0.1.7/src/sclab/event/_broker.py +201 -0
  21. sclab-0.1.7/src/sclab/event/_client.py +81 -0
  22. sclab-0.1.7/src/sclab/event/_utils.py +14 -0
  23. sclab-0.1.7/src/sclab/examples/__init__.py +5 -0
  24. sclab-0.1.7/src/sclab/examples/processor_steps/__init__.py +15 -0
  25. sclab-0.1.7/src/sclab/examples/processor_steps/_cluster.py +37 -0
  26. sclab-0.1.7/src/sclab/examples/processor_steps/_neighbors.py +72 -0
  27. sclab-0.1.7/src/sclab/examples/processor_steps/_pca.py +124 -0
  28. sclab-0.1.7/src/sclab/examples/processor_steps/_preprocess.py +186 -0
  29. sclab-0.1.7/src/sclab/examples/processor_steps/_qc.py +93 -0
  30. sclab-0.1.7/src/sclab/examples/processor_steps/_umap.py +48 -0
sclab-0.1.7/PKG-INFO ADDED
@@ -0,0 +1,139 @@
1
+ Metadata-Version: 2.3
2
+ Name: sclab
3
+ Version: 0.1.7
4
+ Summary: sclab
5
+ Author-email: Argenis Arriojas <ArriojasMaldonado001@umb.edu>
6
+ Requires-Python: >=3.10,<3.13
7
+ Description-Content-Type: text/markdown
8
+ Classifier: License :: OSI Approved :: BSD License
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.10
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Requires-Dist: anndata
14
+ Requires-Dist: anywidget
15
+ Requires-Dist: ipywidgets
16
+ Requires-Dist: itables
17
+ Requires-Dist: numpy<2.2
18
+ Requires-Dist: pandas
19
+ Requires-Dist: plotly
20
+ Requires-Dist: scanpy
21
+ Requires-Dist: scikit-learn
22
+ Requires-Dist: scikit-misc
23
+ Requires-Dist: svgpathtools
24
+ Requires-Dist: pytest>=8.3.4 ; extra == "test"
25
+ Project-URL: Bug Tracker, https://github.com/umbibio/sclab/issues
26
+ Project-URL: Changelog, https://github.com/umbibio/sclab/blob/main/CHANGELOG.md
27
+ Project-URL: Documentation, https://github.com/umbibio/sclab/docs
28
+ Project-URL: Homepage, https://github.com/umbibio/sclab
29
+ Project-URL: Repository, https://github.com/umbibio/sclab.git
30
+ Provides-Extra: test
31
+
32
+ # SCLab
33
+
34
+ SCLab is an interactive single-cell analysis toolkit that provides a seamless interface for analyzing and visualizing single-cell RNA sequencing data. Built on top of popular tools like scanpy and AnnData, SCLab offers an event-driven architecture for real-time updates and interactive visualizations.
35
+
36
+ ## Features
37
+
38
+ - **Interactive Data Analysis**: Built-in dashboard with real-time updates
39
+ - **Quality Control**: Comprehensive QC metrics and filtering capabilities
40
+ - **Preprocessing**: Normalization, log transformation, and scaling with progress tracking
41
+ - **Dimensionality Reduction**: PCA with batch effect correction support
42
+ - **Visualization**: Interactive plots and tables using plotly and itables
43
+ - **Event System**: Robust event-driven architecture for real-time updates
44
+
45
+ ## Installation
46
+
47
+ ```bash
48
+ pip install sclab
49
+ ```
50
+
51
+ ## Quick Start
52
+
53
+ Open a Jupyter Notebook and run the following:
54
+
55
+ ```python
56
+ from sclab import SCLabDashboard
57
+ import scanpy as sc
58
+ from IPython.display import display
59
+
60
+ # Load your data
61
+ adata = sc.read_10x_h5("your_data.h5")
62
+
63
+ # Create dashboard
64
+ dashboard = SCLabDashboard(adata, name="My Analysis")
65
+
66
+ # Display dashboard
67
+ display(dashboard)
68
+
69
+ # The dashboard provides easy access to components:
70
+ dashboard.ds # Dataset (wrapper for AnnData)
71
+ dashboard.pl # Plotter
72
+ dashboard.pr # Processor
73
+ ```
74
+
75
+ ## Components
76
+
77
+ ### SCLabDashboard
78
+
79
+ The main interface that integrates all components with a tabbed layout:
80
+ - Main graph for visualizations
81
+ - Observations table
82
+ - Genes table
83
+ - Event logs
84
+
85
+ ### Dataset
86
+
87
+ Handles data management with:
88
+ - AnnData integration
89
+ - Interactive tables
90
+ - Row selection and filtering
91
+ - Metadata handling
92
+
93
+ ### Processor
94
+
95
+ Handles data processing steps. It is configurable with custom steps implementing the `ProcessorStepBase` interface. This package provides multiple examples of steps:
96
+
97
+ - QC
98
+ - Preprocessing
99
+ - PCA
100
+ - Nearest Neighbors
101
+ - UMAP
102
+ - Clustering
103
+
104
+ ### Plotter
105
+
106
+ Provides interactive visualizations with:
107
+ - Real-time updates
108
+ - Customizable plots
109
+ - Batch effect visualization
110
+ - Export capabilities
111
+
112
+ ## Requirements
113
+
114
+ - Python ≥ 3.12
115
+ - anndata ≥ 0.11.3
116
+ - scanpy ≥ 1.10.4
117
+ - Other dependencies listed in pyproject.toml
118
+
119
+ ## Contributing
120
+
121
+ Contributions are welcome! Please feel free to submit a Pull Request.
122
+
123
+ ## License
124
+
125
+ This project is licensed under the BSD 3-Clause License - see the [LICENSE](LICENSE) file for details.
126
+
127
+ ## Citation
128
+
129
+ If you use SCLab in your research, please cite:
130
+
131
+ ```bibtex
132
+ @software{sclab2024,
133
+ author = {Arriojas, Argenis},
134
+ title = {SCLab: Interactive Single-Cell Analysis Toolkit},
135
+ year = {2024},
136
+ publisher = {GitHub},
137
+ url = {https://github.com/umbibio/sclab}
138
+ }
139
+
sclab-0.1.7/README.md ADDED
@@ -0,0 +1,107 @@
1
+ # SCLab
2
+
3
+ SCLab is an interactive single-cell analysis toolkit that provides a seamless interface for analyzing and visualizing single-cell RNA sequencing data. Built on top of popular tools like scanpy and AnnData, SCLab offers an event-driven architecture for real-time updates and interactive visualizations.
4
+
5
+ ## Features
6
+
7
+ - **Interactive Data Analysis**: Built-in dashboard with real-time updates
8
+ - **Quality Control**: Comprehensive QC metrics and filtering capabilities
9
+ - **Preprocessing**: Normalization, log transformation, and scaling with progress tracking
10
+ - **Dimensionality Reduction**: PCA with batch effect correction support
11
+ - **Visualization**: Interactive plots and tables using plotly and itables
12
+ - **Event System**: Robust event-driven architecture for real-time updates
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ pip install sclab
18
+ ```
19
+
20
+ ## Quick Start
21
+
22
+ Open a Jupyter Notebook and run the following:
23
+
24
+ ```python
25
+ from sclab import SCLabDashboard
26
+ import scanpy as sc
27
+ from IPython.display import display
28
+
29
+ # Load your data
30
+ adata = sc.read_10x_h5("your_data.h5")
31
+
32
+ # Create dashboard
33
+ dashboard = SCLabDashboard(adata, name="My Analysis")
34
+
35
+ # Display dashboard
36
+ display(dashboard)
37
+
38
+ # The dashboard provides easy access to components:
39
+ dashboard.ds # Dataset (wrapper for AnnData)
40
+ dashboard.pl # Plotter
41
+ dashboard.pr # Processor
42
+ ```
43
+
44
+ ## Components
45
+
46
+ ### SCLabDashboard
47
+
48
+ The main interface that integrates all components with a tabbed layout:
49
+ - Main graph for visualizations
50
+ - Observations table
51
+ - Genes table
52
+ - Event logs
53
+
54
+ ### Dataset
55
+
56
+ Handles data management with:
57
+ - AnnData integration
58
+ - Interactive tables
59
+ - Row selection and filtering
60
+ - Metadata handling
61
+
62
+ ### Processor
63
+
64
+ Handles data processing steps. It is configurable with custom steps implementing the `ProcessorStepBase` interface. This package provides multiple examples of steps:
65
+
66
+ - QC
67
+ - Preprocessing
68
+ - PCA
69
+ - Nearest Neighbors
70
+ - UMAP
71
+ - Clustering
72
+
73
+ ### Plotter
74
+
75
+ Provides interactive visualizations with:
76
+ - Real-time updates
77
+ - Customizable plots
78
+ - Batch effect visualization
79
+ - Export capabilities
80
+
81
+ ## Requirements
82
+
83
+ - Python ≥ 3.12
84
+ - anndata ≥ 0.11.3
85
+ - scanpy ≥ 1.10.4
86
+ - Other dependencies listed in pyproject.toml
87
+
88
+ ## Contributing
89
+
90
+ Contributions are welcome! Please feel free to submit a Pull Request.
91
+
92
+ ## License
93
+
94
+ This project is licensed under the BSD 3-Clause License - see the [LICENSE](LICENSE) file for details.
95
+
96
+ ## Citation
97
+
98
+ If you use SCLab in your research, please cite:
99
+
100
+ ```bibtex
101
+ @software{sclab2024,
102
+ author = {Arriojas, Argenis},
103
+ title = {SCLab: Interactive Single-Cell Analysis Toolkit},
104
+ year = {2024},
105
+ publisher = {GitHub},
106
+ url = {https://github.com/umbibio/sclab}
107
+ }
@@ -0,0 +1,56 @@
1
+ [project]
2
+ name = "sclab"
3
+ version = "0.1.7"
4
+ description = "sclab"
5
+ readme = "README.md"
6
+ authors = [
7
+ { name = "Argenis Arriojas", email = "ArriojasMaldonado001@umb.edu" },
8
+ ]
9
+ requires-python = ">=3.10,<3.13"
10
+ classifiers = [
11
+ "License :: OSI Approved :: BSD License",
12
+ "Programming Language :: Python :: 3",
13
+ "Programming Language :: Python :: 3.10",
14
+ "Programming Language :: Python :: 3.11",
15
+ "Programming Language :: Python :: 3.12",
16
+ ]
17
+ dependencies = [
18
+ "anndata",
19
+ "anywidget",
20
+ "ipywidgets",
21
+ "itables",
22
+ "numpy<2.2",
23
+ "pandas",
24
+ "plotly",
25
+ "scanpy",
26
+ "scikit-learn",
27
+ "scikit-misc",
28
+ "svgpathtools",
29
+ ]
30
+
31
+ [project.urls]
32
+ "Repository" = "https://github.com/umbibio/sclab.git"
33
+ "Documentation" = "https://github.com/umbibio/sclab/docs"
34
+ "Homepage" = "https://github.com/umbibio/sclab"
35
+ "Bug Tracker" = "https://github.com/umbibio/sclab/issues"
36
+ "Changelog" = "https://github.com/umbibio/sclab/blob/main/CHANGELOG.md"
37
+
38
+ [project.optional-dependencies]
39
+ test = ["pytest>=8.3.4"]
40
+
41
+ [build-system]
42
+ requires = ["flit_core>=3.2,<4"]
43
+ build-backend = "flit_core.buildapi"
44
+
45
+ [tool.flit.module]
46
+ name = "sclab"
47
+ source = "src/sclab"
48
+
49
+ [dependency-groups]
50
+ dev = [
51
+ "bump-my-version>=0.31.1",
52
+ "pre-commit>=4.1.0",
53
+ "ruff>=0.9.4",
54
+ "nox>=2024.1.29",
55
+ "pytest>=8.3.4",
56
+ ]
@@ -0,0 +1,7 @@
1
+ from ._sclab import SCLabDashboard
2
+
3
+ __all__ = [
4
+ "SCLabDashboard",
5
+ ]
6
+
7
+ __version__ = "0.1.7"
@@ -0,0 +1,32 @@
1
+ from pathlib import Path
2
+
3
+ import anndata as ad
4
+
5
+
6
+ def read_adata(path: str | Path, var_names: str = "gene_ids") -> ad.AnnData:
7
+ path = Path(path)
8
+
9
+ match path.suffix:
10
+ case ".h5" | "":
11
+ try:
12
+ import scanpy as sc
13
+ except ImportError:
14
+ raise ImportError("Please install scanpy: `pip install scanpy`")
15
+
16
+ match path.suffix:
17
+ case ".h5":
18
+ adata = sc.read_10x_h5(path)
19
+ case ".h5ad":
20
+ adata = ad.read_h5ad(path)
21
+ case "":
22
+ assert path.is_dir()
23
+ adata = sc.read_10x_mtx(path)
24
+ case _:
25
+ raise ValueError(
26
+ "Input file must be a 10x h5, h5ad or a folder of 10x mtx files"
27
+ )
28
+
29
+ if var_names in adata.var:
30
+ adata.var = adata.var.set_index(var_names)
31
+
32
+ return adata
@@ -0,0 +1,80 @@
1
+ from pathlib import Path
2
+
3
+ from anndata import AnnData
4
+ from ipywidgets.widgets import GridBox, Layout, Tab
5
+
6
+ from ._io import read_adata
7
+ from .dataset import SCLabDataset
8
+ from .dataset.plotter import Plotter
9
+ from .dataset.processor import Processor
10
+ from .event import EventBroker
11
+
12
+
13
+ class SCLabDashboard(GridBox):
14
+ broker: EventBroker
15
+
16
+ def __init__(
17
+ self,
18
+ adata: AnnData | None = None,
19
+ filepath: str | Path | None = None,
20
+ name: str = "SCLab Dashboard",
21
+ counts_layer: str = "counts",
22
+ batch_key: str | None = None,
23
+ copy: bool = True,
24
+ ):
25
+ if adata is None and filepath is None:
26
+ raise ValueError("Either adata or filepath must be provided")
27
+
28
+ if adata is None:
29
+ adata = read_adata(filepath)
30
+
31
+ self.broker = EventBroker()
32
+ self.dataset = SCLabDataset(
33
+ adata, name=name, counts_layer=counts_layer, copy=copy, broker=self.broker
34
+ )
35
+ self.plotter = Plotter(self.dataset)
36
+ self.processor = Processor(
37
+ self.dataset,
38
+ self.plotter,
39
+ batch_key=batch_key,
40
+ )
41
+
42
+ self.main_content = Tab(
43
+ children=[
44
+ self.plotter,
45
+ self.dataset.obs_table,
46
+ self.dataset.var_table,
47
+ self.broker.logs_tab,
48
+ ],
49
+ titles=[
50
+ "Main graph",
51
+ "Observations",
52
+ "Genes",
53
+ "Logs",
54
+ ],
55
+ )
56
+
57
+ super().__init__(
58
+ [
59
+ self.processor.main_accordion,
60
+ self.main_content,
61
+ ],
62
+ layout=Layout(
63
+ width="100%",
64
+ grid_template_columns="350px auto",
65
+ grid_template_areas=""" "processor plotter" """,
66
+ border="0px solid black",
67
+ ),
68
+ )
69
+
70
+ @property
71
+ def ds(self):
72
+ return self.dataset
73
+
74
+ @property
75
+ def pr(self):
76
+ return self.processor
77
+
78
+ @property
79
+ def pl(self):
80
+ return self.plotter
@@ -0,0 +1,8 @@
1
+ from . import plotter, processor
2
+ from ._dataset import SCLabDataset
3
+
4
+ __all__ = [
5
+ "plotter",
6
+ "processor",
7
+ "SCLabDataset",
8
+ ]