Skip to content
Merged
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
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ repos:
- id: check-yaml
- id: detect-private-key
- repo: https://github.com/tox-dev/pyproject-fmt
rev: "v2.21.0"
rev: "v2.21.1"
hooks:
- id: pyproject-fmt
- repo: https://github.com/codespell-project/codespell
Expand Down Expand Up @@ -50,7 +50,7 @@ repos:
hooks:
- id: actionlint
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.15.8"
rev: "v0.15.10"
hooks:
- id: ruff-format
- id: ruff-check
Expand Down
3 changes: 3 additions & 0 deletions docs/src/examples.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Examples

Featured example:
[OME Arrow and CytoDataFrame](examples/omearrow_and_cytodataframe)

```{toctree}
---
caption: "List of examples"
Expand Down
258 changes: 258 additions & 0 deletions docs/src/examples/omearrow_and_cytodataframe.ipynb

Large diffs are not rendered by default.

58 changes: 58 additions & 0 deletions docs/src/examples/omearrow_and_cytodataframe.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# ---
# jupyter:
# jupytext:
# text_representation:
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.17.3
# kernelspec:
# display_name: cytodataframe-shAZamSV-py3.12
# language: python
# name: python3
# ---

# # OME-Arrow and CytoDataFrame
#
# This notebook demonstrates how [OME-Arrow](https://github.com/WayScience/ome-arrow) works in context with CytoDataFrame.

# + colab={"base_uri": "https://localhost:8080/", "height": 423} id="Y5e85t05nSLt" outputId="a0807c7c-4705-41a2-83b2-9fb7287c40f9"
import pyarrow as pa
import pyarrow.parquet as pq
from ome_arrow import OMEArrow

from cytodataframe import CytoDataFrame

# load a tiff using OME Arrow
oa_img = OMEArrow(
"../../../tests/data/cytotable/JUMP_plate_BR00117006/images/orig/r01c01f01p01-ch2sk1fk1fl1.tiff"
)
oa_img

# + colab={"base_uri": "https://localhost:8080/", "height": 423} id="wkCpuZEBosNV" outputId="4adee883-9707-40a4-92ab-2ee748bbcf76"
# make a "slice" (crop) from the overall image
oa_img_slice = oa_img.slice(x_min=240, x_max=310, y_min=360, y_max=430)
oa_img_slice

# + colab={"base_uri": "https://localhost:8080/"} id="ZZ8LWIuQqQqz" outputId="f82de1df-3240-4dba-d0a0-6a4ce973f299"
# show the OME Arrow struct
oa_img_slice.data

# + colab={"base_uri": "https://localhost:8080/", "height": 1000} id="zcaDHeNorxCt" outputId="e64c061b-c56e-462b-dfe0-c73de76df0d3"
# create a pyarrow table for writing the data
table = pa.table(
{
# two columns, two values each, both int64 type
"metadata_1": pa.array([0, 2], type=pa.int64()),
"feature_1": pa.array([1, 2], type=pa.int64()),
# add an image column with repeated entries based on the image slice
"image": pa.repeat(oa_img_slice.data, 2),
}
)

# write a parquet table
pq.write_table(table, "example.ome.parquet")

# read the parquet table with cytodataframe
# (showing the OME-Arrow image that was written)
CytoDataFrame("example.ome.parquet")
10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,16 @@ lint.select = [
]
# Ignore `E402` and `F401` (unused imports) in all `__init__.py` files
lint.per-file-ignores."__init__.py" = [ "E402", "F401" ]
lint.per-file-ignores."docs/src/examples/cytodataframe_at_a_glance.py" = [ "E402" ]
lint.per-file-ignores."docs/src/examples/*.py" = [ "E402", "E501" ]
lint.per-file-ignores."src/cytodataframe/*.py" = [ "ANN401", "PLC0415" ]
lint.per-file-ignores."src/cytodataframe/image.py" = [ "PLR2004" ]
# ignore typing rules for tests
lint.per-file-ignores."tests/*" = [ "ANN201", "PLR0913", "PLR2004", "SIM105" ]

# specify where version replacement is performed
[tool.bandit]
exclude_dirs = [ "tests" ]

[tool.pytest]
ini_options.addopts = "--cov=src/cytodataframe --cov-report=term-missing:skip-covered --no-cov-on-fail"

Expand All @@ -130,10 +134,6 @@ run.omit = [
[tool.jupytext]
formats = "ipynb,py:light"

# specify where version replacement is performed
[tool.bandit]
exclude_dirs = [ "tests" ]

[tool.poe]
# note: quarto commands below expect quarto installed on the local system.
# see here for more information: https://quarto.org/docs/download/
Expand Down
Loading