onecodex 0.19.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. docs/.gitignore +1 -0
  2. docs/Makefile +20 -0
  3. docs/_static/one_codex_logo.png +0 -0
  4. docs/conf.py +47 -0
  5. docs/index.rst +90 -0
  6. docs/models.rst +87 -0
  7. docs/notebook_examples/notebooks_demo.ipynb +261 -0
  8. docs/notebooks.rst +10 -0
  9. docs/readme.md +2 -0
  10. docs/requirements.txt +6 -0
  11. docs/sample_collection.rst +73 -0
  12. docs/statistics.rst +39 -0
  13. docs/taxonomy.rst +24 -0
  14. docs/visualization.rst +154 -0
  15. notebook_examples/example.ipynb +299 -0
  16. notebook_examples/notebooks_demo.ipynb +261 -0
  17. onecodex/__init__.py +15 -0
  18. onecodex/analyses.py +650 -0
  19. onecodex/api.py +186 -0
  20. onecodex/assets/fonts/FiraSans-Light.otf +0 -0
  21. onecodex/assets/fonts/FiraSans-Light.woff2 +0 -0
  22. onecodex/assets/fonts/FiraSans-LightItalic.otf +0 -0
  23. onecodex/assets/fonts/FiraSans-LightItalic.woff2 +0 -0
  24. onecodex/assets/fonts/FiraSans-Medium.otf +0 -0
  25. onecodex/assets/fonts/FiraSans-Medium.woff2 +0 -0
  26. onecodex/assets/fonts/FiraSans-MediumItalic.otf +0 -0
  27. onecodex/assets/fonts/FiraSans-MediumItalic.woff2 +0 -0
  28. onecodex/assets/fonts/FiraSans-Regular.otf +0 -0
  29. onecodex/assets/fonts/FiraSans-Regular.woff2 +0 -0
  30. onecodex/assets/fonts/FiraSans-RegularItalic.otf +0 -0
  31. onecodex/assets/fonts/FiraSans-RegularItalic.woff2 +0 -0
  32. onecodex/assets/fonts/FiraSans-SemiBold.otf +0 -0
  33. onecodex/assets/fonts/FiraSans-SemiBold.woff2 +0 -0
  34. onecodex/assets/fonts/FiraSans-SemiBoldItalic.otf +0 -0
  35. onecodex/assets/fonts/FiraSans-SemiBoldItalic.woff2 +0 -0
  36. onecodex/assets/fonts/FiraSansCondensed-Regular.otf +0 -0
  37. onecodex/assets/fonts/FiraSansCondensed-RegularItalic.otf +0 -0
  38. onecodex/assets/fonts/FiraSansCondensed-SemiBold.otf +0 -0
  39. onecodex/assets/fonts/FiraSansCondensed-SemiboldItalic.otf +0 -0
  40. onecodex/assets/notebook_template.css +286 -0
  41. onecodex/assets/notebook_template.scss +344 -0
  42. onecodex/assets/notebook_template.tpl +25 -0
  43. onecodex/assets/one_codex_logo.png +0 -0
  44. onecodex/auth.py +233 -0
  45. onecodex/cli.py +587 -0
  46. onecodex/dataframes.py +273 -0
  47. onecodex/distance.py +225 -0
  48. onecodex/exceptions.py +118 -0
  49. onecodex/input_helpers.py +344 -0
  50. onecodex/lib/__init__.py +0 -0
  51. onecodex/lib/auth.py +94 -0
  52. onecodex/lib/download.py +97 -0
  53. onecodex/lib/enums.py +165 -0
  54. onecodex/lib/files.py +165 -0
  55. onecodex/lib/upload.py +567 -0
  56. onecodex/metadata_upload.py +84 -0
  57. onecodex/models/__init__.py +91 -0
  58. onecodex/models/analysis.py +252 -0
  59. onecodex/models/base.py +430 -0
  60. onecodex/models/collection.py +809 -0
  61. onecodex/models/genome.py +150 -0
  62. onecodex/models/helpers.py +205 -0
  63. onecodex/models/misc.py +122 -0
  64. onecodex/models/sample.py +320 -0
  65. onecodex/models/schemas/__init__.py +52 -0
  66. onecodex/models/schemas/analysis.py +50 -0
  67. onecodex/models/schemas/base.py +10 -0
  68. onecodex/models/schemas/genome.py +45 -0
  69. onecodex/models/schemas/misc.py +93 -0
  70. onecodex/models/schemas/sample.py +126 -0
  71. onecodex/models/schemas/types.py +32 -0
  72. onecodex/notebooks/__init__.py +0 -0
  73. onecodex/notebooks/exporters.py +234 -0
  74. onecodex/notebooks/report.py +479 -0
  75. onecodex/scripts/__init__.py +0 -0
  76. onecodex/scripts/subset_reads.py +407 -0
  77. onecodex/stats.py +564 -0
  78. onecodex/taxonomy.py +110 -0
  79. onecodex/utils.py +507 -0
  80. onecodex/version.py +1 -0
  81. onecodex/viz/__init__.py +202 -0
  82. onecodex/viz/_bargraph.py +323 -0
  83. onecodex/viz/_distance.py +509 -0
  84. onecodex/viz/_functional.py +211 -0
  85. onecodex/viz/_heatmap.py +303 -0
  86. onecodex/viz/_metadata.py +292 -0
  87. onecodex/viz/_pca.py +241 -0
  88. onecodex/viz/_primitives.py +194 -0
  89. onecodex-0.19.0.dist-info/METADATA +336 -0
  90. onecodex-0.19.0.dist-info/RECORD +94 -0
  91. onecodex-0.19.0.dist-info/WHEEL +5 -0
  92. onecodex-0.19.0.dist-info/entry_points.txt +7 -0
  93. onecodex-0.19.0.dist-info/licenses/LICENSE +21 -0
  94. onecodex-0.19.0.dist-info/top_level.txt +3 -0
docs/.gitignore ADDED
@@ -0,0 +1 @@
1
+ _build/
docs/Makefile ADDED
@@ -0,0 +1,20 @@
1
+ # Minimal makefile for Sphinx documentation
2
+ #
3
+
4
+ # You can set these variables from the command line, and also
5
+ # from the environment for the first two.
6
+ SPHINXOPTS ?=
7
+ SPHINXBUILD ?= sphinx-build
8
+ SOURCEDIR = .
9
+ BUILDDIR = _build
10
+
11
+ # Put it first so that "make" without argument is like "make help".
12
+ help:
13
+ @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14
+
15
+ .PHONY: help Makefile
16
+
17
+ # Catch-all target: route all unknown targets to Sphinx using the new
18
+ # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19
+ %: Makefile
20
+ $(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
Binary file
docs/conf.py ADDED
@@ -0,0 +1,47 @@
1
+ import datetime
2
+ import os
3
+ import sys
4
+ from onecodex.version import __version__
5
+
6
+ # Configuration file for the Sphinx documentation builder.
7
+ #
8
+ # For the full list of built-in configuration values, see the documentation:
9
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html
10
+
11
+ # -- Project information -----------------------------------------------------
12
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
13
+
14
+ project = "One Codex"
15
+ copyright = f"{str(datetime.datetime.now().year)}, One Codex"
16
+ author = "One Codex"
17
+
18
+ version = __version__
19
+
20
+ # -- General configuration ---------------------------------------------------
21
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
22
+
23
+ extensions = ["sphinx.ext.autodoc", "nbsphinx", "myst_parser", "sphinxext_altair.altairplot"]
24
+
25
+ nbsphinx_execute = "always"
26
+ nbsphinx_allow_errors = True
27
+
28
+ templates_path = ["_templates"]
29
+ exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", "venv"]
30
+
31
+ html_logo = "_static/one_codex_logo.png"
32
+ html_theme = "sphinx_rtd_theme"
33
+
34
+
35
+ sys.path.insert(0, os.path.abspath("../"))
36
+
37
+ html_theme_options = {"collapse_navigation": True, "navigation_depth": 2}
38
+
39
+ # -- Options for HTML output -------------------------------------------------
40
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
41
+
42
+ html_static_path = ["_static"]
43
+
44
+ # Set default options for autodoc directives
45
+ autodoc_default_options = {
46
+ "inherited-members": True, # Automatically document inherited members
47
+ }
docs/index.rst ADDED
@@ -0,0 +1,90 @@
1
+ *******************************
2
+ One Codex Python Client Library
3
+ *******************************
4
+
5
+ Introduction
6
+ ============
7
+
8
+ This package provides 3 major pieces of functionality: (1) a core Python client
9
+ library; (2) a simple CLI for interacting with the `One Codex platform
10
+ <https://onecodex.com>`_ that uses that core library; and (3) optional
11
+ extensions to the client library, which offers many features aimed at advanced
12
+ users and provides functionality for use in interactive notebook environments
13
+ (e.g., Jupyter notebooks).
14
+
15
+ For installation instructions and instructions on using the command-line
16
+ client, see the :doc:`readme`. You can find the source code on `GitHub
17
+ <https://github.com/onecodex/onecodex>`_.
18
+
19
+ .. toctree::
20
+ :maxdepth: 5
21
+ :caption: Contents
22
+ :hidden:
23
+
24
+ sample_collection
25
+ Visualization <visualization>
26
+ Statistics <statistics>
27
+ Taxonomy <taxonomy>
28
+ Models <models>
29
+ notebooks
30
+
31
+ GitHub <https://github.com/onecodex/onecodex>
32
+
33
+
34
+ Installation
35
+ ============
36
+
37
+ .. code-block:: bash
38
+
39
+ # The CLI (and core Python library)
40
+ pip install onecodex
41
+
42
+ # Optional dependencies (visualization, analysis and reports)
43
+ pip install onecodex[all]
44
+
45
+
46
+ Quickstart
47
+ ==========
48
+
49
+ .. altair-plot::
50
+ :strict:
51
+
52
+ import onecodex
53
+
54
+ # Instantiate the API (run onecodex login first)
55
+ ocx = onecodex.Api()
56
+
57
+ # Fetch some samples
58
+ project = ocx.Projects.get("d53ad03b010542e3")
59
+ samples = ocx.Samples.where(project=project, public=True, limit=10)
60
+
61
+ # Generate a Pandas DataFrame from classification results
62
+ results = samples.to_df()
63
+
64
+ # Plot a bar graph
65
+ # note: return_chart is not needed if using a Jupyter notebook
66
+ samples.plot_bargraph(return_chart=True)
67
+
68
+
69
+ Tutorials
70
+ =========
71
+
72
+ For documentation and examples of common uses of the client library including
73
+ interactive data analysis and plotting within Jupyter notebooks see
74
+ :doc:`notebooks`.
75
+
76
+ CLI
77
+ ===
78
+
79
+ The Python package also comes with a command-line tool which can be used to
80
+ upload samples to One Codex as well as results from the API. See
81
+ :doc:`readme` for more information.
82
+
83
+
84
+ See Also
85
+ ========
86
+
87
+ * `Source on GitHub <https://github.com/onecodex/onecodex>`_
88
+ * `Package on PyPI <https://pypi.org/project/onecodex/>`_
89
+ * `One Codex API Documentation <https://developer.onecodex.com>`_
90
+ * `One Codex <https://onecodex.com>`_
docs/models.rst ADDED
@@ -0,0 +1,87 @@
1
+ ******
2
+ Models
3
+ ******
4
+
5
+ ``Analyses``
6
+ ============
7
+
8
+ .. autoclass:: onecodex.models.analysis.Analyses
9
+ :members:
10
+ :show-inheritance:
11
+
12
+ ``Alignments``
13
+ ==============
14
+
15
+ .. autoclass:: onecodex.models.analysis.Alignments
16
+ :members:
17
+ :show-inheritance:
18
+
19
+ ``Classifications``
20
+ ===================
21
+
22
+ .. autoclass:: onecodex.models.analysis.Classifications
23
+ :members:
24
+ :show-inheritance:
25
+
26
+ ``FunctionalProfiles``
27
+ ======================
28
+
29
+ .. autoclass:: onecodex.models.misc.FunctionalProfiles
30
+ :members:
31
+ :show-inheritance:
32
+
33
+ ``Panels``
34
+ ==========
35
+
36
+ .. autoclass:: onecodex.models.analysis.Panels
37
+ :members:
38
+ :show-inheritance:
39
+
40
+ ``Assets``
41
+ ==========
42
+
43
+ .. autoclass:: onecodex.models.misc.Assets
44
+ :members:
45
+ :show-inheritance:
46
+
47
+ ``Documents``
48
+ =============
49
+
50
+ .. autoclass:: onecodex.models.misc.Documents
51
+ :members:
52
+ :show-inheritance:
53
+
54
+ ``Jobs``
55
+ ========
56
+
57
+ .. autoclass:: onecodex.models.misc.Jobs
58
+ :members:
59
+ :show-inheritance:
60
+
61
+ ``Projects``
62
+ ============
63
+
64
+ .. autoclass:: onecodex.models.misc.Projects
65
+ :members:
66
+ :show-inheritance:
67
+
68
+ ``Samples``
69
+ ===========
70
+
71
+ .. autoclass:: onecodex.models.sample.Samples
72
+ :members:
73
+ :show-inheritance:
74
+
75
+ ``Tags``
76
+ ========
77
+
78
+ .. autoclass:: onecodex.models.misc.Tags
79
+ :members:
80
+ :show-inheritance:
81
+
82
+ ``Users``
83
+ =========
84
+
85
+ .. autoclass:: onecodex.models.misc.Users
86
+ :members:
87
+ :show-inheritance:
@@ -0,0 +1,261 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {},
6
+ "source": [
7
+ "# Introduction\n",
8
+ "\n",
9
+ "This notebook contains all of the code from the corresponding post on the [One Codex Blog](https://www.onecodex.com/blog/2019/05/01/onecodex-library-for-data-viz/). These snippets are exactly what are in the blog post, and let you perfectly reproduce those figures.\n",
10
+ "\n",
11
+ "This is meant to be a starting off point for you to get started analyzing your own samples. You can copy this notebook straight into your account using the button in the header. To \"run\" or execute a cell, just hit `Shift + Enter`. A few other resources you may find useful include: notes on getting started with [our One Codex library](https://github.com/onecodex/onecodex); the [full documentation on our API](https://docs.onecodex.com) (more technical); a cheat sheet on [getting started with Pandas](http://nbviewer.jupyter.org/github/pybokeh/ipython_notebooks/blob/master/pandas/PandasCheatSheet.ipynb), a Python library for data manipulation; and [reading a few of our blog posts](https://www.onecodex.com/blog/) (where we plan to have nice demos with these notebooks). As always, also feel free to send us questions or suggestions by clicking the chat icon in the bottom right!\n",
12
+ "\n",
13
+ "Now we're going to dive right in and start crunching some numbers!"
14
+ ]
15
+ },
16
+ {
17
+ "cell_type": "markdown",
18
+ "metadata": {},
19
+ "source": [
20
+ "## Fetching data\n",
21
+ "\n",
22
+ "To get started, we create an instance of our API, grab the DIABIMMUNE project, and download 500 samples from the cohort."
23
+ ]
24
+ },
25
+ {
26
+ "cell_type": "code",
27
+ "execution_count": null,
28
+ "metadata": {},
29
+ "outputs": [],
30
+ "source": [
31
+ "from onecodex import Api\n",
32
+ "\n",
33
+ "ocx = Api()\n",
34
+ "\n",
35
+ "project = ocx.Projects.get(\"d53ad03b010542e3\") # get DIABIMMUNE project by ID\n",
36
+ "samples = ocx.Samples.where(project=project.id, public=True, limit=50)\n",
37
+ "\n",
38
+ "samples.metadata[[\n",
39
+ " \"gender\",\n",
40
+ " \"host_age\",\n",
41
+ " \"geo_loc_name\",\n",
42
+ " \"totalige\",\n",
43
+ " \"eggs\",\n",
44
+ " \"vegetables\",\n",
45
+ " \"milk\",\n",
46
+ " \"wheat\",\n",
47
+ " \"rice\",\n",
48
+ "]]"
49
+ ]
50
+ },
51
+ {
52
+ "cell_type": "markdown",
53
+ "metadata": {},
54
+ "source": [
55
+ "## Question #1: How does alpha diversity vary by sample group?\n",
56
+ "\n",
57
+ "Here, we display observed taxa, Simpson’s Index, and Shannon diversity side-by-side, grouped by the region of birth. Each group includes samples taken across the entire three-year longitudinal study.\n",
58
+ "\n",
59
+ "**Note:** Shannon diversity is calculated using log base ``e`` (natural log)."
60
+ ]
61
+ },
62
+ {
63
+ "cell_type": "code",
64
+ "execution_count": null,
65
+ "metadata": {},
66
+ "outputs": [],
67
+ "source": [
68
+ "observed_taxa = samples.plot_metadata(vaxis=\"observed_taxa\", haxis=\"geo_loc_name\", return_chart=True)\n",
69
+ "simpson = samples.plot_metadata(vaxis=\"simpson\", haxis=\"geo_loc_name\", return_chart=True)\n",
70
+ "shannon = samples.plot_metadata(vaxis=\"shannon\", haxis=\"geo_loc_name\", return_chart=True)\n",
71
+ "\n",
72
+ "observed_taxa | simpson | shannon"
73
+ ]
74
+ },
75
+ {
76
+ "cell_type": "code",
77
+ "execution_count": null,
78
+ "metadata": {},
79
+ "outputs": [],
80
+ "source": [
81
+ "from onecodex.notebooks.report import *\n",
82
+ "\n",
83
+ "ref_text = 'Roo, et al. \"How to Python.\" Nature, 2019.'\n",
84
+ "legend(f\"Alpha diversity by location of birth{reference(text=ref_text, label='roo1')}\")"
85
+ ]
86
+ },
87
+ {
88
+ "cell_type": "markdown",
89
+ "metadata": {},
90
+ "source": [
91
+ "## Question #2: How does the microbiome change over time?\n",
92
+ "\n",
93
+ "The `plot_metadata` function can\n",
94
+ "search through all taxa in your samples and pull out read counts or relative abundances."
95
+ ]
96
+ },
97
+ {
98
+ "cell_type": "code",
99
+ "execution_count": null,
100
+ "metadata": {},
101
+ "outputs": [],
102
+ "source": [
103
+ "samples.plot_metadata(haxis=\"host_age\", vaxis=\"Bacteroides\", plot_type=\"scatter\")"
104
+ ]
105
+ },
106
+ {
107
+ "cell_type": "markdown",
108
+ "metadata": {},
109
+ "source": [
110
+ "## Question #3: How does an individual subject's gut change over time?\n",
111
+ "\n",
112
+ "Here, we're going to drop into a dataframe, slice it to fetch all the data points from a single subject of the study, and generate a stacked bar plot. It's nice to see the expected high abundance of Bifidobacterium early in life, giving way to Bacteroides near age three!"
113
+ ]
114
+ },
115
+ {
116
+ "cell_type": "code",
117
+ "execution_count": null,
118
+ "metadata": {},
119
+ "outputs": [],
120
+ "source": [
121
+ "# generate a dataframe containing relative abundances\n",
122
+ "df_rel = samples.to_df(rank=\"genus\")\n",
123
+ "\n",
124
+ "# fetch all samples for subject P014839\n",
125
+ "subject_metadata = samples.metadata.loc[samples.metadata[\"host_subject_id\"] == \"P014839\"]\n",
126
+ "subject_df = df_rel.loc[subject_metadata.index]\n",
127
+ "\n",
128
+ "# put them in order of sample date\n",
129
+ "subject_df = subject_df.loc[subject_metadata[\"host_age\"].sort_values().index]\n",
130
+ "\n",
131
+ "# you can access our library using the ocx accessor on pandas dataframes!\n",
132
+ "subject_df.ocx.plot_bargraph(\n",
133
+ " rank=\"genus\",\n",
134
+ " label=lambda metadata: str(metadata[\"host_age\"]),\n",
135
+ " title=\"Subject P014839 Over Time\",\n",
136
+ " xlabel=\"Host Age at Sampling Time (days)\",\n",
137
+ " ylabel=\"Relative Abundance\",\n",
138
+ " legend=\"Genus\",\n",
139
+ ")"
140
+ ]
141
+ },
142
+ {
143
+ "cell_type": "markdown",
144
+ "metadata": {},
145
+ "source": [
146
+ "## Question #4: Heatmaps?!"
147
+ ]
148
+ },
149
+ {
150
+ "cell_type": "code",
151
+ "execution_count": null,
152
+ "metadata": {},
153
+ "outputs": [],
154
+ "source": [
155
+ "df_rel[:30].ocx.plot_heatmap(legend=\"Relative Abundance\", tooltip=\"geo_loc_name\")"
156
+ ]
157
+ },
158
+ {
159
+ "cell_type": "markdown",
160
+ "metadata": {},
161
+ "source": [
162
+ "## Question #5: How do samples cluster?\n",
163
+ "\n",
164
+ "First up, we'll plot a heatmap of weighted UniFrac distance between the first 30 samples in the dataset. This requires unnormalized read counts, so we'll generate a new, unnormalized dataframe."
165
+ ]
166
+ },
167
+ {
168
+ "cell_type": "code",
169
+ "execution_count": null,
170
+ "metadata": {},
171
+ "outputs": [],
172
+ "source": [
173
+ "# generate a dataframe containing read counts\n",
174
+ "df_abs = samples.to_df()\n",
175
+ "\n",
176
+ "df_abs[:30].ocx.plot_distance(metric=\"weighted_unifrac\")"
177
+ ]
178
+ },
179
+ {
180
+ "cell_type": "markdown",
181
+ "metadata": {},
182
+ "source": [
183
+ "## Question #6: Can I do PCA?"
184
+ ]
185
+ },
186
+ {
187
+ "cell_type": "code",
188
+ "execution_count": null,
189
+ "metadata": {},
190
+ "outputs": [],
191
+ "source": [
192
+ "samples.plot_pca(color=\"geo_loc_name\", size=\"Bifidobacterium\", title=\"My PCoA Plot\")"
193
+ ]
194
+ },
195
+ {
196
+ "cell_type": "markdown",
197
+ "metadata": {},
198
+ "source": [
199
+ "## Question #6: Can I do something _better_ than PCA?"
200
+ ]
201
+ },
202
+ {
203
+ "cell_type": "code",
204
+ "execution_count": null,
205
+ "metadata": {},
206
+ "outputs": [],
207
+ "source": [
208
+ "samples.plot_mds(\n",
209
+ " metric=\"weighted_unifrac\", method=\"pcoa\", color=\"geo_loc_name\", title=\"My PCoA Plot\"\n",
210
+ ")"
211
+ ]
212
+ },
213
+ {
214
+ "cell_type": "code",
215
+ "execution_count": null,
216
+ "metadata": {},
217
+ "outputs": [],
218
+ "source": [
219
+ "page_break()"
220
+ ]
221
+ },
222
+ {
223
+ "cell_type": "code",
224
+ "execution_count": null,
225
+ "metadata": {},
226
+ "outputs": [],
227
+ "source": [
228
+ "bibliography()"
229
+ ]
230
+ },
231
+ {
232
+ "cell_type": "code",
233
+ "execution_count": null,
234
+ "metadata": {},
235
+ "outputs": [],
236
+ "source": []
237
+ }
238
+ ],
239
+ "metadata": {
240
+ "kernelspec": {
241
+ "display_name": "Python 3 (ipykernel)",
242
+ "language": "python",
243
+ "name": "python3"
244
+ },
245
+ "language_info": {
246
+ "codemirror_mode": {
247
+ "name": "ipython",
248
+ "version": 3
249
+ },
250
+ "file_extension": ".py",
251
+ "mimetype": "text/x-python",
252
+ "name": "python",
253
+ "nbconvert_exporter": "python",
254
+ "pygments_lexer": "ipython3",
255
+ "version": "3.11.4"
256
+ },
257
+ "onecodex_notebook": true
258
+ },
259
+ "nbformat": 4,
260
+ "nbformat_minor": 1
261
+ }
docs/notebooks.rst ADDED
@@ -0,0 +1,10 @@
1
+ Notebooks
2
+ ---------
3
+
4
+ Examples of interactive data analysis using the One Codex Python library with
5
+ Jupyter Notebook.
6
+
7
+ Example Notebooks
8
+ ^^^^^^^^^^^^^^^^^
9
+
10
+ 1. :doc:`Notebooks Demo <notebook_examples/notebooks_demo>`
docs/readme.md ADDED
@@ -0,0 +1,2 @@
1
+ ```{include} ../README.md
2
+ ```
docs/requirements.txt ADDED
@@ -0,0 +1,6 @@
1
+ sphinx
2
+ nbsphinx
3
+ sphinx-rtd-theme
4
+ myst-parser
5
+ sphinxext-altair
6
+ -e .[all,reports]
@@ -0,0 +1,73 @@
1
+ ****************
2
+ SampleCollection
3
+ ****************
4
+
5
+ Data export, analysis and visualization functions are all contained within the
6
+ ``SampleCollection`` class.
7
+
8
+ A ``SampleCollection`` is returned whenever multiple Samples are returned via
9
+ the One Codex API using a model.
10
+
11
+ Usage
12
+ =====
13
+
14
+ ``SampleCollection`` contains useful tools for data export, analysis,
15
+ visualization and statistics. See the following sections for more information:
16
+
17
+ - :doc:`Visualization <visualization>`
18
+ - :doc:`Statistics <statistics>`
19
+ - :doc:`Taxonomy <taxonomy>`
20
+
21
+ .. code-block:: python
22
+
23
+ import onecodex
24
+
25
+ ocx = onecodex.Api()
26
+
27
+ project = ocx.Project.get("d53ad03b010542e3")
28
+ samples = ocx.Samples.where(project=project)
29
+
30
+ type(samples) # SampleCollection
31
+
32
+
33
+ A ``SampleCollection`` can also be created manually from a list of samples:
34
+
35
+ .. code-block:: python
36
+
37
+ import onecodex.models.collection.SampleCollection
38
+
39
+ sample_list = [
40
+ ocx.Samples.get("cee3b512605a43c6"),
41
+ ocx.Samples.get("01f703ac505e4a30")
42
+ ]
43
+
44
+ samples = SampleCollection(sample_list)
45
+
46
+ # convert classification results to a Pandas DataFrame
47
+ samples.to_df()
48
+
49
+
50
+ ``filter``
51
+ ==========
52
+
53
+ .. automethod:: onecodex.models.collection.SampleCollection.filter
54
+
55
+ ``to_otu``
56
+ ==========
57
+
58
+ .. automethod:: onecodex.models.collection.SampleCollection.to_otu
59
+
60
+ ``to_df``
61
+ =========
62
+
63
+ .. automethod:: onecodex.models.collection.SampleCollection.to_df
64
+
65
+ ``to_classification_df``
66
+ =========================
67
+
68
+ .. automethod:: onecodex.models.collection.SampleCollection.to_classification_df
69
+
70
+ ``to_functional_df``
71
+ =====================
72
+
73
+ .. automethod:: onecodex.models.collection.SampleCollection.to_functional_df
docs/statistics.rst ADDED
@@ -0,0 +1,39 @@
1
+ **********
2
+ Statistics
3
+ **********
4
+
5
+ .. admonition:: See Also
6
+ :class: note
7
+
8
+ Statistics functions are implemented as part of ``SampleCollection``. For
9
+ more information, see :doc:`sample_collection`.
10
+
11
+ ``aitchison_distance``
12
+ ======================
13
+
14
+ .. automethod:: onecodex.models.collection.SampleCollection.aitchison_distance
15
+
16
+ ``alpha_diversity``
17
+ ===================
18
+
19
+ .. automethod:: onecodex.models.collection.SampleCollection.alpha_diversity
20
+
21
+ ``alpha_diversity_stats``
22
+ =========================
23
+
24
+ .. automethod:: onecodex.models.collection.SampleCollection.alpha_diversity_stats
25
+
26
+ ``beta_diversity``
27
+ ==================
28
+
29
+ .. automethod:: onecodex.models.collection.SampleCollection.beta_diversity
30
+
31
+ ``beta_diversity_stats``
32
+ ========================
33
+
34
+ .. automethod:: onecodex.models.collection.SampleCollection.beta_diversity_stats
35
+
36
+ ``unifrac``
37
+ ===========
38
+
39
+ .. automethod:: onecodex.models.collection.SampleCollection.unifrac
docs/taxonomy.rst ADDED
@@ -0,0 +1,24 @@
1
+ ********
2
+ Taxonomy
3
+ ********
4
+
5
+ .. admonition:: See Also
6
+ :class: note
7
+
8
+ Taxonomy functions are implemented as part of ``SampleCollection``. For more
9
+ information, see :doc:`sample_collection`.
10
+
11
+ ``tree_build``
12
+ ==============
13
+
14
+ .. automethod:: onecodex.models.collection.SampleCollection.tree_build
15
+
16
+ ``tree_prune_rank``
17
+ ===================
18
+
19
+ .. automethod:: onecodex.models.collection.SampleCollection.tree_prune_rank
20
+
21
+ ``tree_prune_tax_ids``
22
+ ======================
23
+
24
+ .. automethod:: onecodex.models.collection.SampleCollection.tree_prune_tax_ids