Skip to content

Commit

Permalink
first merge to main
Browse files Browse the repository at this point in the history
  • Loading branch information
shitohana committed Dec 29, 2023
1 parent 87e290b commit eda082e
Show file tree
Hide file tree
Showing 120 changed files with 866 additions and 1,328 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 0 additions & 6 deletions docs/_templates/autosummary/module.rst

This file was deleted.

2 changes: 2 additions & 0 deletions docs_copy/_templates/class.rst → docs/_templates/class.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
:template: method.rst
{% for item in methods %}
{% if item != "__init__" %}
{%- if item not in inherited_members %}
~{{ name }}.{{ item }}
{% endif %}
{% endif %}
{%- endfor %}
{% endif %}
{% endblock %}
File renamed without changes.
File renamed without changes.
6 changes: 0 additions & 6 deletions docs/_templates/module.rst

This file was deleted.

21 changes: 13 additions & 8 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,35 @@
import os
import sys

project = 'BismarkPlot'
copyright = '2023, shitohana'
author = 'shitohana'
release = '1.2'
import os
import sys
release = '1.4.1'
sys.path.insert(0, os.path.abspath('../src'))
sys.path.insert(0, os.path.abspath('../src/bismarkplot'))
sys.path.append(os.path.abspath('.'))


extensions = [
# TODO add myst_parser to dependencies
'myst_parser',
'sphinx.ext.intersphinx',
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx_autodoc_typehints',
'sphinx.ext.napoleon'
]

templates_path = ['_templates']
autodoc_mock_imports = ['polars', 'matplotlib', 'numpy', 'scipy', 'pandas', 'pyarrow', 'pyreadr', 'dynamicTreeCut']
autodoc_mock_imports = ['polars', 'matplotlib', 'numpy', 'scipy', 'pandas', 'pyarrow', 'pyreadr', 'dynamicTreeCut', 'plotly', 'numba', 'pathlib']
autodoc_default_options = {
'members': True,
# 'exclude-members': '__init__'
'exclude-members': '__init__'
}
autosummary_generate = True
autodoc_member_order = 'bysource'
add_module_names = False
html_short_title = 'BismarkPlot Documentation'


html_theme = 'sphinx_book_theme'
html_theme = 'sphinx_rtd_theme'
html_show_sourcelink = False

File renamed without changes
File renamed without changes
Binary file added docs/images/boxplot/vp_ara_bradi_plotly.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Binary file added docs/images/lineplot/ara_NO_major_labels.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/lineplot/ara_NO_minor_labels.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/lineplot/ara_bradi_mpl.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added docs/images/lineplot/ara_custom_label.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/lineplot/ara_major_labels.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/lineplot/ara_minor_labels.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
23 changes: 12 additions & 11 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ Welcome to BismarkPlot's documentation!
=======================================
This page gives an overview of all public objects, functions and methods.


.. toctree::
:caption: Tutorials

markdowns/test

.. autosummary::
:toctree: _autosummary
:template: module.rst

BismarkPlot.Metagene
BismarkPlot.MetageneFiles
BismarkPlot.Genome
BismarkPlot.ChrLevels
BismarkPlot.Clustering
BismarkPlot.BismarkBase
BismarkPlot.LinePlot
BismarkPlot.HeatMap
.. toctree::
:caption: Reference
:maxdepth: 1

_metagene
_plots
_binom
_genome
128 changes: 128 additions & 0 deletions docs/markdowns/test.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# LinePlot Tutorial

This tutorial will explain you how to calculate, visualize and configure line-plots.

## Single metagene

### Initialization

```python
from bismarkplot import *

# Firstly, we need to read the regions annotation (e.g. reference genome .gff)
genome = Genome.from_gff("path/to/genome.gff")
# Next we need to filter regions of interest from the genome
genes = genome.gene_body(min_length=0, flank_length=2000)

# Now we need to calculate metagene data (e.g. from Bismark output)
metagene = bismarkplot.Metagene.from_bismark(
file="path/to/CX_report.txt",
genome=genes, # filtered regions
up_windows=500,
body_windows=1000,
down_windows=500
)

# Our metagene contains all methylation contexts and both strands, so we need to filter it
# (OPTIONAL for line-plot)
filtered = metagene.filter(context="CG", strand="+")

# LinePlot now can be created
lp = filtered.line_plot()
```

### Basic usage

The easiest way to get the plot is to call `.draw_mpl()` or `.draw_plotly()` methods to get matplotlib and Plotly
versions of plots respectively

```python
figure = lp.draw_mpl()
figure.show()
```

![basic line-plot mpl](../images/lineplot/lp_ara_mpl.png)

Or for Plotly version

```python
figure = lp.draw_mpl()
figure.show()
```

#### No Metagene filtering

If metagene was not filtered by context, line-plot for all contexts on the same figure will be created

```python
lp = metagene.line_plot() # Metagene from previous example

figure = lp.draw_mpl()
figure.show()
```

![multi line-plot mpl](../images/lineplot/ara_multi_mpl.png)

And for plotly version

```python
figure = lp.draw_mpl()
figure.show()
```

![multi line-plot plotly](../images/lineplot/ara_multi_plotly.png)


### Advanced configuration

Examples for matplotlib version of plots will be shown, but Plotly version is identical.

For all examples we use [metagene filtered by CG context](#initialization).

#### `label` parameter

Custom label can be set for line-plot using `label` parameter:

```python
lp.draw_mpl(label="My custom label")
```

![line-plot mpl label](../images/lineplot/ara_custom_label.png)

#### `minor_labels` parameter

Labels for upstream, body and downstream regions can be changed to custom, but **exactly 3** need to be provided.

Set ``[]`` to disable.


```python
lp.draw_mpl(minor_labels=["-2000kb", "Gene", "+2000kb"])
```

![line-plot mpl label](../images/lineplot/ara_minor_labels.png)

```python
lp.draw_mpl(minor_labels=[])
```

![line-plot mpl label](../images/lineplot/ara_NO_minor_labels.png)

#### `major_labels` parameter

Labels for body region start and end (e.g. TSS, TES) can be changed to custom, but **exactly 2** need to be provided.

Set ``[]`` to disable.


```python
lp.draw_mpl(major_labels=["Start", "End"], minor_labels=[])
```

![line-plot mpl label](../images/lineplot/ara_major_labels.png)

```python
lp.draw_mpl(major_labels=[], minor_labels=["-2000kb", "Gene", "+2000kb"])
```

![line-plot mpl label](../images/lineplot/ara_NO_major_labels.png)
2 changes: 2 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ typing-extensions==4.5.0
tzdata==2023.3
sphinx_autodoc_typehints==1.23.0
sphinx_book_theme==1.0.1
myst-parser==2.0.0

Empty file removed docs_copy/.nojekyll
Empty file.
20 changes: 0 additions & 20 deletions docs_copy/Makefile

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

4 changes: 0 additions & 4 deletions docs_copy/_Binom/_method/bismarkplot.RegionStat.filter.rst

This file was deleted.

This file was deleted.

4 changes: 0 additions & 4 deletions docs_copy/_Binom/_method/bismarkplot.RegionStat.save.rst

This file was deleted.

26 changes: 0 additions & 26 deletions docs_copy/_Binom/bismarkplot.BinomialData.rst

This file was deleted.

32 changes: 0 additions & 32 deletions docs_copy/_Binom/bismarkplot.RegionStat.rst

This file was deleted.

4 changes: 0 additions & 4 deletions docs_copy/_Genome/_method/bismarkplot.Genome.all.rst

This file was deleted.

4 changes: 0 additions & 4 deletions docs_copy/_Genome/_method/bismarkplot.Genome.cds.rst

This file was deleted.

4 changes: 0 additions & 4 deletions docs_copy/_Genome/_method/bismarkplot.Genome.exon.rst

This file was deleted.

4 changes: 0 additions & 4 deletions docs_copy/_Genome/_method/bismarkplot.Genome.from_custom.rst

This file was deleted.

4 changes: 0 additions & 4 deletions docs_copy/_Genome/_method/bismarkplot.Genome.from_gff.rst

This file was deleted.

4 changes: 0 additions & 4 deletions docs_copy/_Genome/_method/bismarkplot.Genome.gene_body.rst

This file was deleted.

4 changes: 0 additions & 4 deletions docs_copy/_Genome/_method/bismarkplot.Genome.near_TES.rst

This file was deleted.

Loading

0 comments on commit eda082e

Please sign in to comment.