From a0dbf10b88180dc6c467603d66dbe972b10162e3 Mon Sep 17 00:00:00 2001 From: emunozdc Date: Thu, 20 Jun 2024 21:15:17 +0200 Subject: [PATCH] Update docs. --- README.md | 11 +++++++---- docs/prp_options.rst | 3 ++- docs/tutorial.rst | 3 +-- src/pyranges_plot/core.py | 20 +++++++++++--------- src/pyranges_plot/plot_main.py | 14 ++++++++------ src/pyranges_plot/pr_register_plot.py | 19 ++++++++++++++++++- 6 files changed, 47 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index ae41f4a..b4eac89 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,11 @@ # pyranges_plot -Gene visualization package for dataframe objects generated with [PyRanges](https://pyranges.readthedocs.io/en/latest/index.html). - - +Gene visualization package for dataframe objects generated with [PyRanges](https://pyranges1.readthedocs.io/). +Pyranges is scbfjgnk... +PyRanges Plot significantly facilitates genomic data +interpretation by providing powerful, customizable, and user-friendly visualizations. It +effectively covers the gap between data manipulation and visualization, thereby accelerating +the analysis workflow in genomic research. ## Overview The goal is getting a plot displaying a series of genes, transcripts, or any kind @@ -57,7 +60,7 @@ since the graphical dependencies are not installed. ## Documentation -Pyranges Plot documentation and tutorial can be found at [readthedocs](https://pyranges-plot.readthedocs.io/en/latest/). +Pyranges Plot documentation and tutorial can be found at https://pyranges-plot.readthedocs.io/. ## Coming soon diff --git a/docs/prp_options.rst b/docs/prp_options.rst index afac774..dd11bf7 100644 --- a/docs/prp_options.rst +++ b/docs/prp_options.rst @@ -1,7 +1,8 @@ Customizable options -------------------- -Functions related to check, set and reset the plot customizable options. +Functions related to check, set and reset the plot customizable options. For graphical +explanation check the first figure of the :ref:`tutorial `. .. automodule:: pyranges_plot :members: diff --git a/docs/tutorial.rst b/docs/tutorial.rst index 488b573..488117d 100644 --- a/docs/tutorial.rst +++ b/docs/tutorial.rst @@ -482,5 +482,4 @@ is the following: .. code-block:: import pyranges_plot as prp - prp.set_engine("matplotlib") - prp.register_plot() + prp.register_plot("matplotlib") diff --git a/src/pyranges_plot/core.py b/src/pyranges_plot/core.py index 333c4e3..50314f5 100644 --- a/src/pyranges_plot/core.py +++ b/src/pyranges_plot/core.py @@ -47,7 +47,7 @@ def set_id_col(name): def get_id_col(): - """Shows the current defined ID column (id_col).""" + """Returns the currently defined ID column (id_col).""" return ID_COL @@ -58,7 +58,7 @@ def get_id_col(): def set_engine(name): """ - Defines the engine for the plots + Defines the engine for the plots. Parameters ---------- @@ -78,7 +78,7 @@ def set_engine(name): def get_engine(): - """Shows the current defined engine.""" + """Returns the currently defined engine.""" return ENGINE @@ -120,7 +120,7 @@ def get_warnings(): def set_theme(name): """ - Defines the engine for the plots + Defines the color theme for the plots. Parameters ---------- @@ -166,7 +166,7 @@ def set_theme(name): def get_theme(): - """Shows the current defined engine.""" + """Returns the currently defined color theme.""" return theme @@ -176,17 +176,18 @@ def get_theme(): def set_options(varname, value=None): """ - Define some features of the plot layout. + Define some feature options of the plot layout. Parameters ---------- varname: {str, dict} - Name of the variable to change, or dictionary with the variable: value pairs. + Name of the variable to change, or dictionary with the {variable: value} pairs. + To check the available customizable options use prp.print_default(). value: - New value of the variable to be assigned if needed. + New value of the variable to be assigned to varname if needed. Examples -------- @@ -196,6 +197,8 @@ def set_options(varname, value=None): >>> prp.set_options('title_size', 20) + >>> prp.set_options({'plot_background': 'magenta', 'title_size': 20}) + """ if isinstance(varname, str): @@ -279,7 +282,6 @@ def reset_options(varname="all"): >>> prp.reset_options(['title_size', 'tag_background']) - >>> prp.reset_options('title_color') """ plot_features_dict_in_use = get_options() diff --git a/src/pyranges_plot/plot_main.py b/src/pyranges_plot/plot_main.py index 5bcfc7a..f8d81e9 100644 --- a/src/pyranges_plot/plot_main.py +++ b/src/pyranges_plot/plot_main.py @@ -154,7 +154,7 @@ def plot( provided as a string containing the column names of the values to be shown within curly brackets. For example if you want to show the value of the pointed gene for the column "col1" a valid tooltip string could be: "Value of col1: {col1}". Note that the values in the curly brackets are not - strings. If you want to introduce a newline you can use "\n". + strings. If you want to introduce a newline you can use a newline character "\" + "n". to_file: {str, tuple}, default None Name of the file to export specifying the desired extension. The supported extensions are '.png' and '.pdf'. @@ -175,17 +175,19 @@ def plot( >>> import pyranges as pr, pyranges_plot as prp + >>> prp.set_engine('plotly') + >>> p = pr.PyRanges({"Chromosome": [1]*5, "Strand": ["+"]*3 + ["-"]*2, "Start": [10,20,30,25,40], "End": [15,25,35,30,50], "transcript_id": ["t1"]*3 + ["t2"]*2}, "feature1": ["A", "B", "C", "A", "B"]) - >>> plot(p, engine='plt', id_col="transcript_id", max_shown=25, colormap='Set3') + >>> plot(p, id_col="transcript_id", max_shown=25, colormap='Set3', text=False) - >>> plot(p, engine='matplotlib', id_col="transcript_id", color_col='Strand', colormap={'+': 'green', '-': 'red'}) + >>> plot(p, id_col="transcript_id", color_col='Strand', colormap={'+': 'green', '-': 'red'}) - >>> plot(p, engine='ply', id_col="transcript_id", limits = {'1': (1000, 50000), '2': None, '3': (10000, None)}) + >>> plot(p, limits = {'1': (1000, 50000), '2': None, '3': (10000, None)}, title_chr="Chrom: {chrom}") - >>> plot(p, engine='plotly', id_col="transcript_id", shrink=True, tooltip = "Feature1: {feature1}") + >>> plot([p, p], id_col="transcript_id", shrink=True, tooltip = "Feature1: {feature1}") - >>> plot(data, engine='plt', id_col="transcript_id", color_col='Strand', packed=False, to_file='my_plot.pdf') + >>> plot([p, p], id_col="transcript_id", y_labels=["first_p", "second_p"], packed=False, to_file='my_plot.pdf') """ # Treat input data as list diff --git a/src/pyranges_plot/pr_register_plot.py b/src/pyranges_plot/pr_register_plot.py index db76c4f..c8df8f8 100644 --- a/src/pyranges_plot/pr_register_plot.py +++ b/src/pyranges_plot/pr_register_plot.py @@ -4,7 +4,24 @@ def register_plot(engine=None): - """Register the plot function as a method to PyRanges.""" + """ + Register the plot function as a method to PyRanges. + + Parameters + ---------- + engine: {str} + + String defining the engine for plotting: Matplotlib ('plt', 'matplotlib') or Plotly ('ply', 'plotly'). + + Examples + -------- + >>> import pyranges_plot as prp + + >>> prp.register_plot() + + >>> prp.register_plot("matplotlib") + + """ if engine is not None: set_engine(engine)