cnsplots 0.0.1__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.
- cnsplots-0.0.1/LICENSE.md +29 -0
- cnsplots-0.0.1/PKG-INFO +359 -0
- cnsplots-0.0.1/README.md +295 -0
- cnsplots-0.0.1/pyproject.toml +123 -0
- cnsplots-0.0.1/setup.cfg +4 -0
- cnsplots-0.0.1/src/cnsplots/__init__.py +137 -0
- cnsplots-0.0.1/src/cnsplots/_methods.py +591 -0
- cnsplots-0.0.1/src/cnsplots/_multipanels.py +521 -0
- cnsplots-0.0.1/src/cnsplots/_settings.py +265 -0
- cnsplots-0.0.1/src/cnsplots/_setup.py +597 -0
- cnsplots-0.0.1/src/cnsplots/_svg.py +214 -0
- cnsplots-0.0.1/src/cnsplots/_utils.py +1112 -0
- cnsplots-0.0.1/src/cnsplots/_validation.py +712 -0
- cnsplots-0.0.1/src/cnsplots/helpers/__init__.py +1 -0
- cnsplots-0.0.1/src/cnsplots/helpers/_cmprsk.py +77 -0
- cnsplots-0.0.1/src/cnsplots/helpers/_heatmap.py +302 -0
- cnsplots-0.0.1/src/cnsplots/helpers/_phylo.py +269 -0
- cnsplots-0.0.1/src/cnsplots/helpers/_sankey.py +403 -0
- cnsplots-0.0.1/src/cnsplots/plots/__init__.py +58 -0
- cnsplots-0.0.1/src/cnsplots/plots/_categorical.py +953 -0
- cnsplots-0.0.1/src/cnsplots/plots/_distribution.py +610 -0
- cnsplots-0.0.1/src/cnsplots/plots/_genomics.py +256 -0
- cnsplots-0.0.1/src/cnsplots/plots/_heatmap.py +690 -0
- cnsplots-0.0.1/src/cnsplots/plots/_regression.py +390 -0
- cnsplots-0.0.1/src/cnsplots/plots/_sets.py +186 -0
- cnsplots-0.0.1/src/cnsplots/plots/_specialized.py +380 -0
- cnsplots-0.0.1/src/cnsplots/plots/_survival.py +343 -0
- cnsplots-0.0.1/src/cnsplots.egg-info/PKG-INFO +359 -0
- cnsplots-0.0.1/src/cnsplots.egg-info/SOURCES.txt +30 -0
- cnsplots-0.0.1/src/cnsplots.egg-info/dependency_links.txt +1 -0
- cnsplots-0.0.1/src/cnsplots.egg-info/requires.txt +44 -0
- cnsplots-0.0.1/src/cnsplots.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023-2026, Farid Rashidi
|
|
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.
|
cnsplots-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cnsplots
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: A comprehensive plotting library for bioinformatics and data visualization
|
|
5
|
+
License: BSD-3-Clause
|
|
6
|
+
Project-URL: Homepage, https://github.com/faridrashidi/cnsplots
|
|
7
|
+
Project-URL: Documentation, https://cnsplots.readthedocs.io
|
|
8
|
+
Project-URL: Repository, https://github.com/faridrashidi/cnsplots
|
|
9
|
+
Project-URL: Issues, https://github.com/faridrashidi/cnsplots/issues
|
|
10
|
+
Keywords: plotting,visualization,bioinformatics
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
|
|
22
|
+
Requires-Python: <4.0,>=3.9
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE.md
|
|
25
|
+
Requires-Dist: adjustText
|
|
26
|
+
Requires-Dist: biopython
|
|
27
|
+
Requires-Dist: glasbey
|
|
28
|
+
Requires-Dist: gseapy
|
|
29
|
+
Requires-Dist: lifelines
|
|
30
|
+
Requires-Dist: lxml
|
|
31
|
+
Requires-Dist: matplotlib
|
|
32
|
+
Requires-Dist: matplotlib-venn
|
|
33
|
+
Requires-Dist: natsort
|
|
34
|
+
Requires-Dist: num2tex
|
|
35
|
+
Requires-Dist: numba>=0.58.1
|
|
36
|
+
Requires-Dist: numpy
|
|
37
|
+
Requires-Dist: palettable
|
|
38
|
+
Requires-Dist: pandas
|
|
39
|
+
Requires-Dist: pycomplexheatmap
|
|
40
|
+
Requires-Dist: scanpy
|
|
41
|
+
Requires-Dist: scikit-learn
|
|
42
|
+
Requires-Dist: scipy
|
|
43
|
+
Requires-Dist: seaborn
|
|
44
|
+
Requires-Dist: statannotations
|
|
45
|
+
Requires-Dist: statsmodels
|
|
46
|
+
Requires-Dist: upsetplot
|
|
47
|
+
Provides-Extra: dev
|
|
48
|
+
Requires-Dist: bump-my-version; extra == "dev"
|
|
49
|
+
Requires-Dist: fastcluster; extra == "dev"
|
|
50
|
+
Requires-Dist: ipykernel; extra == "dev"
|
|
51
|
+
Requires-Dist: pre-commit; extra == "dev"
|
|
52
|
+
Requires-Dist: pytest; extra == "dev"
|
|
53
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
54
|
+
Provides-Extra: doc
|
|
55
|
+
Requires-Dist: furo; extra == "doc"
|
|
56
|
+
Requires-Dist: myst-parser; extra == "doc"
|
|
57
|
+
Requires-Dist: sphinx<9; python_version < "3.11" and extra == "doc"
|
|
58
|
+
Requires-Dist: sphinx<9.1,>=9; python_version >= "3.11" and extra == "doc"
|
|
59
|
+
Requires-Dist: sphinx-autodoc-typehints; extra == "doc"
|
|
60
|
+
Requires-Dist: sphinx-copybutton; extra == "doc"
|
|
61
|
+
Requires-Dist: sphinx-design; extra == "doc"
|
|
62
|
+
Requires-Dist: sphinx-gallery; extra == "doc"
|
|
63
|
+
Dynamic: license-file
|
|
64
|
+
|
|
65
|
+
# cnsplots
|
|
66
|
+
|
|
67
|
+
<div align="center">
|
|
68
|
+
|
|
69
|
+
[](https://pypi.org/project/cnsplots/)
|
|
70
|
+
[](https://pypi.org/project/cnsplots/)
|
|
71
|
+
[](https://github.com/faridrashidi/cnsplots/blob/main/LICENSE.md)
|
|
72
|
+
[](https://github.com/astral-sh/ruff)
|
|
73
|
+
|
|
74
|
+
**Publication-Ready Scientific Plots for Cell, Nature, and Science Journals**
|
|
75
|
+
|
|
76
|
+
Create visually stunning, journal-quality figures with minimal code. Built on matplotlib, fully compatible with seaborn, and optimized for Adobe Illustrator.
|
|
77
|
+
|
|
78
|
+
[Documentation](https://cnsplots.farid.one/) ยท [Examples Gallery](https://cnsplots.farid.one/examples/index.html) ยท [Report Bug](https://github.com/faridrashidi/cnsplots/issues) ยท [Request Feature](https://github.com/faridrashidi/cnsplots/issues)
|
|
79
|
+
|
|
80
|
+
</div>
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## Overview
|
|
85
|
+
|
|
86
|
+
[](https://cnsplots.farid.one/examples/index.html)
|
|
87
|
+
|
|
88
|
+
**cnsplots** is a Python visualization library designed specifically for creating publication-ready scientific figures. It takes care of the tedious styling details so you can focus on your science.
|
|
89
|
+
|
|
90
|
+
### Why cnsplots?
|
|
91
|
+
|
|
92
|
+
- ๐จ **Publication-Ready**: Pre-configured styles matching Cell, Nature, and Science journal requirements
|
|
93
|
+
- ๐ฏ **Simple API**: Create complex multi-panel figures with just a few lines of code
|
|
94
|
+
- ๐ **Precise Control**: Specify dimensions in pixels, perfect for journal submission guidelines
|
|
95
|
+
- ๐๏ธ **Adobe Illustrator Compatible**: SVG exports with editable fonts (no text-to-path conversion)
|
|
96
|
+
- ๐ **Statistical Integration**: Built-in statistical tests and annotations
|
|
97
|
+
- ๐ง **Highly Customizable**: Full control over colors, fonts, and styling
|
|
98
|
+
- ๐ **Rich Color Palettes**: Curated color schemes optimized for scientific visualization
|
|
99
|
+
- ๐งฉ **Multi-Panel Support**: Easy creation of complex figure layouts
|
|
100
|
+
|
|
101
|
+
## Features
|
|
102
|
+
|
|
103
|
+
### ๐ 25+ Plot Types
|
|
104
|
+
|
|
105
|
+
**Basic Plots**
|
|
106
|
+
|
|
107
|
+
- Box plots, violin plots, bar plots, strip plots
|
|
108
|
+
- Scatter plots, line plots, regression plots
|
|
109
|
+
- Histograms, KDE plots, ridge plots
|
|
110
|
+
|
|
111
|
+
**Scientific Plots**
|
|
112
|
+
|
|
113
|
+
- Survival plots (Kaplan-Meier)
|
|
114
|
+
- Cumulative incidence plots
|
|
115
|
+
- ROC curves and forest plots
|
|
116
|
+
- Volcano plots and GSEA plots
|
|
117
|
+
- Confusion matrices
|
|
118
|
+
|
|
119
|
+
**Specialized Plots**
|
|
120
|
+
|
|
121
|
+
- Heatmaps with hierarchical clustering
|
|
122
|
+
- Dot plots for enrichment
|
|
123
|
+
- Venn diagrams and UpSet plots
|
|
124
|
+
- Sankey diagrams
|
|
125
|
+
- Pie and donut charts
|
|
126
|
+
- QQ plots and slope plots
|
|
127
|
+
|
|
128
|
+
### ๐จ Beautiful Color Palettes
|
|
129
|
+
|
|
130
|
+
Multiple curated palettes including:
|
|
131
|
+
|
|
132
|
+
- **Qualitative**: Ecotyper1-6, Set1-3, Tableau, Bold
|
|
133
|
+
- **Sequential**: Parula, gnuplot, custom gradients
|
|
134
|
+
- **Diverging**: BlueRed, BuRd_custom, OrBu_custom
|
|
135
|
+
|
|
136
|
+
### ๐ Multi-Panel Figures
|
|
137
|
+
|
|
138
|
+
Create complex layouts with automatic panel labeling (A, B, C...):
|
|
139
|
+
|
|
140
|
+
```python
|
|
141
|
+
import cnsplots as cns
|
|
142
|
+
|
|
143
|
+
mp = cns.multipanel(max_width=540)
|
|
144
|
+
|
|
145
|
+
# Panel A
|
|
146
|
+
mp.panel("A", height=150, width=150)
|
|
147
|
+
cns.boxplot(data=df1, x="group", y="value")
|
|
148
|
+
|
|
149
|
+
# Panel B
|
|
150
|
+
mp.panel("B", height=150, width=150)
|
|
151
|
+
cns.scatterplot(data=df2, x="x", y="y")
|
|
152
|
+
|
|
153
|
+
# Continues...
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Installation
|
|
157
|
+
|
|
158
|
+
### From PyPI
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
pip install cnsplots
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### For Development
|
|
165
|
+
|
|
166
|
+
First install [uv](https://docs.astral.sh/uv/), then:
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
git clone https://github.com/faridrashidi/cnsplots
|
|
170
|
+
cd cnsplots
|
|
171
|
+
make install
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Quick Start
|
|
175
|
+
|
|
176
|
+
### Basic Usage
|
|
177
|
+
|
|
178
|
+
```python
|
|
179
|
+
import cnsplots as cns
|
|
180
|
+
import seaborn as sns
|
|
181
|
+
import matplotlib.pyplot as plt
|
|
182
|
+
|
|
183
|
+
# Load example data
|
|
184
|
+
df = sns.load_dataset("tips")
|
|
185
|
+
|
|
186
|
+
# Create a figure (dimensions in pixels)
|
|
187
|
+
cns.figure(height=150, width=100)
|
|
188
|
+
|
|
189
|
+
# Create a publication-ready boxplot
|
|
190
|
+
cns.boxplot(data=df, x="day", y="total_bill")
|
|
191
|
+
|
|
192
|
+
# Save as vector graphic
|
|
193
|
+
plt.savefig("figure.svg")
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Statistical Comparisons
|
|
197
|
+
|
|
198
|
+
```python
|
|
199
|
+
# Add statistical significance annotations
|
|
200
|
+
cns.figure(150, 150)
|
|
201
|
+
cns.boxplot(
|
|
202
|
+
data=df,
|
|
203
|
+
x="day",
|
|
204
|
+
y="total_bill",
|
|
205
|
+
pairs=[("Thur", "Fri"), ("Sat", "Sun")], # Compare these pairs
|
|
206
|
+
)
|
|
207
|
+
# Prints: P-values were determined by two-sided Mann-Whitney U test.
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Custom Colors
|
|
211
|
+
|
|
212
|
+
```python
|
|
213
|
+
# Use custom color palette
|
|
214
|
+
cns.figure(150, 200, color_cycle="Ecotyper1")
|
|
215
|
+
cns.violinplot(data=df, x="day", y="total_bill", hue="sex")
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
## Examples Gallery
|
|
219
|
+
|
|
220
|
+
Explore our comprehensive [examples gallery](https://cnsplots.farid.one/examples/index.html) featuring:
|
|
221
|
+
|
|
222
|
+
- ๐ฆ Basic statistical plots
|
|
223
|
+
- ๐งฌ Genomics and bioinformatics visualizations
|
|
224
|
+
- ๐ Time-series and survival analysis
|
|
225
|
+
- ๐ฏ Machine learning results (ROC, confusion matrices)
|
|
226
|
+
- ๐ฌ Multi-omics data visualization
|
|
227
|
+
- ๐จ Custom color schemes and styling
|
|
228
|
+
|
|
229
|
+
## Documentation
|
|
230
|
+
|
|
231
|
+
Full documentation is available at [farid.one/cnsplots](https://cnsplots.farid.one/)
|
|
232
|
+
|
|
233
|
+
- [Installation Guide](https://cnsplots.farid.one/installation.html)
|
|
234
|
+
- [API Reference](https://cnsplots.farid.one/api.html)
|
|
235
|
+
- [Examples Gallery](https://cnsplots.farid.one/examples/index.html)
|
|
236
|
+
|
|
237
|
+
## Key Concepts
|
|
238
|
+
|
|
239
|
+
### Figure Dimensions
|
|
240
|
+
|
|
241
|
+
Specify sizes in **pixels** for precise control:
|
|
242
|
+
|
|
243
|
+
```python
|
|
244
|
+
cns.figure(height=150, width=100) # Creates 150px ร 100px figure
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### Color Palettes
|
|
248
|
+
|
|
249
|
+
Access curated color palettes:
|
|
250
|
+
|
|
251
|
+
```python
|
|
252
|
+
# Qualitative palettes (for categorical data)
|
|
253
|
+
cns.figure(color_cycle="Ecotyper1") # Default, optimized for journals
|
|
254
|
+
cns.figure(color_cycle="Set1") # ColorBrewer Set1
|
|
255
|
+
|
|
256
|
+
# Sequential palettes (for continuous data)
|
|
257
|
+
cns.figure(color_map="parula") # MATLAB-style
|
|
258
|
+
cns.figure(color_map="gnuplot") # Default sequential
|
|
259
|
+
|
|
260
|
+
# Get individual colors
|
|
261
|
+
red = cns.RED
|
|
262
|
+
blue = cns.BLUE
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### Statistical Tests
|
|
266
|
+
|
|
267
|
+
Many plot functions include built-in statistical testing:
|
|
268
|
+
|
|
269
|
+
```python
|
|
270
|
+
# Boxplot with Mann-Whitney U test
|
|
271
|
+
cns.boxplot(data=df, x="group", y="value", pairs="all")
|
|
272
|
+
|
|
273
|
+
# Barplot with Welch's t-test
|
|
274
|
+
cns.barplot(data=df, x="group", y="value", pairs=[("A", "B")])
|
|
275
|
+
|
|
276
|
+
# Stackplot with Fisher's exact test
|
|
277
|
+
cns.stackplot(data=df, x="group", y="category", pairs=[("A", "B")])
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### Export for Publication
|
|
281
|
+
|
|
282
|
+
```python
|
|
283
|
+
# SVG for vector graphics (recommended)
|
|
284
|
+
plt.savefig("figure.svg")
|
|
285
|
+
|
|
286
|
+
# High-resolution PNG
|
|
287
|
+
plt.savefig("figure.png", dpi=300)
|
|
288
|
+
|
|
289
|
+
# PDF with editable text
|
|
290
|
+
plt.savefig("figure.pdf")
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
## Requirements
|
|
294
|
+
|
|
295
|
+
- Python โฅ 3.9
|
|
296
|
+
- Core: matplotlib, numpy, pandas, seaborn
|
|
297
|
+
- Optional: lifelines, gseapy, scanpy (for specific plot types)
|
|
298
|
+
|
|
299
|
+
See [pyproject.toml](pyproject.toml) for complete dependency list.
|
|
300
|
+
|
|
301
|
+
## Contributing
|
|
302
|
+
|
|
303
|
+
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
|
|
304
|
+
|
|
305
|
+
### Development Setup
|
|
306
|
+
|
|
307
|
+
Follow the development installation instructions above, then use `make lint` to run formatters and linters before submitting a PR.
|
|
308
|
+
|
|
309
|
+
## Citation
|
|
310
|
+
|
|
311
|
+
If you use cnsplots in your research, please cite:
|
|
312
|
+
|
|
313
|
+
```bibtex
|
|
314
|
+
@software{cnsplots,
|
|
315
|
+
author = {Rashidi, Farid},
|
|
316
|
+
title = {cnsplots: Publication-Ready Scientific Plots},
|
|
317
|
+
year = {2026},
|
|
318
|
+
url = {https://github.com/faridrashidi/cnsplots}
|
|
319
|
+
}
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
## License
|
|
323
|
+
|
|
324
|
+
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details.
|
|
325
|
+
|
|
326
|
+
## Acknowledgments
|
|
327
|
+
|
|
328
|
+
Built with:
|
|
329
|
+
|
|
330
|
+
- [matplotlib](https://matplotlib.org/) - Core plotting library
|
|
331
|
+
- [seaborn](https://seaborn.pydata.org/) - Statistical visualizations
|
|
332
|
+
- [lifelines](https://lifelines.readthedocs.io/) - Survival analysis
|
|
333
|
+
- [PyComplexHeatmap](https://github.com/DingWB/PyComplexHeatmap) - Complex heatmaps
|
|
334
|
+
- [UpSetPlot](https://upsetplot.readthedocs.io/) - Set intersections
|
|
335
|
+
|
|
336
|
+
Inspired by the visualization standards of Cell, Nature, and Science journals.
|
|
337
|
+
|
|
338
|
+
## Support
|
|
339
|
+
|
|
340
|
+
- ๐ [Documentation](https://cnsplots.farid.one/)
|
|
341
|
+
- ๐ [Issue Tracker](https://github.com/faridrashidi/cnsplots/issues)
|
|
342
|
+
- ๐ฌ [Discussions](https://github.com/faridrashidi/cnsplots/discussions)
|
|
343
|
+
|
|
344
|
+
## Related Projects
|
|
345
|
+
|
|
346
|
+
- [matplotlib](https://matplotlib.org/) - The foundation of Python plotting
|
|
347
|
+
- [seaborn](https://seaborn.pydata.org/) - Statistical data visualization
|
|
348
|
+
- [plotnine](https://plotnine.readthedocs.io/) - Grammar of graphics for Python
|
|
349
|
+
- [altair](https://altair-viz.github.io/) - Declarative visualization
|
|
350
|
+
|
|
351
|
+
---
|
|
352
|
+
|
|
353
|
+
<div align="center">
|
|
354
|
+
|
|
355
|
+
Made with โค๏ธ for the scientific community
|
|
356
|
+
|
|
357
|
+
[โญ Star us on GitHub](https://github.com/faridrashidi/cnsplots) ยท [๐ Read the Docs](https://cnsplots.farid.one/)
|
|
358
|
+
|
|
359
|
+
</div>
|
cnsplots-0.0.1/README.md
ADDED
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
# cnsplots
|
|
2
|
+
|
|
3
|
+
<div align="center">
|
|
4
|
+
|
|
5
|
+
[](https://pypi.org/project/cnsplots/)
|
|
6
|
+
[](https://pypi.org/project/cnsplots/)
|
|
7
|
+
[](https://github.com/faridrashidi/cnsplots/blob/main/LICENSE.md)
|
|
8
|
+
[](https://github.com/astral-sh/ruff)
|
|
9
|
+
|
|
10
|
+
**Publication-Ready Scientific Plots for Cell, Nature, and Science Journals**
|
|
11
|
+
|
|
12
|
+
Create visually stunning, journal-quality figures with minimal code. Built on matplotlib, fully compatible with seaborn, and optimized for Adobe Illustrator.
|
|
13
|
+
|
|
14
|
+
[Documentation](https://cnsplots.farid.one/) ยท [Examples Gallery](https://cnsplots.farid.one/examples/index.html) ยท [Report Bug](https://github.com/faridrashidi/cnsplots/issues) ยท [Request Feature](https://github.com/faridrashidi/cnsplots/issues)
|
|
15
|
+
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Overview
|
|
21
|
+
|
|
22
|
+
[](https://cnsplots.farid.one/examples/index.html)
|
|
23
|
+
|
|
24
|
+
**cnsplots** is a Python visualization library designed specifically for creating publication-ready scientific figures. It takes care of the tedious styling details so you can focus on your science.
|
|
25
|
+
|
|
26
|
+
### Why cnsplots?
|
|
27
|
+
|
|
28
|
+
- ๐จ **Publication-Ready**: Pre-configured styles matching Cell, Nature, and Science journal requirements
|
|
29
|
+
- ๐ฏ **Simple API**: Create complex multi-panel figures with just a few lines of code
|
|
30
|
+
- ๐ **Precise Control**: Specify dimensions in pixels, perfect for journal submission guidelines
|
|
31
|
+
- ๐๏ธ **Adobe Illustrator Compatible**: SVG exports with editable fonts (no text-to-path conversion)
|
|
32
|
+
- ๐ **Statistical Integration**: Built-in statistical tests and annotations
|
|
33
|
+
- ๐ง **Highly Customizable**: Full control over colors, fonts, and styling
|
|
34
|
+
- ๐ **Rich Color Palettes**: Curated color schemes optimized for scientific visualization
|
|
35
|
+
- ๐งฉ **Multi-Panel Support**: Easy creation of complex figure layouts
|
|
36
|
+
|
|
37
|
+
## Features
|
|
38
|
+
|
|
39
|
+
### ๐ 25+ Plot Types
|
|
40
|
+
|
|
41
|
+
**Basic Plots**
|
|
42
|
+
|
|
43
|
+
- Box plots, violin plots, bar plots, strip plots
|
|
44
|
+
- Scatter plots, line plots, regression plots
|
|
45
|
+
- Histograms, KDE plots, ridge plots
|
|
46
|
+
|
|
47
|
+
**Scientific Plots**
|
|
48
|
+
|
|
49
|
+
- Survival plots (Kaplan-Meier)
|
|
50
|
+
- Cumulative incidence plots
|
|
51
|
+
- ROC curves and forest plots
|
|
52
|
+
- Volcano plots and GSEA plots
|
|
53
|
+
- Confusion matrices
|
|
54
|
+
|
|
55
|
+
**Specialized Plots**
|
|
56
|
+
|
|
57
|
+
- Heatmaps with hierarchical clustering
|
|
58
|
+
- Dot plots for enrichment
|
|
59
|
+
- Venn diagrams and UpSet plots
|
|
60
|
+
- Sankey diagrams
|
|
61
|
+
- Pie and donut charts
|
|
62
|
+
- QQ plots and slope plots
|
|
63
|
+
|
|
64
|
+
### ๐จ Beautiful Color Palettes
|
|
65
|
+
|
|
66
|
+
Multiple curated palettes including:
|
|
67
|
+
|
|
68
|
+
- **Qualitative**: Ecotyper1-6, Set1-3, Tableau, Bold
|
|
69
|
+
- **Sequential**: Parula, gnuplot, custom gradients
|
|
70
|
+
- **Diverging**: BlueRed, BuRd_custom, OrBu_custom
|
|
71
|
+
|
|
72
|
+
### ๐ Multi-Panel Figures
|
|
73
|
+
|
|
74
|
+
Create complex layouts with automatic panel labeling (A, B, C...):
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
import cnsplots as cns
|
|
78
|
+
|
|
79
|
+
mp = cns.multipanel(max_width=540)
|
|
80
|
+
|
|
81
|
+
# Panel A
|
|
82
|
+
mp.panel("A", height=150, width=150)
|
|
83
|
+
cns.boxplot(data=df1, x="group", y="value")
|
|
84
|
+
|
|
85
|
+
# Panel B
|
|
86
|
+
mp.panel("B", height=150, width=150)
|
|
87
|
+
cns.scatterplot(data=df2, x="x", y="y")
|
|
88
|
+
|
|
89
|
+
# Continues...
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Installation
|
|
93
|
+
|
|
94
|
+
### From PyPI
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
pip install cnsplots
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### For Development
|
|
101
|
+
|
|
102
|
+
First install [uv](https://docs.astral.sh/uv/), then:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
git clone https://github.com/faridrashidi/cnsplots
|
|
106
|
+
cd cnsplots
|
|
107
|
+
make install
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Quick Start
|
|
111
|
+
|
|
112
|
+
### Basic Usage
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
import cnsplots as cns
|
|
116
|
+
import seaborn as sns
|
|
117
|
+
import matplotlib.pyplot as plt
|
|
118
|
+
|
|
119
|
+
# Load example data
|
|
120
|
+
df = sns.load_dataset("tips")
|
|
121
|
+
|
|
122
|
+
# Create a figure (dimensions in pixels)
|
|
123
|
+
cns.figure(height=150, width=100)
|
|
124
|
+
|
|
125
|
+
# Create a publication-ready boxplot
|
|
126
|
+
cns.boxplot(data=df, x="day", y="total_bill")
|
|
127
|
+
|
|
128
|
+
# Save as vector graphic
|
|
129
|
+
plt.savefig("figure.svg")
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Statistical Comparisons
|
|
133
|
+
|
|
134
|
+
```python
|
|
135
|
+
# Add statistical significance annotations
|
|
136
|
+
cns.figure(150, 150)
|
|
137
|
+
cns.boxplot(
|
|
138
|
+
data=df,
|
|
139
|
+
x="day",
|
|
140
|
+
y="total_bill",
|
|
141
|
+
pairs=[("Thur", "Fri"), ("Sat", "Sun")], # Compare these pairs
|
|
142
|
+
)
|
|
143
|
+
# Prints: P-values were determined by two-sided Mann-Whitney U test.
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Custom Colors
|
|
147
|
+
|
|
148
|
+
```python
|
|
149
|
+
# Use custom color palette
|
|
150
|
+
cns.figure(150, 200, color_cycle="Ecotyper1")
|
|
151
|
+
cns.violinplot(data=df, x="day", y="total_bill", hue="sex")
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Examples Gallery
|
|
155
|
+
|
|
156
|
+
Explore our comprehensive [examples gallery](https://cnsplots.farid.one/examples/index.html) featuring:
|
|
157
|
+
|
|
158
|
+
- ๐ฆ Basic statistical plots
|
|
159
|
+
- ๐งฌ Genomics and bioinformatics visualizations
|
|
160
|
+
- ๐ Time-series and survival analysis
|
|
161
|
+
- ๐ฏ Machine learning results (ROC, confusion matrices)
|
|
162
|
+
- ๐ฌ Multi-omics data visualization
|
|
163
|
+
- ๐จ Custom color schemes and styling
|
|
164
|
+
|
|
165
|
+
## Documentation
|
|
166
|
+
|
|
167
|
+
Full documentation is available at [farid.one/cnsplots](https://cnsplots.farid.one/)
|
|
168
|
+
|
|
169
|
+
- [Installation Guide](https://cnsplots.farid.one/installation.html)
|
|
170
|
+
- [API Reference](https://cnsplots.farid.one/api.html)
|
|
171
|
+
- [Examples Gallery](https://cnsplots.farid.one/examples/index.html)
|
|
172
|
+
|
|
173
|
+
## Key Concepts
|
|
174
|
+
|
|
175
|
+
### Figure Dimensions
|
|
176
|
+
|
|
177
|
+
Specify sizes in **pixels** for precise control:
|
|
178
|
+
|
|
179
|
+
```python
|
|
180
|
+
cns.figure(height=150, width=100) # Creates 150px ร 100px figure
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Color Palettes
|
|
184
|
+
|
|
185
|
+
Access curated color palettes:
|
|
186
|
+
|
|
187
|
+
```python
|
|
188
|
+
# Qualitative palettes (for categorical data)
|
|
189
|
+
cns.figure(color_cycle="Ecotyper1") # Default, optimized for journals
|
|
190
|
+
cns.figure(color_cycle="Set1") # ColorBrewer Set1
|
|
191
|
+
|
|
192
|
+
# Sequential palettes (for continuous data)
|
|
193
|
+
cns.figure(color_map="parula") # MATLAB-style
|
|
194
|
+
cns.figure(color_map="gnuplot") # Default sequential
|
|
195
|
+
|
|
196
|
+
# Get individual colors
|
|
197
|
+
red = cns.RED
|
|
198
|
+
blue = cns.BLUE
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Statistical Tests
|
|
202
|
+
|
|
203
|
+
Many plot functions include built-in statistical testing:
|
|
204
|
+
|
|
205
|
+
```python
|
|
206
|
+
# Boxplot with Mann-Whitney U test
|
|
207
|
+
cns.boxplot(data=df, x="group", y="value", pairs="all")
|
|
208
|
+
|
|
209
|
+
# Barplot with Welch's t-test
|
|
210
|
+
cns.barplot(data=df, x="group", y="value", pairs=[("A", "B")])
|
|
211
|
+
|
|
212
|
+
# Stackplot with Fisher's exact test
|
|
213
|
+
cns.stackplot(data=df, x="group", y="category", pairs=[("A", "B")])
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### Export for Publication
|
|
217
|
+
|
|
218
|
+
```python
|
|
219
|
+
# SVG for vector graphics (recommended)
|
|
220
|
+
plt.savefig("figure.svg")
|
|
221
|
+
|
|
222
|
+
# High-resolution PNG
|
|
223
|
+
plt.savefig("figure.png", dpi=300)
|
|
224
|
+
|
|
225
|
+
# PDF with editable text
|
|
226
|
+
plt.savefig("figure.pdf")
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
## Requirements
|
|
230
|
+
|
|
231
|
+
- Python โฅ 3.9
|
|
232
|
+
- Core: matplotlib, numpy, pandas, seaborn
|
|
233
|
+
- Optional: lifelines, gseapy, scanpy (for specific plot types)
|
|
234
|
+
|
|
235
|
+
See [pyproject.toml](pyproject.toml) for complete dependency list.
|
|
236
|
+
|
|
237
|
+
## Contributing
|
|
238
|
+
|
|
239
|
+
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
|
|
240
|
+
|
|
241
|
+
### Development Setup
|
|
242
|
+
|
|
243
|
+
Follow the development installation instructions above, then use `make lint` to run formatters and linters before submitting a PR.
|
|
244
|
+
|
|
245
|
+
## Citation
|
|
246
|
+
|
|
247
|
+
If you use cnsplots in your research, please cite:
|
|
248
|
+
|
|
249
|
+
```bibtex
|
|
250
|
+
@software{cnsplots,
|
|
251
|
+
author = {Rashidi, Farid},
|
|
252
|
+
title = {cnsplots: Publication-Ready Scientific Plots},
|
|
253
|
+
year = {2026},
|
|
254
|
+
url = {https://github.com/faridrashidi/cnsplots}
|
|
255
|
+
}
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
## License
|
|
259
|
+
|
|
260
|
+
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details.
|
|
261
|
+
|
|
262
|
+
## Acknowledgments
|
|
263
|
+
|
|
264
|
+
Built with:
|
|
265
|
+
|
|
266
|
+
- [matplotlib](https://matplotlib.org/) - Core plotting library
|
|
267
|
+
- [seaborn](https://seaborn.pydata.org/) - Statistical visualizations
|
|
268
|
+
- [lifelines](https://lifelines.readthedocs.io/) - Survival analysis
|
|
269
|
+
- [PyComplexHeatmap](https://github.com/DingWB/PyComplexHeatmap) - Complex heatmaps
|
|
270
|
+
- [UpSetPlot](https://upsetplot.readthedocs.io/) - Set intersections
|
|
271
|
+
|
|
272
|
+
Inspired by the visualization standards of Cell, Nature, and Science journals.
|
|
273
|
+
|
|
274
|
+
## Support
|
|
275
|
+
|
|
276
|
+
- ๐ [Documentation](https://cnsplots.farid.one/)
|
|
277
|
+
- ๐ [Issue Tracker](https://github.com/faridrashidi/cnsplots/issues)
|
|
278
|
+
- ๐ฌ [Discussions](https://github.com/faridrashidi/cnsplots/discussions)
|
|
279
|
+
|
|
280
|
+
## Related Projects
|
|
281
|
+
|
|
282
|
+
- [matplotlib](https://matplotlib.org/) - The foundation of Python plotting
|
|
283
|
+
- [seaborn](https://seaborn.pydata.org/) - Statistical data visualization
|
|
284
|
+
- [plotnine](https://plotnine.readthedocs.io/) - Grammar of graphics for Python
|
|
285
|
+
- [altair](https://altair-viz.github.io/) - Declarative visualization
|
|
286
|
+
|
|
287
|
+
---
|
|
288
|
+
|
|
289
|
+
<div align="center">
|
|
290
|
+
|
|
291
|
+
Made with โค๏ธ for the scientific community
|
|
292
|
+
|
|
293
|
+
[โญ Star us on GitHub](https://github.com/faridrashidi/cnsplots) ยท [๐ Read the Docs](https://cnsplots.farid.one/)
|
|
294
|
+
|
|
295
|
+
</div>
|