# Peakoscope
[![PyPI version](https://badge.fury.io/py/peakoscope.svg)](https://badge.fury.io/py/peakoscope)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
Peakoscope is a python package for hierarchical analysis of peak and valley regions in numeric data.
![peak plot](https://github.com/eivindtostesen/hierarchical_peak_finding/blob/v1.0.0/output.png?raw=true "fig, (peaks.plot.ax, valleys.plot.ax) = plt.subplots(2, 1, sharex=True, figsize=(4, 4));
peaks.plot.crowns(peaks.size_filter(maxsize=7))
peaks.plot.bounding_boxes(peaks.size_filter(maxsize=7))
valleys.plot.crowns(valleys.size_filter(maxsize=7), facecolor='C9')
valleys.plot.bounding_boxes(valleys.size_filter(maxsize=7), edgecolor='C1')
peaks.plot.ax.set_title('Peak regions')
valleys.plot.ax.set_title('Valley regions')
peaks.plot.ax.plot(X, Y, linewidth=2, color='black')
valleys.plot.ax.plot(X, Y, linewidth=2, color='black');")
* Peak and valley regions can be nested, for example, when a large peak region contains smaller subpeak regions.
* Based on a one-pass algorithm that finds all peak regions and orders them into a tree.
* Classes for peak/valley objects and tree objects.
* Optional interfaces to matplotlib, pandas and polars.
## Usage examples
Compute the tree of nested peak regions in a data set:
```python
>>> import peakoscope
>>> data = [10, 30, 40, 30, 10, 50, 70, 70, 50, 80]
>>> print(peakoscope.tree(data))
0:10
├─5:10
│ ├─9:10
│ └─6:8
└─1:4
└─2:3
```
From the tree, select default peak regions and print their subarrays of data:
```python
>>> for peak in peakoscope.tree(data).size_filter():
... print(peak.subarray(data))
...
[80]
[70, 70]
[30, 40, 30]
```
## Howto files
The github repo contains tutorials and a glossary:
* [plotting_tutorial.ipynb](https://github.com/eivindtostesen/hierarchical_peak_finding/blob/v1.0.0/plotting_tutorial.ipynb)
* [dataframes_tutorial.ipynb](https://github.com/eivindtostesen/hierarchical_peak_finding/blob/v1.0.0/dataframes_tutorial.ipynb)
* [glossary.rst](https://github.com/eivindtostesen/hierarchical_peak_finding/blob/v1.0.0/glossary.rst)
## Authors
* Eivind Tøstesen, <contact@tostesen.no>
## License
Copyright (C) 2021-2024 Eivind Tøstesen. This software is licensed under [GPLv3](https://github.com/eivindtostesen/hierarchical_peak_finding/blob/v1.0.0/LICENSE?raw=true "included LICENSE file")
## Citation
Citation can include one or more of:
* Peakoscope + version
* Github URL: https://github.com/eivindtostesen/hierarchical_peak_finding
* PyPI URL: https://pypi.org/project/peakoscope/
* The open-access article:
>Tøstesen, E.
>A stitch in time: Efficient computation of genomic DNA melting bubbles.
>*Algorithms for Molecular Biology*, 3, 10 (2008).
>[DOI: 10.1186/1748-7188-3-10](http://dx.doi.org/10.1186/1748-7188-3-10)
Raw data
{
"_id": null,
"home_page": "",
"name": "peakoscope",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "peak,valley,time series,random walk,nested regions,hierarchical",
"author": "",
"author_email": "Eivind T\u00f8stesen <contact@tostesen.no>",
"download_url": "https://files.pythonhosted.org/packages/35/ca/15b1867d3fc966d6fdbeb9bde06f54a7a18a3115a12896b63a3ca283b71c/peakoscope-1.0.0.tar.gz",
"platform": null,
"description": "# Peakoscope\n[![PyPI version](https://badge.fury.io/py/peakoscope.svg)](https://badge.fury.io/py/peakoscope)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n\nPeakoscope is a python package for hierarchical analysis of peak and valley regions in numeric data.\n\n![peak plot](https://github.com/eivindtostesen/hierarchical_peak_finding/blob/v1.0.0/output.png?raw=true \"fig, (peaks.plot.ax, valleys.plot.ax) = plt.subplots(2, 1, sharex=True, figsize=(4, 4));\npeaks.plot.crowns(peaks.size_filter(maxsize=7))\npeaks.plot.bounding_boxes(peaks.size_filter(maxsize=7))\nvalleys.plot.crowns(valleys.size_filter(maxsize=7), facecolor='C9')\nvalleys.plot.bounding_boxes(valleys.size_filter(maxsize=7), edgecolor='C1')\npeaks.plot.ax.set_title('Peak regions')\nvalleys.plot.ax.set_title('Valley regions')\npeaks.plot.ax.plot(X, Y, linewidth=2, color='black')\nvalleys.plot.ax.plot(X, Y, linewidth=2, color='black');\")\n\n* Peak and valley regions can be nested, for example, when a large peak region contains smaller subpeak regions.\n* Based on a one-pass algorithm that finds all peak regions and orders them into a tree.\n* Classes for peak/valley objects and tree objects.\n* Optional interfaces to matplotlib, pandas and polars.\n\n## Usage examples\nCompute the tree of nested peak regions in a data set:\n```python\n>>> import peakoscope\n>>> data = [10, 30, 40, 30, 10, 50, 70, 70, 50, 80]\n>>> print(peakoscope.tree(data))\n0:10\n\u251c\u25005:10\n\u2502 \u251c\u25009:10\n\u2502 \u2514\u25006:8\n\u2514\u25001:4\n \u2514\u25002:3\n```\nFrom the tree, select default peak regions and print their subarrays of data:\n```python\n>>> for peak in peakoscope.tree(data).size_filter():\n... print(peak.subarray(data))\n... \n[80]\n[70, 70]\n[30, 40, 30]\n```\n\n## Howto files\nThe github repo contains tutorials and a glossary:\n* [plotting_tutorial.ipynb](https://github.com/eivindtostesen/hierarchical_peak_finding/blob/v1.0.0/plotting_tutorial.ipynb)\n* [dataframes_tutorial.ipynb](https://github.com/eivindtostesen/hierarchical_peak_finding/blob/v1.0.0/dataframes_tutorial.ipynb)\n* [glossary.rst](https://github.com/eivindtostesen/hierarchical_peak_finding/blob/v1.0.0/glossary.rst)\n\n## Authors\n* Eivind T\u00f8stesen, <contact@tostesen.no>\n\n## License\nCopyright (C) 2021-2024 Eivind T\u00f8stesen. This software is licensed under [GPLv3](https://github.com/eivindtostesen/hierarchical_peak_finding/blob/v1.0.0/LICENSE?raw=true \"included LICENSE file\")\n\n## Citation\nCitation can include one or more of:\n\n* Peakoscope + version\n* Github URL: https://github.com/eivindtostesen/hierarchical_peak_finding\n* PyPI URL: https://pypi.org/project/peakoscope/\n* The open-access article:\n\n >T\u00f8stesen, E.\n >A stitch in time: Efficient computation of genomic DNA melting bubbles.\n >*Algorithms for Molecular Biology*, 3, 10 (2008).\n >[DOI: 10.1186/1748-7188-3-10](http://dx.doi.org/10.1186/1748-7188-3-10)\n",
"bugtrack_url": null,
"license": "",
"summary": "Data analysis of peak and valley regions",
"version": "1.0.0",
"project_urls": {
"Homepage": "https://github.com/eivindtostesen/hierarchical_peak_finding",
"Issues": "https://github.com/eivindtostesen/hierarchical_peak_finding/issues"
},
"split_keywords": [
"peak",
"valley",
"time series",
"random walk",
"nested regions",
"hierarchical"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "e83f249b234f0eda39e2bc2c6f8b0e1d7e13b0726be45235a45bcfc9e92af597",
"md5": "a5b784a9242d62a35bf1ef8037761992",
"sha256": "acf8061970090e556bd8bef19d22eb71a1bf1809e8a2042c6449e0c7c252c8f2"
},
"downloads": -1,
"filename": "peakoscope-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a5b784a9242d62a35bf1ef8037761992",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 34218,
"upload_time": "2024-03-14T07:48:35",
"upload_time_iso_8601": "2024-03-14T07:48:35.840548Z",
"url": "https://files.pythonhosted.org/packages/e8/3f/249b234f0eda39e2bc2c6f8b0e1d7e13b0726be45235a45bcfc9e92af597/peakoscope-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "35ca15b1867d3fc966d6fdbeb9bde06f54a7a18a3115a12896b63a3ca283b71c",
"md5": "68dc555818a76d58b4537e6852cbe558",
"sha256": "48379c44c191602e353ebf803e61586ff5d20832f543f536db102b83ffa8fff2"
},
"downloads": -1,
"filename": "peakoscope-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "68dc555818a76d58b4537e6852cbe558",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 30076,
"upload_time": "2024-03-14T07:48:37",
"upload_time_iso_8601": "2024-03-14T07:48:37.121792Z",
"url": "https://files.pythonhosted.org/packages/35/ca/15b1867d3fc966d6fdbeb9bde06f54a7a18a3115a12896b63a3ca283b71c/peakoscope-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-14 07:48:37",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "eivindtostesen",
"github_project": "hierarchical_peak_finding",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "peakoscope"
}