Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: YosefLab/treedata
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0.0.4
Choose a base ref
...
head repository: YosefLab/treedata
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
Loading
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -30,3 +30,6 @@ __pycache__/

# Prettier
/node_modules/

# Environment
environment.yml
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -2,24 +2,24 @@ fail_fast: false
default_language_version:
python: python3
default_stages:
- commit
- push
- pre-commit
- pre-push
minimum_pre_commit_version: 2.16.0
repos:
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
hooks:
- id: prettier
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.2
rev: v0.9.4
hooks:
- id: ruff
types_or: [python, pyi, jupyter]
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format
types_or: [python, pyi, jupyter]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: detect-private-key
- id: check-ast
76 changes: 64 additions & 12 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -8,6 +8,58 @@ and this project adheres to [Semantic Versioning][].
[keep a changelog]: https://keepachangelog.com/en/1.0.0/
[semantic versioning]: https://semver.org/spec/v2.0.0.html

## [Unrealeased]

### Added

### Changed

### Fixed

## [0.1.3] - 2025-01-20

### Added

### Changed

### Fixed

- Fixed `ImportError: zarr-python major version > 2 is not supported'` error with Python 12 (#46)

## [0.1.2] - 2024-12-02

### Added

### Changed

### Fixed

- Fixed `KeyError: "Unable to synchronously open object (object 'X' doesn't exist)"'` when reading h5ad without X field (#40)

## [0.1.1] - 2024-11-25

### Added

- Axis in `td.concat` can now be specified with `obs` and `var` (#40)

### Changed

### Fixed

- Fixed `ImportError: cannot import name '_resolve_dim' from 'anndata._core.merge'` caused by anndata update (#40)

## [0.1.0] - 2024-09-27

### Added

### Changed

- Encoding of `treedata` attributes in h5ad and zarr files. `label`, `allow_overlap`, `obst`, and `vart` are now separate fields in the file. (#31)

### Fixed

- `TreeData` objects with `.raw` specified can now be read (#31)

## [0.0.4] - 2024-09-02

### Added
@@ -16,39 +68,39 @@ and this project adheres to [Semantic Versioning][].

### Fixed

- Fixed typing bug introduced by anndata update (#29)
- Fixed typing bug introduced by anndata update (#29)

## [0.0.3] - 2024-08-21

### Added

- Add concatenation tutorial to documentation (#27)
- Add concatenation tutorial to documentation (#27)

### Changed

- `obst` and `vart` create local copy of `nx.DiGraphs` that are added (#26)
- `TreeData.label` value remains the same after `td.concat` as long as all `label` values are the same for all objects (#27)
- `obst` and `vart` create local copy of `nx.DiGraphs` that are added (#26)
- `TreeData.label` value remains the same after `td.concat` as long as all `label` values are the same for all objects (#27)

### Fixed

- Fixed bug which caused key to be listed twice in `label` column after value update in `obst` or `vart` (#26)
- Fixed bug which caused key to be listed twice in `label` column after value update in `obst` or `vart` (#26)

## [0.0.2] - 2024-06-18

### Changed

- Empty trees are now allowed to avoid error on subsetting (#13)
- How trees are stored in h5ad and zarr files (#16)
- Format of label column with multiple trees ([1,2] -> 1,2) (#16)
- Empty trees are now allowed to avoid error on subsetting (#13)
- How trees are stored in h5ad and zarr files (#16)
- Format of label column with multiple trees ([1,2] -> 1,2) (#16)

### Fixed

- Fixed issue with slow read/write of large trees
- Fixed issue with slow read/write of large trees

## [0.0.1] - 2024-05-13

### Added

- TreeData class for storing and manipulating trees
- Read/write trees to h5ad and zarr files
- Concatenate trees with similar API to AnnData
- TreeData class for storing and manipulating trees
- Read/write trees to h5ad and zarr files
- Concatenate trees with similar API to AnnData
18 changes: 9 additions & 9 deletions docs/contributing.md
Original file line number Diff line number Diff line change
@@ -99,11 +99,11 @@ Specify `vX.X.X` as a tag name and create a release. For more information, see [

Please write documentation for new or changed features and use-cases. This project uses [sphinx][] with the following features:

- the [myst][] extension allows to write documentation in markdown/Markedly Structured Text
- [Numpy-style docstrings][numpydoc] (through the [napoloen][numpydoc-napoleon] extension).
- Jupyter notebooks as tutorials through [myst-nb][] (See [Tutorials with myst-nb](#tutorials-with-myst-nb-and-jupyter-notebooks))
- [Sphinx autodoc typehints][], to automatically reference annotated input and output types
- Citations (like {cite:p}`Virshup_2023`) can be included with [sphinxcontrib-bibtex](https://sphinxcontrib-bibtex.readthedocs.io/)
- the [myst][] extension allows to write documentation in markdown/Markedly Structured Text
- [Numpy-style docstrings][numpydoc] (through the [napoloen][numpydoc-napoleon] extension).
- Jupyter notebooks as tutorials through [myst-nb][] (See [Tutorials with myst-nb](#tutorials-with-myst-nb-and-jupyter-notebooks))
- [Sphinx autodoc typehints][], to automatically reference annotated input and output types
- Citations (like {cite:p}`Virshup_2023`) can be included with [sphinxcontrib-bibtex](https://sphinxcontrib-bibtex.readthedocs.io/)

See the [scanpy developer docs](https://scanpy.readthedocs.io/en/latest/dev/documentation.html) for more information
on how to write documentation.
@@ -120,10 +120,10 @@ repository.

#### Hints

- If you refer to objects from other packages, please add an entry to `intersphinx_mapping` in `docs/conf.py`. Only
if you do so can sphinx automatically create a link to the external documentation.
- If building the documentation fails because of a missing link that is outside your control, you can add an entry to
the `nitpick_ignore` list in `docs/conf.py`
- If you refer to objects from other packages, please add an entry to `intersphinx_mapping` in `docs/conf.py`. Only
if you do so can sphinx automatically create a link to the external documentation.
- If building the documentation fails because of a missing link that is outside your control, you can add an entry to
the `nitpick_ignore` list in `docs/conf.py`

#### Building the docs locally

2 changes: 1 addition & 1 deletion docs/extensions/typed_returns.py
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@
def _process_return(lines: Iterable[str]) -> Generator[str, None, None]:
for line in lines:
if m := re.fullmatch(r"(?P<param>\w+)\s+:\s+(?P<type>[\w.]+)", line):
yield f'-{m["param"]} (:class:`~{m["type"]}`)'
yield f"-{m['param']} (:class:`~{m['type']}`)"
else:
yield line

5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ requires = ["hatchling"]

[project]
name = "treedata"
version = "0.0.4"
version = "0.1.3"
description = "anndata with trees"
readme = "README.md"
requires-python = ">=3.10"
@@ -22,12 +22,13 @@ dependencies = [
"anndata",
"h5py",
"numpy",
"packaging",
"pandas",
"pathlib",
"pyarrow",
"networkx",
"session-info",
"zarr",
"zarr>=2,<3",
]

[project.optional-dependencies]
10 changes: 5 additions & 5 deletions src/treedata/_core/merge.py
Original file line number Diff line number Diff line change
@@ -13,9 +13,9 @@

import anndata as ad
import pandas as pd
from anndata._core.merge import _resolve_dim, resolve_merge_strategy
from anndata._core.merge import resolve_merge_strategy

from treedata._utils import combine_trees
from treedata._utils import _resolve_axis, combine_trees

from .treedata import TreeData

@@ -25,7 +25,7 @@
def concat(
tdatas: Collection[TreeData] | typing.Mapping[str, TreeData],
*,
axis: Literal[0, 1] = 0,
axis: Literal["obs", 0, "var", 1] = "obs",
join: Literal["inner", "outer"] = "inner",
merge: StrategiesLiteral | Callable | None = None,
uns_merge: StrategiesLiteral | Callable | None = None,
@@ -74,8 +74,8 @@ def concat(
Whether pairwise elements along the concatenated dimension should be included.
This is False by default, since the resulting arrays are often not meaningful.
"""
axis, dim = _resolve_dim(axis=axis)
alt_axis, alt_dim = _resolve_dim(axis=1 - axis)
axis, dim = _resolve_axis(axis)
alt_axis, alt_dim = _resolve_axis(axis=1 - axis)
merge = resolve_merge_strategy(merge)

# Check indices
Loading