diff --git a/docs/examples_single_analysis/diff_regulation_ancova.ipynb b/docs/examples_single_analysis/diff_regulation_ancova.ipynb index 1afdc93..a230e81 100644 --- a/docs/examples_single_analysis/diff_regulation_ancova.ipynb +++ b/docs/examples_single_analysis/diff_regulation_ancova.ipynb @@ -50,6 +50,7 @@ "import pandas as pd\n", "import sklearn.impute\n", "import vuecore.plots.basic.scatter\n", + "from vuecore.interactive import get_differential_regulation_plot\n", "\n", "import acore.differential_regulation as ad\n", "\n", @@ -350,6 +351,26 @@ ")\n", "scatter_plot_adv" ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0fdb7bd6", + "metadata": {}, + "outputs": [], + "source": [ + "get_differential_regulation_plot(\n", + " data=ancova,\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1af558dc", + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { diff --git a/docs/examples_single_analysis/diff_regulation_ancova.py b/docs/examples_single_analysis/diff_regulation_ancova.py index a175b4e..b486498 100644 --- a/docs/examples_single_analysis/diff_regulation_ancova.py +++ b/docs/examples_single_analysis/diff_regulation_ancova.py @@ -34,6 +34,7 @@ import pandas as pd import sklearn.impute import vuecore.plots.basic.scatter +from vuecore.interactive import get_differential_regulation_plot import acore.differential_regulation as ad @@ -193,3 +194,10 @@ height=600, ) scatter_plot_adv + +# %% +get_differential_regulation_plot( + data=ancova, +) + +# %% diff --git a/docs/examples_single_analysis/diff_regulation_anova_ttest_two_groups.ipynb b/docs/examples_single_analysis/diff_regulation_anova_ttest_two_groups.ipynb index 57ac583..a916490 100644 --- a/docs/examples_single_analysis/diff_regulation_anova_ttest_two_groups.ipynb +++ b/docs/examples_single_analysis/diff_regulation_anova_ttest_two_groups.ipynb @@ -44,7 +44,7 @@ "source": [ "import dsp_pandas\n", "import pandas as pd\n", - "import vuecore.plots.basic.scatter\n", + "import vuecore.interactive\n", "\n", "import acore.differential_regulation as ad\n", "\n", @@ -315,7 +315,9 @@ { "cell_type": "markdown", "id": "5fb1bebd", - "metadata": {}, + "metadata": { + "lines_to_next_cell": 2 + }, "source": [ "## View Volcano plot for the ANOVA results\n", "- p-value (unadjusted) using the -log10 transformation on the y-axis, using\n", @@ -332,33 +334,14 @@ "cell_type": "code", "execution_count": null, "id": "37085bf1", - "metadata": {}, + "metadata": { + "lines_to_next_cell": 0 + }, "outputs": [], "source": [ - "scatter_plot_adv = vuecore.plots.basic.scatter.create_scatter_plot(\n", - " data=anova.reset_index(),\n", - " x=\"log2FC\",\n", - " y=\"-log10 pvalue\",\n", - " color=\"rejected\",\n", - " title=\"Simple Volcano Plot\",\n", - " subtitle=\"Visualizing ANOVA results\",\n", - " labels={\n", - " \"log2FC\": \"Log2 Fold Change\",\n", - " \"-log10 pvalue\": \"-log10(p-value)\",\n", - " \"rejected\": \"FDR corrected Significant\",\n", - " \"identifier\": \"Protein Identifier\",\n", - " },\n", - " hover_data=[\"identifier\"],\n", - " # currently does not work:\n", - " # color_discrete_map={False: \"#2166AC\", True: \"#B2182B\"}, # Blue # Red\n", - " color_discrete_sequence=[\"red\", \"blue\"],\n", - " opacity=1,\n", - " marker_line_width=1,\n", - " marker_line_color=\"darkgray\",\n", - " width=800,\n", - " height=600,\n", - ")\n", - "scatter_plot_adv" + "vuecore.interactive.get_differential_regulation_plot(\n", + " data=anova,\n", + ")" ] }, { diff --git a/docs/examples_single_analysis/diff_regulation_anova_ttest_two_groups.py b/docs/examples_single_analysis/diff_regulation_anova_ttest_two_groups.py index ba0b817..5f9057d 100644 --- a/docs/examples_single_analysis/diff_regulation_anova_ttest_two_groups.py +++ b/docs/examples_single_analysis/diff_regulation_anova_ttest_two_groups.py @@ -34,7 +34,7 @@ # %% tags=["hide-input"] import dsp_pandas import pandas as pd -import vuecore.plots.basic.scatter +import vuecore.interactive import acore.differential_regulation as ad @@ -167,31 +167,10 @@ # which is True for significant features and False for non-significant features, and # is calculated based on the `padj` column and a significance threshold (default 0.05) + # %% -scatter_plot_adv = vuecore.plots.basic.scatter.create_scatter_plot( - data=anova.reset_index(), - x="log2FC", - y="-log10 pvalue", - color="rejected", - title="Simple Volcano Plot", - subtitle="Visualizing ANOVA results", - labels={ - "log2FC": "Log2 Fold Change", - "-log10 pvalue": "-log10(p-value)", - "rejected": "FDR corrected Significant", - "identifier": "Protein Identifier", - }, - hover_data=["identifier"], - # currently does not work: - # color_discrete_map={False: "#2166AC", True: "#B2182B"}, # Blue # Red - color_discrete_sequence=["red", "blue"], - opacity=1, - marker_line_width=1, - marker_line_color="darkgray", - width=800, - height=600, +vuecore.interactive.get_differential_regulation_plot( + data=anova, ) -scatter_plot_adv - # %% [markdown] # Done. diff --git a/docs/markdown_ref/acore.md b/docs/markdown_ref/acore.md index 24d33e2..6627268 100644 --- a/docs/markdown_ref/acore.md +++ b/docs/markdown_ref/acore.md @@ -265,13 +265,13 @@ * [`AncovaSchema.posthoc_comparison`](acore.types.md#acore.types.differential_analysis.AncovaSchema.posthoc_comparison) * [`AncovaSchema.t_statistics`](acore.types.md#acore.types.differential_analysis.AncovaSchema.t_statistics) * [`AncovaSchema.posthoc_pvalue`](acore.types.md#acore.types.differential_analysis.AncovaSchema.posthoc_pvalue) + * [`AncovaSchema.f_statistics`](acore.types.md#acore.types.differential_analysis.AncovaSchema.f_statistics) + * [`AncovaSchema.posthoc_padj`](acore.types.md#acore.types.differential_analysis.AncovaSchema.posthoc_padj) * [`AncovaSchema.posthoc_rejected`](acore.types.md#acore.types.differential_analysis.AncovaSchema.posthoc_rejected) * [`AncovaSchema.coef`](acore.types.md#acore.types.differential_analysis.AncovaSchema.coef) * [`AncovaSchema.std_err`](acore.types.md#acore.types.differential_analysis.AncovaSchema.std_err) * [`AncovaSchema.conf_int_low`](acore.types.md#acore.types.differential_analysis.AncovaSchema.conf_int_low) * [`AncovaSchema.conf_int_upp`](acore.types.md#acore.types.differential_analysis.AncovaSchema.conf_int_upp) - * [`AncovaSchema.f_statistics`](acore.types.md#acore.types.differential_analysis.AncovaSchema.f_statistics) - * [`AncovaSchema.posthoc_padj`](acore.types.md#acore.types.differential_analysis.AncovaSchema.posthoc_padj) * [`AncovaSchema.Config`](acore.types.md#acore.types.differential_analysis.AncovaSchema.Config) * [`AncovaSchema.build_schema_()`](acore.types.md#acore.types.differential_analysis.AncovaSchema.build_schema_) * [`AncovaSchema.empty()`](acore.types.md#acore.types.differential_analysis.AncovaSchema.empty) diff --git a/docs/markdown_ref/acore.types.md b/docs/markdown_ref/acore.types.md index ab3af0e..d488d3d 100644 --- a/docs/markdown_ref/acore.types.md +++ b/docs/markdown_ref/acore.types.md @@ -27,7 +27,7 @@ containing NaN values. Bases: [`DataFrameModel`](https://pandera.readthedocs.io/en/stable/reference/generated/pandera.api.pandas.model.DataFrameModel.html#pandera.api.pandas.model.DataFrameModel) -Schema for the enrichment analysis results DataFrame. +Schema for the differential regulation analysis results DataFrame. #### group1 *: [str](https://docs.python.org/3/builtins/stdtypes.html#str)* *= 'group1'* @@ -527,7 +527,7 @@ Validate a DataFrame based on the schema specification. Bases: [`DataFrameModel`](https://pandera.readthedocs.io/en/stable/reference/generated/pandera.api.pandas.model.DataFrameModel.html#pandera.api.pandas.model.DataFrameModel) -Schema for the enrichment analysis results DataFrame. +Schema for the differential regulation analysis results DataFrame. #### posthoc_comparison *: [str](https://docs.python.org/3/builtins/stdtypes.html#str)* *= 'posthoc comparison'* @@ -535,6 +535,10 @@ Schema for the enrichment analysis results DataFrame. #### posthoc_pvalue *: [float](https://docs.python.org/3/builtins/functions.html#float)* *= 'posthoc pvalue'* +#### f_statistics *: [float](https://docs.python.org/3/builtins/functions.html#float)* *= 'F-statistics'* + +#### posthoc_padj *: [float](https://docs.python.org/3/builtins/functions.html#float)* *= 'posthoc pvalue adj'* + #### posthoc_rejected *: [bool](https://docs.python.org/3/builtins/functions.html#bool)* *= 'posthoc rejected'* #### coef *: [float](https://docs.python.org/3/builtins/functions.html#float)* *= 'coef'* @@ -545,10 +549,6 @@ Schema for the enrichment analysis results DataFrame. #### conf_int_upp *: [float](https://docs.python.org/3/builtins/functions.html#float)* *= 'Conf. Int. Upp.'* -#### f_statistics *: [float](https://docs.python.org/3/builtins/functions.html#float)* *= 'F-statistics'* - -#### posthoc_padj *: [float](https://docs.python.org/3/builtins/functions.html#float)* *= 'posthoc pvalue adj'* - #### *class* Config Bases: [`BaseConfig`](https://pandera.readthedocs.io/en/stable/reference/generated/pandera.api.pandas.model_config.BaseConfig.html#pandera.api.pandas.model_config.BaseConfig) diff --git a/pyproject.toml b/pyproject.toml index a50b68d..215e20c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,7 +55,7 @@ docs = [ "sphinx-copybutton", "sphinx-llms-txt", # Multi-Omics-Analysis group package for visualisation of results in the documentation - "vuecore", + "vuecore>=0.3.0", ] dev = [ "black[jupyter]", diff --git a/src/acore/types/differential_analysis.py b/src/acore/types/differential_analysis.py index 0abb115..61edf45 100644 --- a/src/acore/types/differential_analysis.py +++ b/src/acore/types/differential_analysis.py @@ -3,7 +3,7 @@ class AnovaSchema(DataFrameModel): """ - Schema for the enrichment analysis results DataFrame. + Schema for the differential regulation analysis results DataFrame. """ group1: str = Field(nullable=False) @@ -57,16 +57,18 @@ class AnovaSchemaMultiGroup(AnovaSchema): class AncovaSchema(DataFrameModel): """ - Schema for the enrichment analysis results DataFrame. + Schema for the differential regulation analysis results DataFrame. """ + # same as in AnovaSchemaMultiGroup posthoc_comparison: str = Field(alias="posthoc comparison", nullable=False) t_statistics: float = Field(alias="posthoc T-Statistics") posthoc_pvalue: float = Field(alias="posthoc pvalue") + f_statistics: float = Field(alias="F-statistics") + posthoc_padj: float = Field(alias="posthoc pvalue adj", ge=0, le=1) posthoc_rejected: bool = Field(alias="posthoc rejected", nullable=False) + coef: float = Field() std_err: float = Field(alias="std err") conf_int_low: float = Field(alias="Conf. Int. Low") conf_int_upp: float = Field(alias="Conf. Int. Upp.") - f_statistics: float = Field(alias="F-statistics") - posthoc_padj: float = Field(alias="posthoc pvalue adj", ge=0, le=1)