Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ Note that the minimal installation by `pip install pyrangeyes` is not able to pr
since the graphical dependencies are not installed.


## Shared assets

The PyRanges cheat sheet image is kept in this repository for downstream use by the PyRanges 1.x documentation:

- [PyRanges cheat sheet](images/pyranges_cheatsheet.png)

Do not remove this image as an unreferenced local asset; it is intentionally shared across repositories.

## Documentation
Pyrangeyes documentation and tutorial can be found at https://pyrangeyes.readthedocs.io/.

8 changes: 5 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#
from docutils import nodes
import doctest
import sphinx_rtd_theme
import os
import sys

Expand All @@ -36,7 +35,6 @@
"sphinx.ext.autodoc",
"sphinx.ext.doctest",
"sphinx.ext.napoleon",
"sphinx_rtd_theme",
]
autosummary_generate = True # Enable summary table generation

Expand Down Expand Up @@ -98,7 +96,11 @@ def _doctest_plot(*args, **kwargs):

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = "sphinx_rtd_theme"
html_theme = "pydata_sphinx_theme"
html_theme_options = {
"show_toc_level": 2,
"navigation_with_keys": False,
}


def monospaced_link(name, rawtext, text, lineno, inliner, options={}, content=[]):
Expand Down
Binary file modified docs/images/my_plot.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 removed docs/images/options_fig_wm.png
Binary file not shown.
Binary file modified docs/images/prp_rtd_01.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 modified docs/images/prp_rtd_01_mpl.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 modified docs/images/prp_rtd_02.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 modified docs/images/prp_rtd_02_mpl.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 removed docs/images/prp_rtd_03.png
Binary file not shown.
Binary file modified docs/images/prp_rtd_04.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 modified docs/images/prp_rtd_04_mpl.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 modified docs/images/prp_rtd_05.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 modified docs/images/prp_rtd_05_mpl.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 modified docs/images/prp_rtd_06.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 modified docs/images/prp_rtd_06_mpl.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 modified docs/images/prp_rtd_07.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 modified docs/images/prp_rtd_07_mpl.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 modified docs/images/prp_rtd_08.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 modified docs/images/prp_rtd_08_mpl.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 modified docs/images/prp_rtd_09.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 modified docs/images/prp_rtd_09_mpl.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 modified docs/images/prp_rtd_10.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 modified docs/images/prp_rtd_10_mpl.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 removed docs/images/prp_rtd_11.png
Binary file not shown.
Binary file removed docs/images/prp_rtd_12.png
Binary file not shown.
Binary file modified docs/images/prp_rtd_13.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 modified docs/images/prp_rtd_13_mpl.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 modified docs/images/prp_rtd_14.png
Binary file modified docs/images/prp_rtd_14_mpl.png
Binary file modified docs/images/prp_rtd_15.png
Binary file modified docs/images/prp_rtd_15_mpl.png
Binary file modified docs/images/prp_rtd_16.png
Binary file modified docs/images/prp_rtd_16_mpl.png
Binary file modified docs/images/prp_rtd_17.png
Binary file modified docs/images/prp_rtd_17_mpl.png
Binary file modified docs/images/prp_rtd_18.png
Binary file modified docs/images/prp_rtd_18_mpl.png
Binary file removed docs/images/prp_rtd_19.png
Diff not rendered.
Binary file removed docs/images/prp_rtd_20.png
Diff not rendered.
Binary file modified docs/images/prp_rtd_21.png
Binary file modified docs/images/prp_rtd_21_mpl.png
Binary file removed docs/images/prp_rtd_22.png
Diff not rendered.
Binary file removed docs/images/prp_rtd_23.png
Diff not rendered.
Binary file removed docs/images/prp_rtd_24.png
Diff not rendered.
Binary file removed docs/images/prp_rtd_25.png
Diff not rendered.
Binary file removed docs/images/prp_rtd_26.png
Diff not rendered.
Binary file removed docs/images/prp_rtd_28.png
Diff not rendered.
Binary file modified docs/images/prp_rtd_29.png
Binary file modified docs/images/prp_rtd_29_mpl.png
Binary file modified docs/images/prp_rtd_30.png
Binary file modified docs/images/prp_rtd_30_mpl.png
Binary file modified docs/images/prp_rtd_31.png
Binary file modified docs/images/prp_rtd_31_mpl.png
Binary file modified docs/images/prp_rtd_32.png
Binary file modified docs/images/prp_rtd_32_mpl.png
Binary file modified docs/images/prp_rtd_33.png
Binary file modified docs/images/prp_rtd_33_mpl.png
Binary file modified docs/images/prp_rtd_34.png
Binary file modified docs/images/prp_rtd_34_mpl.png
Binary file modified docs/images/prp_rtd_35.png
Binary file modified docs/images/prp_rtd_35_mpl.png
Binary file removed docs/images/prp_rtd_36.png
Diff not rendered.
Binary file removed docs/images/prp_rtd_37.png
Diff not rendered.
Binary file modified docs/images/prp_rtd_38.png
Binary file modified docs/images/prp_rtd_38_mpl.png
Binary file modified docs/images/prp_rtd_39.png
Binary file modified docs/images/prp_rtd_39_mpl.png
Binary file modified docs/images/prp_rtd_40.png
Binary file modified docs/images/prp_rtd_40_mpl.png
Binary file removed docs/images/prp_rtd_41.png
Diff not rendered.
Binary file modified docs/images/prp_rtd_43_mpl.png
168 changes: 77 additions & 91 deletions docs/tutorial.rst

Large diffs are not rendered by default.

Binary file removed examples/fig_1a.png
Diff not rendered.
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ plotly =
dash_bootstrap_components >= 1.5.0
docs =
sphinx >= 7.3.7
sphinx_rtd_theme >= 2.0.0
pydata-sphinx-theme >= 0.16.0
sphinx-autoapi >= 3.1.1
sphinxcontrib-napoleon >= 0.7
memory-profiler >= 0.61.0
Expand All @@ -53,7 +53,7 @@ all =
dash >= 2.14.0
dash_bootstrap_components >= 1.5.0
sphinx >= 7.3.7
sphinx_rtd_theme >= 2.0.0
pydata-sphinx-theme >= 0.16.0
sphinx-autoapi >= 3.1.1
sphinxcontrib-napoleon >= 0.7
memory-profiler >= 0.61.0
Expand Down
10 changes: 8 additions & 2 deletions src/pyrangeyes/data_preparation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,7 @@ def assign_label_rows(
track_scales=None,
pack_by_track=None,
text_position_by_track=None,
text_avoid_by_track=None,
label_size=None,
):
"""
Expand Down Expand Up @@ -1109,7 +1110,12 @@ def assign_label_rows(
if text_position_by_track is None
else text_position_by_track.get(pr_val, "left")
)
effective_text_avoid = text_avoid and track_scale >= 1
track_text_avoid = (
text_avoid
if text_avoid_by_track is None
else bool(text_avoid_by_track.get(pr_val, text_avoid))
)
effective_text_avoid = track_text_avoid and track_scale >= 1
# Font size is specified in points by the rendering engines, while
# layout is expressed in pyrangeyes' row units. Reserve a modest
# vertical text band for above/below labels: enough to prevent
Expand All @@ -1118,7 +1124,7 @@ def assign_label_rows(
text_extra_y = (
0.0
if not (effective_text_avoid and text_position in {"above", "below"})
else float(label_size or 12) / 40.0
else float(label_size or 12) / 26.0
)
track_height = interval_height * track_scale
track_gap = v_spacer * track_scale
Expand Down
53 changes: 40 additions & 13 deletions src/pyrangeyes/matplotlib_base/fig_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import matplotlib as mpl
import matplotlib.pyplot as plt
import matplotlib.colors as mcolors
import matplotlib.gridspec as gridspec
from matplotlib.ticker import ScalarFormatter
from matplotlib.ticker import MaxNLocator
from matplotlib.patches import Rectangle
Expand Down Expand Up @@ -30,7 +29,7 @@ def ax_display(ax, title, t_dict, plot_back, plot_border):
"""

if title:
ax.set_title(title, fontdict=t_dict)
ax.set_title(title, fontdict=t_dict, pad=8)

ax.set_facecolor(plot_back)
plt.setp(ax.spines.values(), color=plot_border)
Expand Down Expand Up @@ -184,22 +183,53 @@ def _fmt_title(row, fallback_chrom):
num_additional_rows = len(additional_plots) if add_aligned_plots else 0
total_rows = num_main_rows + num_additional_rows
row_heights_additional = [height] * num_additional_rows
row_heights = chrmd_df_grouped["y_height"].to_list() + row_heights_additional

# Start figure
fig = plt.figure(figsize=(x, y), facecolor=figure_bg)

gs = gridspec.GridSpec(
total_rows,
1,
height_ratios=chrmd_df_grouped["y_height"].to_list() + row_heights_additional,
) # size of chromosome subplot according to number of gene rows
fig_w_px = fig.get_figwidth() * fig.dpi
fig_h_px = fig.get_figheight() * fig.dpi
left_px = 96
right_px = 24
top_px = 18
bottom_px = 28
title_px = max(34, int(title_dict_plt.get("size", 18) * 1.9))
xaxis_px = 46
panel_gap_px = 6
# Figure-level legends live in a reserved bottom strip. Keeping this out of
# the axes placement means legends do not shrink or overlap plot panels.
if legend:
bottom_px += 80

non_data_px = (
top_px
+ bottom_px
+ total_rows * (title_px + xaxis_px)
+ max(0, total_rows - 1) * panel_gap_px
)
available_data_px = max(1, fig_h_px - non_data_px)
row_sum = sum(row_heights) or 1
row_data_px = [available_data_px * h / row_sum for h in row_heights]

left = left_px / fig_w_px
width = max(0.1, (fig_w_px - left_px - right_px) / fig_w_px)
y_cursor = fig_h_px - top_px

def _add_layout_axis(row_index):
nonlocal y_cursor
y_cursor -= title_px
axis_h = row_data_px[row_index]
bottom = y_cursor - axis_h
ax = fig.add_axes([left, bottom / fig_h_px, width, axis_h / fig_h_px])
y_cursor = bottom - xaxis_px - panel_gap_px
return ax

# one plot per chromosome
axes = []
for i in range(total_rows):
if i < num_main_rows:
chrom = chrmd_df_grouped.index[i]
axes.append(plt.subplot(gs[i]))
axes.append(_add_layout_axis(i))
ax = axes[i]
# Adjust plot display
ax_display(ax, titles[i], title_dict_plt, plot_background, plot_border)
Expand Down Expand Up @@ -418,7 +448,7 @@ def _fmt_title(row, fallback_chrom):
ax.set_yticklabels(list(y_ticks_name))
else:
# Adding the added plot
axes.append(plt.subplot(gs[i]))
axes.append(_add_layout_axis(i))
ax = axes[i]
aligned_idx = i - num_main_rows
original_ax = additional_plots[aligned_idx]
Expand All @@ -445,7 +475,4 @@ def _fmt_title(row, fallback_chrom):
fontsize=custom_dict.get("title_size", 14), # Setting the size
color=custom_dict.get("title_color", "black"), # Setting the color
)

plt.subplots_adjust(hspace=vertical_spacing)

return fig, axes
6 changes: 6 additions & 0 deletions src/pyrangeyes/plot_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
"Default (and maximum) height of rendered interval blocks.",
" ",
),
"auto_height_px_per_unit": (
80,
"Pixels assigned to one vertical layout unit when pyrangeyes infers figure height automatically.",
" ",
),
"figure_bg": ("white", "Bakground color of the whole figure.", " "),
"grid_color": ("lightgrey", "Color of x coordinates grid lines.", " "),
"intron_color": (
Expand Down Expand Up @@ -124,6 +129,7 @@
"shrink_threshold",
"v_spacer",
"x_ticks",
"auto_height_px_per_unit",
"title_color",
"title_size",
"title_font",
Expand Down
Loading
Loading