Skip to content

Commit

Permalink
🎨 better plots (and one typo fix)
Browse files Browse the repository at this point in the history
  • Loading branch information
enryH committed Feb 21, 2025
1 parent 7a84d40 commit 66cf4a3
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 17 deletions.
32 changes: 23 additions & 9 deletions docs/api_examples/enrichment_analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@
"id": "4bbf5dc4",
"metadata": {},
"source": [
"# ANCOVA: Compute up and downregulated genes\n",
"# ANOVA: Compute up and downregulated genes\n",
"These will be used to find enrichments in the set of both up and downregulated genes."
]
},
Expand Down Expand Up @@ -280,13 +280,27 @@
},
"outputs": [],
"source": [
"_ = (\n",
" annotations.groupby(\"annotation\")\n",
" .size()\n",
" .value_counts()\n",
" .sort_index()\n",
" .plot(kind=\"bar\")\n",
")"
"s_count_pg_per_annotation = (\n",
" annotations.groupby(\"annotation\").size().value_counts().sort_index()\n",
")\n",
"_ = s_count_pg_per_annotation.plot(\n",
" kind=\"bar\",\n",
" xlabel=\"Number of protein groups associated with annotation\",\n",
" ylabel=\"Number of annotations\",\n",
")\n",
"s_count_pg_per_annotation.to_frame(\"number of annotations\").rename_axis(\n",
" \"N protein groups\"\n",
").T"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e04c98d8",
"metadata": {},
"outputs": [],
"source": [
"annotations.groupby(\"annotation\").size().value_counts(ascending=False)"
]
},
{
Expand Down Expand Up @@ -577,7 +591,7 @@
"import plotly.graph_objects as go\n",
"from vuecore import viz\n",
"\n",
"args = {\"factor\": 1, \"loadings\": 10}\n",
"args = {\"factor\": 2, \"loadings\": 1} # increase number of loadings or scaling factor\n",
"#! pca_results has three items, but docstring requests only two -> double check\n",
"figure = viz.get_pca_plot(data=pca_result, identifier=\"PCA enrichment\", args=args)\n",
"figure = go.Figure(data=figure[\"data\"], layout=figure[\"layout\"])\n",
Expand Down
23 changes: 15 additions & 8 deletions docs/api_examples/enrichment_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@


# %% [markdown]
# # ANCOVA: Compute up and downregulated genes
# # ANOVA: Compute up and downregulated genes
# These will be used to find enrichments in the set of both up and downregulated genes.

# %%
Expand Down Expand Up @@ -137,13 +137,20 @@
# functional annotations are associated only to a single protein group in our dataset.

# %% tags=["hide-input"]
_ = (
annotations.groupby("annotation")
.size()
.value_counts()
.sort_index()
.plot(kind="bar")
s_count_pg_per_annotation = (
annotations.groupby("annotation").size().value_counts().sort_index()
)
_ = s_count_pg_per_annotation.plot(
kind="bar",
xlabel="Number of protein groups associated with annotation",
ylabel="Number of annotations",
)
s_count_pg_per_annotation.to_frame("number of annotations").rename_axis(
"N protein groups"
).T

# %%
annotations.groupby("annotation").size().value_counts(ascending=False)

# %% [markdown]
# # Enrichment analysis
Expand Down Expand Up @@ -289,7 +296,7 @@
import plotly.graph_objects as go
from vuecore import viz

args = {"factor": 1, "loadings": 10}
args = {"factor": 2, "loadings": 1} # increase number of loadings or scaling factor
# #! pca_results has three items, but docstring requests only two -> double check
figure = viz.get_pca_plot(data=pca_result, identifier="PCA enrichment", args=args)
figure = go.Figure(data=figure["data"], layout=figure["layout"])
Expand Down

0 comments on commit 66cf4a3

Please sign in to comment.