Skip to content

Added 4 Sphinx gallery python tutorials #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,11 @@ dmypy.json
# Files generated during package build and CMD check, unnecessary for the package
atlasapprox.Rcheck/
.Rhistory
.RData
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's going on here?

.RData

# sphinx gallery src
docs/source/_build
docs/source/python/gallery

# OS system file
**/.DS_Store
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
Quickstart
==========

This example shows a quick and easy example of how to use atlasapprox to get and plot the expression of some gees in a specific organ of a specific organism.
This example shows a quick and easy example of how to use atlasapprox to get and plot the expression of some gees in a
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo gees

specific organ of a specific organism.
"""

import matplotlib.pyplot as plt
Expand All @@ -19,3 +20,5 @@
fig, ax = plt.subplots(figsize=(7, 4))
sns.heatmap(expression, ax=ax)
fig.tight_layout()

# sphinx_gallery_thumbnail_path = '_static/quickstart.png'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need this?

100 changes: 100 additions & 0 deletions docs/gallery/python/1_beginner_guide.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
"""
.. _beginner-guide:

Beginner guide
==============

The `atlasapprox <https://atlasapprox.readthedocs.io/en/latest/index.html>`_ API provides access to approximated
cell atlas data from 30 species, including both animals and plants. You can explore data from species such as *Homo sapiens* (humans), *Mus musculus* (mice), *Arabidopsis thaliana* (thale cress), and *Zea mays* (corn).
This guide walks you through installing the package, setting up the API, and running basic queries with simple examples.
"""

# %%
# Setting up a virtual environment (optional)
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# It's recommended to use a virtual environment to manage dependencies. Run the following command:
#
# ``python -m venv venv``
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually people typically put it into .venv - with a dot

#
# Activate the environment using the appropriate command for your operating system:
#
# For macOS/Linux:
# ``source venv/bin/activate``
#
# For Windows:
# ``venv\Scripts\activate``

# %%
# Installing required packages
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# Install the ``atlasapprox`` package along with libraries needed for data visualization using *pip*:
#
# ``pip install atlasapprox matplotlib seaborn numpy pandas``
#
# These packages will be used throughout the tutorials.

# %%
# Then, import required libraries and instantiate the ``API`` object:

import atlasapprox

api = atlasapprox.API()

# %%
# Querying available data
# ^^^^^^^^^^^^^^^^^^^^^^^
# Explore available organisms, organs, and cell types using the following methods:

# %%

# List available organisms
available_organisms = api.organisms()
print(available_organisms)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just printing the API call directly?


# %%

# List available organs for humans
available_organs = api.organs(organism="h_sapiens")
print(available_organs)

# %%

# List available cell types in the human lung
available_celltypes = api.celltypes(organism="h_sapiens", organ="lung")
print(available_celltypes)


# %%
# Exploring average gene expression
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# The ``average`` method retrieves gene expression levels for selected genes in a specific organ of an organism.
#
# The following example shows how to examine the average expression of five genes
# (*COL13A1*, *COL14A1*, *TGFBI*, *PDGFRA*, *GZMA*) in the human lung:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why these genes?


avg_gene_expr_lung = api.average(
organism = "h_sapiens",
organ = "lung",
features = ["COL13A1", "COL14A1", "TGFBI", "PDGFRA", "GZMA"],
measurement_type = "gene_expression"
)

# Display the result
avg_gene_expr_lung
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not obvious to many people that putting a variable out there visualises it


# %%
# Understanding the output
# ------------------------
# The ``average`` method returns a **pandas.DataFrame** where:
#
# - Rows represent genes.
# - Columns represent cell types.
# - Values show average gene expression in counts per ten thousand (cptt).

# %%
# Conclusion
# ^^^^^^^^^^
# This guide covers setup and basic data querying. For more detailed
# information, refer to the official `documentation <https://atlasapprox.readthedocs.io/en/latest/python/index.html>`_.

# sphinx_gallery_thumbnail_path = '_static/beginner_guide.png'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't you just tell it the number of the figure instead? Having static files makes it difficult to maintain

Loading