diff --git a/.github/workflows/cdci.yml b/.github/workflows/cdci.yml index f7b6a3c..a557686 100644 --- a/.github/workflows/cdci.yml +++ b/.github/workflows/cdci.yml @@ -28,13 +28,13 @@ jobs: pip install ruff - name: Lint with ruff run: | - ruff check . + ruff check src test: name: Test runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.9", "3.10", "3.11", "3.12"] + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} diff --git a/docs/api_examples/scatter_plot.ipynb b/docs/api_examples/scatter_plot.ipynb index 3a98669..28f7a40 100644 --- a/docs/api_examples/scatter_plot.ipynb +++ b/docs/api_examples/scatter_plot.ipynb @@ -11,16 +11,16 @@ "\n", "[![Open In Colab][colab_badge]][colab_link]\n", "\n", - "[VueCore][vuecore_repo] is a Python package for creating interactive and static visualizations of multi-omics data. \n", + "[VueCore][vuecore_repo] is a Python package for creating interactive and static visualizations of multi-omics data.\n", "It is part of a broader ecosystem of tools—including [ACore][acore_repo] for data processing and [VueGen][vuegen_repo] for automated reporting—that together enable end-to-end workflows for omics analysis.\n", "\n", - "This notebook demonstrates how to generate scatter plots using plotting functions from VueCore. We showcase basic and \n", - "advanced plot configurations, highlighting key customization options such as grouping, color mapping, text annotations, and export \n", + "This notebook demonstrates how to generate scatter plots using plotting functions from VueCore. We showcase basic and\n", + "advanced plot configurations, highlighting key customization options such as grouping, color mapping, text annotations, and export\n", "to multiple file formats.\n", "\n", "## Notebook structure\n", "\n", - "First, we will set up the work environment by installing the necessary packages and importing the required libraries. Next, we will create \n", + "First, we will set up the work environment by installing the necessary packages and importing the required libraries. Next, we will create\n", "basic and advanced scatter plots.\n", "\n", "0. [Work environment setup](#0-work-environment-setup)\n", @@ -294,7 +294,8 @@ "# Imports\n", "import pandas as pd\n", "import plotly.io as pio\n", - "from vuecore.plots.basic.scatter import create_scatter_plot\n", + "\n", + "from vuecore.plots.basic.scatter import create_scatter_plot\n", "\n", "# Set the Plotly renderer based on the environment\n", "pio.renderers.default = \"notebook\"" @@ -449,14 +450,25 @@ ], "source": [ "# Created sample data\n", - "sample_df = pd.DataFrame({\n", - " \"gene_expression\": [1.2, 2.5, 3.1, 4.5, 5.2, 6.8, 3.9, 2.1],\n", - " \"log_p_value\": [0.5, 1.5, 2.0, 3.5, 4.0, 5.5, 1.8, 0.9],\n", - " \"regulation\": [\"Up\", \"Up\", \"None\", \"Down\", \"Down\", \"Down\", \"None\", \"Up\"],\n", - " \"significance_score\": [10, 20, 5, 40, 55, 80, 15, 25],\n", - " \"gene_name\": [\"GENE_A\", \"GENE_B\", \"GENE_C\", \"GENE_D\", \"GENE_E\", \"GENE_F\", \"GENE_G\", \"GENE_H\"],\n", - " \"cell_type\": [\"A\", \"B\", \"A\", \"B\", \"A\", \"B\", \"A\", \"B\"],\n", - "})\n", + "sample_df = pd.DataFrame(\n", + " {\n", + " \"gene_expression\": [1.2, 2.5, 3.1, 4.5, 5.2, 6.8, 3.9, 2.1],\n", + " \"log_p_value\": [0.5, 1.5, 2.0, 3.5, 4.0, 5.5, 1.8, 0.9],\n", + " \"regulation\": [\"Up\", \"Up\", \"None\", \"Down\", \"Down\", \"Down\", \"None\", \"Up\"],\n", + " \"significance_score\": [10, 20, 5, 40, 55, 80, 15, 25],\n", + " \"gene_name\": [\n", + " \"GENE_A\",\n", + " \"GENE_B\",\n", + " \"GENE_C\",\n", + " \"GENE_D\",\n", + " \"GENE_E\",\n", + " \"GENE_F\",\n", + " \"GENE_G\",\n", + " \"GENE_H\",\n", + " ],\n", + " \"cell_type\": [\"A\", \"B\", \"A\", \"B\", \"A\", \"B\", \"A\", \"B\"],\n", + " }\n", + ")\n", "\n", "sample_df" ] diff --git a/docs/api_examples/scatter_plot.py b/docs/api_examples/scatter_plot.py index f2785d2..2f8d7f9 100644 --- a/docs/api_examples/scatter_plot.py +++ b/docs/api_examples/scatter_plot.py @@ -1,59 +1,92 @@ -""" -Title: Scatter Plot Examples using VueCore -Description: - This script demonstrates how to generate scatter plots using VueCore — a Python package for creating - interactive and static visualizations of multi-omics data. It is part of an ecosystem including ACore - for data processing and VueGen for automated reporting. - - We showcase basic and advanced plot configurations, highlighting customization options such as grouping, - color mapping, annotations, and export to multiple formats. - -Script Structure: - 0. Work environment setup - 1. Basic scatter plot - 2. Advanced scatter plot - -Authors: - Sebastián Ayala-Ruano -Supervisors: - Henry Webel, Alberto Santos (Multiomics Network Analytics Group, DTU Biosustain) - -Institution: - Multiomics Network Analytics Group (MoNA), - Novo Nordisk Foundation Center for Biosustainability (DTU Biosustain) +# --- +# jupyter: +# jupytext: +# text_representation: +# extension: .py +# format_name: percent +# format_version: '1.3' +# jupytext_version: 1.17.2 +# kernelspec: +# display_name: vuecore-dev +# language: python +# name: python3 +# --- + +# %% [markdown] +# # Scatter Plot +# +# ![VueCore logo][vuecore_logo] +# +# [![Open In Colab][colab_badge]][colab_link] +# +# [VueCore][vuecore_repo] is a Python package for creating interactive and static visualizations of multi-omics data. +# It is part of a broader ecosystem of tools—including [ACore][acore_repo] for data processing and [VueGen][vuegen_repo] for automated reporting—that together enable end-to-end workflows for omics analysis. +# +# This notebook demonstrates how to generate scatter plots using plotting functions from VueCore. We showcase basic and +# advanced plot configurations, highlighting key customization options such as grouping, color mapping, text annotations, and export +# to multiple file formats. +# +# ## Notebook structure +# +# First, we will set up the work environment by installing the necessary packages and importing the required libraries. Next, we will create +# basic and advanced scatter plots. +# +# 0. [Work environment setup](#0-work-environment-setup) +# 1. [Basic scatter plot](#1-basic-scatter-plot) +# 2. [Advanced scatter plot](#2-advanced-scatter-plot) +# +# ## Credits and Contributors +# - This notebook was created by Sebastián Ayala-Ruano under the supervision of Henry Webel and Alberto Santos, head of the [Multiomics Network Analytics Group (MoNA)][Mona] at the [Novo Nordisk Foundation Center for Biosustainability (DTU Biosustain)][Biosustain]. +# - You can find more details about the project in this [GitHub repository][vuecore_repo]. +# +# [colab_badge]: https://colab.research.google.com/assets/colab-badge.svg +# [colab_link]: https://colab.research.google.com/github/Multiomics-Analytics-Group/vuecore/blob/main/docs/api_examples/scatter_plot.ipynb +# [vuecore_logo]: https://raw.githubusercontent.com/Multiomics-Analytics-Group/vuecore/main/docs/images/logo/vuecore_logo.svg +# [Mona]: https://multiomics-analytics-group.github.io/ +# [Biosustain]: https://www.biosustain.dtu.dk/ +# [vuecore_repo]: https://github.com/Multiomics-Analytics-Group/vuecore +# [vuegen_repo]: https://github.com/Multiomics-Analytics-Group/vuegen +# [acore_repo]: https://github.com/Multiomics-Analytics-Group/acore + +# %% [markdown] +# ## 0. Work environment setup + +# %% [markdown] +# ### 0.1. Installing libraries and creating global variables for platform and working directory +# +# To run this notebook locally, you should create a virtual environment with the required libraries. If you are running this notebook on Google Colab, everything should be set. + +# %% tags=["hide-output"] +# VueCore library +# %pip install vuecore + +# %% tags=["hide-cell"] +import os -Project Repository: - https://github.com/Multiomics-Analytics-Group/vuecore +IN_COLAB = "COLAB_GPU" in os.environ -License: - MIT License +# %% tags=["hide-cell"] +# Create a directory for outputs +output_dir = "./outputs" +os.makedirs(output_dir, exist_ok=True) -Created: 2025-06-25 -Last Updated: 2025-06-25 -""" +# %% [markdown] +# ### 0.2. Importing libraries # %% -# 0. Work environment setup -# 0.1. Installing libraries and creating global variables for platform and working directory -# To run this notebook locally, you should create a virtual environment with the required libraries. -# pip install vuecore - -# 0.2. Importing libraries -import os +# Imports import pandas as pd import plotly.io as pio + from vuecore.plots.basic.scatter import create_scatter_plot -# Set the Plotly renderer based on the environment, default to notebook, but you can change it -# to "browser" if you do not want to use jupyter widgets. +# Set the Plotly renderer based on the environment pio.renderers.default = "notebook" -# 0.3. Create a directory for outputs -output_dir = "./outputs" -os.makedirs(output_dir, exist_ok=True) +# %% [markdown] +# ## 1. Basic Scatter Plot # %% -# 1. Basic Scatter Plot # Created sample data sample_df = pd.DataFrame( { @@ -75,6 +108,9 @@ } ) +sample_df + +# %% # Define output path file_path_png = os.path.join(output_dir, "scatter_basic.png") @@ -83,13 +119,16 @@ data=sample_df, x="gene_expression", y="log_p_value", + title="Basic Gene Expression Scatter Plot", file_path=file_path_png, ) fig.show() +# %% [markdown] +# ## 2. Advanced Scatter Plot + # %% -# 2. Advanced Scatter Plot # Define output path file_path_adv_html = os.path.join(output_dir, "scatter_advanced.html") @@ -101,7 +140,7 @@ group="regulation", size="significance_score", text="gene_name", - title="Advanced Gene Expression Plot", + title="Advanced Gene Expression Scatter Plot", x_title="Log2 Fold Change", y_title="-Log10(P-value)", colors={"Up": "#FF5733", "Down": "#3380FF", "None": "#33FF57"}, diff --git a/pyproject.toml b/pyproject.toml index 8d3644e..1d82aa0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,44 +1,46 @@ [project] -authors = [{ name = "Alberto Santos Delgado", email = "albsad@dtu.dk" }, - { name = "Henry Webel", email = "heweb@dtu.dk"}] +authors = [ + { name = "Alberto Santos Delgado", email = "albsad@dtu.dk" }, + { name = "Henry Webel", email = "heweb@dtu.dk" }, +] name = "vuecore" dynamic = ["version"] description = "A Python package for plotting related to multimodal molecular data. Works with acore." license = { text = "GNU General Public License v3" } readme = "README.md" -requires-python = ">=3.9,<3.13" +requires-python = ">=3.9" classifiers = [ - "Development Status :: 2 - Pre-Alpha", - "Intended Audience :: Developers", - "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", - "Natural Language :: English", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", + "Development Status :: 2 - Pre-Alpha", + "Intended Audience :: Developers", + "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", + "Natural Language :: English", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", ] dependencies = [ - "numpy", - "pandas", - # "dsp-pandas", # has only pandas related dependencies - "scipy", - "plotly", - # "biopython", - "beautifulsoup4", - "requests", - "dash", # from dash import html - "networkx", - "matplotlib", - "kaleido", - "pyvis", - "wordcloud", - "cyjupyter", - "nltk", - "webweb", - "acore", - "dash-cytoscape", - "pydantic", - "nbformat>=4.2.0", + "numpy", + "pandas", + # "dsp-pandas", # has only pandas related dependencies + "scipy", + "plotly", + # "biopython", + "beautifulsoup4", + "requests", + "dash", # from dash import html + "networkx", + "matplotlib", + "kaleido", + "pyvis", + "wordcloud", + "cyjupyter", + "nltk", + "webweb", + "acore", + "dash-cytoscape", + "pydantic", + "nbformat>=4.2.0", ] [project.optional-dependencies] diff --git a/src/vuecore/engines/plotly/scatter.py b/src/vuecore/engines/plotly/scatter.py index b02fc9d..e90c36d 100644 --- a/src/vuecore/engines/plotly/scatter.py +++ b/src/vuecore/engines/plotly/scatter.py @@ -1,8 +1,10 @@ import pandas as pd import plotly.express as px import plotly.graph_objects as go -from vuecore.schemas.distribution.scatter import ScatterConfig + +from vuecore.schemas.basic.scatter import ScatterConfig from vuecore.utils.statistics import get_density + from .theming import apply_scatter_theme diff --git a/src/vuecore/engines/plotly/theming.py b/src/vuecore/engines/plotly/theming.py index d94a6ac..86a0f8c 100644 --- a/src/vuecore/engines/plotly/theming.py +++ b/src/vuecore/engines/plotly/theming.py @@ -1,5 +1,6 @@ import plotly.graph_objects as go -from vuecore.schemas.distribution.scatter import ScatterConfig + +from vuecore.schemas.basic.scatter import ScatterConfig def apply_scatter_theme(fig: go.Figure, config: ScatterConfig) -> go.Figure: diff --git a/src/vuecore/plots/basic/__init__.py b/src/vuecore/plots/basic/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/vuecore/plots/basic/scatter.py b/src/vuecore/plots/basic/scatter.py index e8bdb49..0c691f6 100644 --- a/src/vuecore/plots/basic/scatter.py +++ b/src/vuecore/plots/basic/scatter.py @@ -1,10 +1,10 @@ -import pandas as pd from typing import Any -from vuecore.schemas.distribution.scatter import ScatterConfig +import pandas as pd -from vuecore.engines import get_builder, get_saver from vuecore import EngineType +from vuecore.engines import get_builder, get_saver +from vuecore.schemas.basic.scatter import ScatterConfig def create_scatter_plot( diff --git a/src/vuecore/schemas/distribution/__init__.py b/src/vuecore/schemas/distribution/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/vuecore/utils/__init__.py b/src/vuecore/utils/__init__.py new file mode 100644 index 0000000..e69de29