StripeSankey 0.1.0__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.
Files changed (61) hide show
  1. stripesankey-0.1.0/LICENSE +21 -0
  2. stripesankey-0.1.0/PKG-INFO +262 -0
  3. stripesankey-0.1.0/README.md +200 -0
  4. stripesankey-0.1.0/StripeSankey/__init__.py +4 -0
  5. stripesankey-0.1.0/StripeSankey/widget.py +1218 -0
  6. stripesankey-0.1.0/__marimo__/session/__init__.py.json +14 -0
  7. stripesankey-0.1.0/__marimo__/session/widget.py.json +14 -0
  8. stripesankey-0.1.0/design_process/.gitignore +4 -0
  9. stripesankey-0.1.0/design_process/__marimo__/session/prototype1(Circular_Histogram|Similarity).py.json +301 -0
  10. stripesankey-0.1.0/design_process/__marimo__/session/prototype1(RecotangNode|Similarity).py.json +301 -0
  11. stripesankey-0.1.0/design_process/__marimo__/session/prototype1(RectangleNode|Similarity).py.json +301 -0
  12. stripesankey-0.1.0/design_process/data/prototype1/ASVProbabilities/ASVProbabilities_10.csv +11 -0
  13. stripesankey-0.1.0/design_process/data/prototype1/ASVProbabilities/ASVProbabilities_2.csv +3 -0
  14. stripesankey-0.1.0/design_process/data/prototype1/ASVProbabilities/ASVProbabilities_3.csv +4 -0
  15. stripesankey-0.1.0/design_process/data/prototype1/ASVProbabilities/ASVProbabilities_4.csv +5 -0
  16. stripesankey-0.1.0/design_process/data/prototype1/ASVProbabilities/ASVProbabilities_5.csv +6 -0
  17. stripesankey-0.1.0/design_process/data/prototype1/ASVProbabilities/ASVProbabilities_6.csv +7 -0
  18. stripesankey-0.1.0/design_process/data/prototype1/ASVProbabilities/ASVProbabilities_7.csv +8 -0
  19. stripesankey-0.1.0/design_process/data/prototype1/ASVProbabilities/ASVProbabilities_8.csv +9 -0
  20. stripesankey-0.1.0/design_process/data/prototype1/ASVProbabilities/ASVProbabilities_9.csv +10 -0
  21. stripesankey-0.1.0/design_process/data/prototype1/SampleProbabilities_wide/DirichletComponentProbabilities_10.csv +11 -0
  22. stripesankey-0.1.0/design_process/data/prototype1/SampleProbabilities_wide/DirichletComponentProbabilities_2.csv +3 -0
  23. stripesankey-0.1.0/design_process/data/prototype1/SampleProbabilities_wide/DirichletComponentProbabilities_3.csv +4 -0
  24. stripesankey-0.1.0/design_process/data/prototype1/SampleProbabilities_wide/DirichletComponentProbabilities_4.csv +5 -0
  25. stripesankey-0.1.0/design_process/data/prototype1/SampleProbabilities_wide/DirichletComponentProbabilities_5.csv +6 -0
  26. stripesankey-0.1.0/design_process/data/prototype1/SampleProbabilities_wide/DirichletComponentProbabilities_6.csv +7 -0
  27. stripesankey-0.1.0/design_process/data/prototype1/SampleProbabilities_wide/DirichletComponentProbabilities_7.csv +8 -0
  28. stripesankey-0.1.0/design_process/data/prototype1/SampleProbabilities_wide/DirichletComponentProbabilities_8.csv +9 -0
  29. stripesankey-0.1.0/design_process/data/prototype1/SampleProbabilities_wide/DirichletComponentProbabilities_9.csv +10 -0
  30. stripesankey-0.1.0/design_process/data/prototype1/metadata_new_updated.csv +345 -0
  31. stripesankey-0.1.0/design_process/data/prototype3/Diagnosis/mallet.diagnostics.10.xml +224 -0
  32. stripesankey-0.1.0/design_process/data/prototype3/Diagnosis/mallet.diagnostics.2.xml +48 -0
  33. stripesankey-0.1.0/design_process/data/prototype3/Diagnosis/mallet.diagnostics.3.xml +70 -0
  34. stripesankey-0.1.0/design_process/data/prototype3/Diagnosis/mallet.diagnostics.4.xml +92 -0
  35. stripesankey-0.1.0/design_process/data/prototype3/Diagnosis/mallet.diagnostics.5.xml +114 -0
  36. stripesankey-0.1.0/design_process/data/prototype3/Diagnosis/mallet.diagnostics.6.xml +136 -0
  37. stripesankey-0.1.0/design_process/data/prototype3/Diagnosis/mallet.diagnostics.7.xml +158 -0
  38. stripesankey-0.1.0/design_process/data/prototype3/Diagnosis/mallet.diagnostics.8.xml +180 -0
  39. stripesankey-0.1.0/design_process/data/prototype3/Diagnosis/mallet.diagnostics.9.xml +202 -0
  40. stripesankey-0.1.0/design_process/data/prototype3/all_MC_metrics_2_20.csv +20 -0
  41. stripesankey-0.1.0/design_process/notebooks/__marimo__/session/prototype1(RectangleNode|Similarity).py.json +281 -0
  42. stripesankey-0.1.0/design_process/notebooks/__marimo__/session/prototype2(CircularHistogram|Similarity).py.json +314 -0
  43. stripesankey-0.1.0/design_process/notebooks/__marimo__/session/prototype3(Axes|SampleTrack).py.json +14 -0
  44. stripesankey-0.1.0/design_process/notebooks/__marimo__/session/prototype3(Circular|SampleTrack).py.json +14 -0
  45. stripesankey-0.1.0/design_process/notebooks/__marimo__/session/prototype3(Coordinate|SampleTrack).py.json +151 -0
  46. stripesankey-0.1.0/design_process/notebooks/__marimo__/session/prototype4(Stripe|SampleTrack).py.json +218 -0
  47. stripesankey-0.1.0/design_process/notebooks/prototype1(RectangleNode|Similarity).py +1407 -0
  48. stripesankey-0.1.0/design_process/notebooks/prototype2(CircularHistogram|Similarity).py +1725 -0
  49. stripesankey-0.1.0/design_process/notebooks/prototype3(Coordinate|SampleTrack).py +1656 -0
  50. stripesankey-0.1.0/design_process/notebooks/prototype4(Stripe|SampleTrack).py +2173 -0
  51. stripesankey-0.1.0/design_process/sankey_data.json +31316 -0
  52. stripesankey-0.1.0/design_process/visuals/20250725_133822_RectangleNode|Similarity.png +0 -0
  53. stripesankey-0.1.0/design_process/visuals/20250725_163822_CircularHistogram|Similarity.png +0 -0
  54. stripesankey-0.1.0/design_process/visuals/20250725_163822_Coordinate|SampleTrack.png +0 -0
  55. stripesankey-0.1.0/design_process/visuals/20250725_170122_Stripe|SampleTrack.png +0 -0
  56. stripesankey-0.1.0/example/__marimo__/session/example1.py.json +60 -0
  57. stripesankey-0.1.0/example/example1.py +196 -0
  58. stripesankey-0.1.0/fig/StripeSankey_click.jpg +0 -0
  59. stripesankey-0.1.0/fig/StripeSankey_metic.jpeg +0 -0
  60. stripesankey-0.1.0/fig/legend.png +0 -0
  61. stripesankey-0.1.0/pyproject.toml +96 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 peiyang
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,262 @@
1
+ Metadata-Version: 2.4
2
+ Name: StripeSankey
3
+ Version: 0.1.0
4
+ Summary: Interactive Sankey diagram widget for topic modeling analysis with sample flow tracing
5
+ Project-URL: Homepage, https://github.com/Peiyangg/StripeSankey
6
+ Project-URL: Documentation, https://github.com/Peiyangg/StripeSankey#readme
7
+ Project-URL: Repository, https://github.com/Peiyangg/StripeSankey.git
8
+ Project-URL: Bug Tracker, https://github.com/Peiyangg/StripeSankey/issues
9
+ Author-email: Peiyang Huo <peiyang.huo@kuleuven.be>
10
+ Maintainer-email: Peiyang Huo <peiyang.huo@kuleuven.be>
11
+ License: MIT License
12
+
13
+ Copyright (c) 2025 peiyang
14
+
15
+ Permission is hereby granted, free of charge, to any person obtaining a copy
16
+ of this software and associated documentation files (the "Software"), to deal
17
+ in the Software without restriction, including without limitation the rights
18
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
19
+ copies of the Software, and to permit persons to whom the Software is
20
+ furnished to do so, subject to the following conditions:
21
+
22
+ The above copyright notice and this permission notice shall be included in all
23
+ copies or substantial portions of the Software.
24
+
25
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31
+ SOFTWARE.
32
+ License-File: LICENSE
33
+ Keywords: anywidget,interactive,jupyter,microbiome,sankey,topic-modeling,visualization,widget
34
+ Classifier: Development Status :: 4 - Beta
35
+ Classifier: Framework :: Jupyter
36
+ Classifier: Framework :: Jupyter :: JupyterLab
37
+ Classifier: Framework :: Jupyter :: JupyterLab :: 3
38
+ Classifier: Framework :: Jupyter :: JupyterLab :: 4
39
+ Classifier: Intended Audience :: Developers
40
+ Classifier: Intended Audience :: Science/Research
41
+ Classifier: License :: OSI Approved :: MIT License
42
+ Classifier: Programming Language :: Python :: 3
43
+ Classifier: Programming Language :: Python :: 3.8
44
+ Classifier: Programming Language :: Python :: 3.9
45
+ Classifier: Programming Language :: Python :: 3.10
46
+ Classifier: Programming Language :: Python :: 3.11
47
+ Classifier: Programming Language :: Python :: 3.12
48
+ Classifier: Topic :: Scientific/Engineering :: Visualization
49
+ Requires-Python: >=3.8
50
+ Requires-Dist: anywidget>=0.9.0
51
+ Requires-Dist: traitlets>=5.0.0
52
+ Provides-Extra: dev
53
+ Requires-Dist: black; extra == 'dev'
54
+ Requires-Dist: mypy; extra == 'dev'
55
+ Requires-Dist: pytest-cov; extra == 'dev'
56
+ Requires-Dist: pytest>=6.0; extra == 'dev'
57
+ Requires-Dist: ruff; extra == 'dev'
58
+ Provides-Extra: docs
59
+ Requires-Dist: sphinx; extra == 'docs'
60
+ Requires-Dist: sphinx-rtd-theme; extra == 'docs'
61
+ Description-Content-Type: text/markdown
62
+
63
+ # Stripe Sankey Widget
64
+
65
+ An interactive Sankey diagram widget for understanding how samples are represented by topics across different LDA models. This tool can also be applied to similar algorithms like NMF and LSA.
66
+
67
+ LDA is a powerful tool for achieving soft clustering and finding latent groups beyond initial hypotheses. However, the challenge of applying LDA to 16S rRNA data is that sequence reads are less informative than human language when users want to evaluate a model's results. Even when metrics are applied, making decisions remains difficult.
68
+
69
+ We designed this StripeSankey diagram to make LDA results more accessible and integrated two widely used metrics—perplexity and coherence score—into novel visual encodings.
70
+
71
+ Overview of StripeSankey diagram:
72
+ <img src="fig/StripeSankey_metic.jpeg" alt="Description" width="600">
73
+
74
+ Legend of metrics coour:
75
+ <img src="fig/legend.png" alt="Description" width="200">
76
+
77
+ After click one flow:
78
+ <img src="fig/StripeSankey_click.jpg" alt="Description" width="600">
79
+
80
+
81
+
82
+ ## Installation
83
+
84
+ ### From PyPI
85
+ ```bash
86
+ pip install StripeSankey
87
+ ```
88
+ ## Data Preprocessing
89
+
90
+ ## Quick Start
91
+
92
+ ```python
93
+ import stripe_sankey
94
+ from stripe_sankey import StripeSankeyInline
95
+
96
+ # Load your processed topic modeling data
97
+ sankey_data = {
98
+ "nodes": {
99
+ "K2_MC1": {
100
+ "high_count": 45,
101
+ "medium_count": 23,
102
+ "model_metrics": {"perplexity": 1.2},
103
+ "mallet_diagnostics": {"coherence": -0.15}
104
+ },
105
+ # ... more nodes
106
+ },
107
+ "flows": [
108
+ {
109
+ "source_segment": "K2_MC1_high",
110
+ "target_segment": "K3_MC2_medium",
111
+ "source_k": 2,
112
+ "target_k": 3,
113
+ "sample_count": 15,
114
+ "samples": [{"sample": "doc_1", "source_prob": 0.8, "target_prob": 0.6}]
115
+ },
116
+ # ... more flows
117
+ ],
118
+ "k_range": [2, 3, 4, 5]
119
+ }
120
+
121
+ # Create and display widget
122
+ widget = StripeSankeyInline(sankey_data=sankey_data)
123
+ widget
124
+ ```
125
+
126
+ ## Visualization Modes
127
+
128
+ ### Default Mode
129
+ Shows topic representations with high/medium probability segments:
130
+ ```python
131
+ widget = StripeSankeyInline(sankey_data=data, mode="default")
132
+ ```
133
+
134
+ ### Metric Mode
135
+ Color-codes topics by quality metrics (perplexity + coherence):
136
+ ```python
137
+ widget = StripeSankeyInline(sankey_data=data, mode="metric")
138
+
139
+ # Customize metric weights
140
+ widget.update_metric_config(red_weight=0.9, blue_weight=0.7)
141
+ ```
142
+
143
+ ## Interactive Features
144
+
145
+ ### Sample Flow Tracing
146
+ - **Click any flow** to highlight sample trajectories across K values
147
+ - **Orange trajectories** show where samples move between topics
148
+ - **Count badges** display number of traced samples in each segment
149
+ - **Line thickness** represents sample flow volume
150
+ - **Click background** to clear selection
151
+
152
+ ### Visual Elements
153
+ - **Stacked bars**: High (dark) and medium (light) probability representations
154
+ - **Curved flows**: Proportional thickness based on sample counts
155
+ - **Barycenter layout**: Optimized positioning to reduce visual complexity
156
+ - **Hover tooltips**: Detailed information on flows and segments
157
+
158
+ ## Data Format
159
+
160
+ Your data should follow this structure:
161
+
162
+ ```python
163
+ {
164
+ "nodes": {
165
+ "K{k}_MC{mc}": {
166
+ "high_count": int, # Samples with prob ≥ 0.67
167
+ "medium_count": int, # Samples with prob 0.33-0.66
168
+ "total_probability": float,
169
+ "model_metrics": {
170
+ "perplexity": float # Lower is better
171
+ },
172
+ "mallet_diagnostics": {
173
+ "coherence": float # Higher (less negative) is better
174
+ }
175
+ }
176
+ },
177
+ "flows": [
178
+ {
179
+ "source_segment": "K{k}_MC{mc}_{level}",
180
+ "target_segment": "K{k+1}_MC{mc}_{level}",
181
+ "source_k": int,
182
+ "target_k": int,
183
+ "sample_count": int,
184
+ "average_probability": float,
185
+ "samples": [
186
+ {
187
+ "sample": str, # Sample identifier
188
+ "source_prob": float, # Probability in source topic
189
+ "target_prob": float # Probability in target topic
190
+ }
191
+ ]
192
+ }
193
+ ],
194
+ "k_range": [2, 3, 4, 5] # Topic numbers analyzed
195
+ }
196
+ ```
197
+
198
+ ## Configuration Options
199
+
200
+ ### Widget Parameters
201
+ ```python
202
+ widget = StripeSankeyInline(
203
+ sankey_data=data,
204
+ width=1200, # Canvas width
205
+ height=800, # Canvas height
206
+ mode="default" # "default" or "metric"
207
+ )
208
+ ```
209
+
210
+ ### Metric Mode Configuration
211
+ ```python
212
+ widget.update_metric_config(
213
+ red_weight=0.8, # Perplexity influence (0-1)
214
+ blue_weight=0.8, # Coherence influence (0-1)
215
+ min_saturation=0.3 # Minimum color brightness
216
+ )
217
+ ```
218
+
219
+ ### Color Schemes
220
+ ```python
221
+ widget.color_schemes = {
222
+ 2: "#1f77b4", # Blue for K=2
223
+ 3: "#ff7f0e", # Orange for K=3
224
+ 4: "#2ca02c", # Green for K=4
225
+ 5: "#d62728" # Red for K=5
226
+ }
227
+ ```
228
+
229
+ ## Use Cases
230
+
231
+ - **Topic Model Analysis**: Understand how topics evolve across different K values
232
+ - **Sample Trajectory Tracking**: Follow samples through topic assignments
233
+ - **Model Quality Assessment**: Visual comparison of perplexity and coherence metrics
234
+ - **Flow Bottleneck Detection**: Identify where samples cluster or disperse
235
+ - **Research Presentation**: Interactive demonstrations of topic modeling results
236
+
237
+
238
+ ## License
239
+
240
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
241
+
242
+ <!-- ## Citation
243
+
244
+ If you use this widget in your research, please cite:
245
+
246
+ ```bibtex
247
+ @software{stripe_sankey,
248
+ title = {Stripe Sankey Widget: Interactive Topic Flow Visualization},
249
+ author = {Your Name},
250
+ url = {https://github.com/Peiyangg/StripeSankey},
251
+ year = {2024}
252
+ }
253
+ ``` -->
254
+
255
+ ## Acknowledgments
256
+
257
+ - Built with [anywidget](https://anywidget.dev/) - modern Jupyter widget framework
258
+ - Visualization powered by [D3.js](https://d3js.org/)
259
+
260
+ ## Support
261
+
262
+ - 📖 [Documentation](https://github.com/Peiyangg/StripeSankey#readme)
@@ -0,0 +1,200 @@
1
+ # Stripe Sankey Widget
2
+
3
+ An interactive Sankey diagram widget for understanding how samples are represented by topics across different LDA models. This tool can also be applied to similar algorithms like NMF and LSA.
4
+
5
+ LDA is a powerful tool for achieving soft clustering and finding latent groups beyond initial hypotheses. However, the challenge of applying LDA to 16S rRNA data is that sequence reads are less informative than human language when users want to evaluate a model's results. Even when metrics are applied, making decisions remains difficult.
6
+
7
+ We designed this StripeSankey diagram to make LDA results more accessible and integrated two widely used metrics—perplexity and coherence score—into novel visual encodings.
8
+
9
+ Overview of StripeSankey diagram:
10
+ <img src="fig/StripeSankey_metic.jpeg" alt="Description" width="600">
11
+
12
+ Legend of metrics coour:
13
+ <img src="fig/legend.png" alt="Description" width="200">
14
+
15
+ After click one flow:
16
+ <img src="fig/StripeSankey_click.jpg" alt="Description" width="600">
17
+
18
+
19
+
20
+ ## Installation
21
+
22
+ ### From PyPI
23
+ ```bash
24
+ pip install StripeSankey
25
+ ```
26
+ ## Data Preprocessing
27
+
28
+ ## Quick Start
29
+
30
+ ```python
31
+ import stripe_sankey
32
+ from stripe_sankey import StripeSankeyInline
33
+
34
+ # Load your processed topic modeling data
35
+ sankey_data = {
36
+ "nodes": {
37
+ "K2_MC1": {
38
+ "high_count": 45,
39
+ "medium_count": 23,
40
+ "model_metrics": {"perplexity": 1.2},
41
+ "mallet_diagnostics": {"coherence": -0.15}
42
+ },
43
+ # ... more nodes
44
+ },
45
+ "flows": [
46
+ {
47
+ "source_segment": "K2_MC1_high",
48
+ "target_segment": "K3_MC2_medium",
49
+ "source_k": 2,
50
+ "target_k": 3,
51
+ "sample_count": 15,
52
+ "samples": [{"sample": "doc_1", "source_prob": 0.8, "target_prob": 0.6}]
53
+ },
54
+ # ... more flows
55
+ ],
56
+ "k_range": [2, 3, 4, 5]
57
+ }
58
+
59
+ # Create and display widget
60
+ widget = StripeSankeyInline(sankey_data=sankey_data)
61
+ widget
62
+ ```
63
+
64
+ ## Visualization Modes
65
+
66
+ ### Default Mode
67
+ Shows topic representations with high/medium probability segments:
68
+ ```python
69
+ widget = StripeSankeyInline(sankey_data=data, mode="default")
70
+ ```
71
+
72
+ ### Metric Mode
73
+ Color-codes topics by quality metrics (perplexity + coherence):
74
+ ```python
75
+ widget = StripeSankeyInline(sankey_data=data, mode="metric")
76
+
77
+ # Customize metric weights
78
+ widget.update_metric_config(red_weight=0.9, blue_weight=0.7)
79
+ ```
80
+
81
+ ## Interactive Features
82
+
83
+ ### Sample Flow Tracing
84
+ - **Click any flow** to highlight sample trajectories across K values
85
+ - **Orange trajectories** show where samples move between topics
86
+ - **Count badges** display number of traced samples in each segment
87
+ - **Line thickness** represents sample flow volume
88
+ - **Click background** to clear selection
89
+
90
+ ### Visual Elements
91
+ - **Stacked bars**: High (dark) and medium (light) probability representations
92
+ - **Curved flows**: Proportional thickness based on sample counts
93
+ - **Barycenter layout**: Optimized positioning to reduce visual complexity
94
+ - **Hover tooltips**: Detailed information on flows and segments
95
+
96
+ ## Data Format
97
+
98
+ Your data should follow this structure:
99
+
100
+ ```python
101
+ {
102
+ "nodes": {
103
+ "K{k}_MC{mc}": {
104
+ "high_count": int, # Samples with prob ≥ 0.67
105
+ "medium_count": int, # Samples with prob 0.33-0.66
106
+ "total_probability": float,
107
+ "model_metrics": {
108
+ "perplexity": float # Lower is better
109
+ },
110
+ "mallet_diagnostics": {
111
+ "coherence": float # Higher (less negative) is better
112
+ }
113
+ }
114
+ },
115
+ "flows": [
116
+ {
117
+ "source_segment": "K{k}_MC{mc}_{level}",
118
+ "target_segment": "K{k+1}_MC{mc}_{level}",
119
+ "source_k": int,
120
+ "target_k": int,
121
+ "sample_count": int,
122
+ "average_probability": float,
123
+ "samples": [
124
+ {
125
+ "sample": str, # Sample identifier
126
+ "source_prob": float, # Probability in source topic
127
+ "target_prob": float # Probability in target topic
128
+ }
129
+ ]
130
+ }
131
+ ],
132
+ "k_range": [2, 3, 4, 5] # Topic numbers analyzed
133
+ }
134
+ ```
135
+
136
+ ## Configuration Options
137
+
138
+ ### Widget Parameters
139
+ ```python
140
+ widget = StripeSankeyInline(
141
+ sankey_data=data,
142
+ width=1200, # Canvas width
143
+ height=800, # Canvas height
144
+ mode="default" # "default" or "metric"
145
+ )
146
+ ```
147
+
148
+ ### Metric Mode Configuration
149
+ ```python
150
+ widget.update_metric_config(
151
+ red_weight=0.8, # Perplexity influence (0-1)
152
+ blue_weight=0.8, # Coherence influence (0-1)
153
+ min_saturation=0.3 # Minimum color brightness
154
+ )
155
+ ```
156
+
157
+ ### Color Schemes
158
+ ```python
159
+ widget.color_schemes = {
160
+ 2: "#1f77b4", # Blue for K=2
161
+ 3: "#ff7f0e", # Orange for K=3
162
+ 4: "#2ca02c", # Green for K=4
163
+ 5: "#d62728" # Red for K=5
164
+ }
165
+ ```
166
+
167
+ ## Use Cases
168
+
169
+ - **Topic Model Analysis**: Understand how topics evolve across different K values
170
+ - **Sample Trajectory Tracking**: Follow samples through topic assignments
171
+ - **Model Quality Assessment**: Visual comparison of perplexity and coherence metrics
172
+ - **Flow Bottleneck Detection**: Identify where samples cluster or disperse
173
+ - **Research Presentation**: Interactive demonstrations of topic modeling results
174
+
175
+
176
+ ## License
177
+
178
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
179
+
180
+ <!-- ## Citation
181
+
182
+ If you use this widget in your research, please cite:
183
+
184
+ ```bibtex
185
+ @software{stripe_sankey,
186
+ title = {Stripe Sankey Widget: Interactive Topic Flow Visualization},
187
+ author = {Your Name},
188
+ url = {https://github.com/Peiyangg/StripeSankey},
189
+ year = {2024}
190
+ }
191
+ ``` -->
192
+
193
+ ## Acknowledgments
194
+
195
+ - Built with [anywidget](https://anywidget.dev/) - modern Jupyter widget framework
196
+ - Visualization powered by [D3.js](https://d3js.org/)
197
+
198
+ ## Support
199
+
200
+ - 📖 [Documentation](https://github.com/Peiyangg/StripeSankey#readme)
@@ -0,0 +1,4 @@
1
+ from .widget import StripeSankeyInline
2
+
3
+ __version__ = "0.1.0"
4
+ __all__ = ["StripeSankeyInline"]