Skip to content
Open
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
6 changes: 4 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# jupyter_contrib_nbextensions imports pkg_resources, which setuptools removed
# in v81; the python:3.13-slim base image no longer ships setuptools at all.
setuptools<81
awscli
biopython
ipywidgets
jupyter_contrib_nbextensions
nbconvert==6.5.0
openpyxl
xlrd
statsmodels
onecodex[all,reports]==0.19.3
onecodex[all,reports]==1.1.0
taxonomy
widgetsnbextension
42 changes: 18 additions & 24 deletions test/notebooks/example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
"\n",
"import warnings\n",
"\n",
"# filter warnings because the timestamp shows up in diff-pdf\n",
"warnings.filterwarnings(\"ignore\", message=\".*SampleCollection contains multiple.*\")\n",
"warnings.filterwarnings(\"ignore\", message=\".*is deprecated.*\")\n",
"\n",
"from IPython.display import display\n",
"\n",
"project = ocx.Projects.get(\"d53ad03b010542e3\") # get DIABIMMUNE project by ID\n",
Expand All @@ -50,7 +54,7 @@
" \"wheat\",\n",
" \"rice\",\n",
"]]\n",
" \n",
"\n",
"display(md_table)"
]
},
Expand All @@ -69,14 +73,9 @@
"metadata": {},
"outputs": [],
"source": [
"# filter warning because timestamp shows up in diff-pdf\n",
"with warnings.catch_warnings():\n",
" warnings.filterwarnings(\"ignore\", message=\".*SampleCollection contains multiple.*\")\n",
" warnings.filterwarnings(\"ignore\", message=\".*is deprecated.*\")\n",
" \n",
" observed_taxa = samples.plot_metadata(vaxis=\"observed_taxa\", haxis=\"geo_loc_name\", return_chart=True)\n",
" simpson = samples.plot_metadata(vaxis=\"simpson\", haxis=\"geo_loc_name\", return_chart=True)\n",
" shannon = samples.plot_metadata(vaxis=\"shannon\", haxis=\"geo_loc_name\", return_chart=True)\n",
"observed_taxa = samples.plot_metadata(vaxis=\"observed_taxa\", haxis=\"geo_loc_name\", return_chart=True)\n",
"simpson = samples.plot_metadata(vaxis=\"simpson\", haxis=\"geo_loc_name\", return_chart=True)\n",
"shannon = samples.plot_metadata(vaxis=\"shannon\", haxis=\"geo_loc_name\", return_chart=True)\n",
"\n",
"observed_taxa | simpson | shannon"
]
Expand Down Expand Up @@ -128,18 +127,12 @@
"outputs": [],
"source": [
"# generate a dataframe containing relative abundances\n",
"df_rel = samples.to_df(rank=\"genus\")\n",
"\n",
"# fetch all samples for subject P014839\n",
"subject_metadata = samples.metadata.loc[samples.metadata[\"host_subject_id\"] == \"P014839\"]\n",
"subject_df = df_rel.loc[subject_metadata.index]\n",
"subject_df = samples.filter(lambda s: s.metadata.custom[\"host_subject_id\"] == \"P014839\")\n",
"\n",
"# put them in order of sample date\n",
"subject_df = subject_df.loc[subject_metadata[\"host_age\"].sort_values().index]\n",
"\n",
"# you can access our library using the ocx accessor on pandas dataframes!\n",
"subject_df.ocx.plot_bargraph(\n",
"subject_df.plot_bargraph(\n",
" rank=\"genus\",\n",
" metric=\"normalized_readcount_w_children\",\n",
" label=lambda metadata: str(metadata[\"host_age\"]),\n",
" title=\"Subject P014839 Over Time\",\n",
" xlabel=\"Host Age at Sampling Time (days)\",\n",
Expand All @@ -161,7 +154,7 @@
"metadata": {},
"outputs": [],
"source": [
"df_rel[:30].ocx.plot_heatmap(legend=\"Relative Abundance\", tooltip=\"geo_loc_name\")"
"samples[:30].plot_heatmap(legend=\"Relative Abundance\", tooltip=\"geo_loc_name\", rank='genus', metric='normalized_readcount_w_children')"
]
},
{
Expand All @@ -179,10 +172,7 @@
"metadata": {},
"outputs": [],
"source": [
"# generate a dataframe containing read counts\n",
"df_abs = samples.to_df()\n",
"\n",
"df_abs[:30].ocx.plot_distance(metric=\"weighted_unifrac\")"
"samples[:30].plot_distance(diversity_metric=\"weighted_unifrac\", metric='normalized_readcount_w_children')"
]
},
{
Expand Down Expand Up @@ -215,7 +205,11 @@
"outputs": [],
"source": [
"samples.plot_mds(\n",
" metric=\"weighted_unifrac\", method=\"pcoa\", color=\"geo_loc_name\", title=\"My PCoA Plot\"\n",
" metric='abundance_w_children',\n",
" diversity_metric=\"weighted_unifrac\",\n",
" method=\"pcoa\",\n",
" color=\"geo_loc_name\",\n",
" title=\"My PCoA Plot\"\n",
")"
]
},
Expand Down
Binary file modified test/notebooks/example_expected.pdf
Binary file not shown.
Loading