Skip to content
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

Concat tutorial #27

Merged
merged 2 commits into from
Aug 21, 2024
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
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,22 @@ and this project adheres to [Semantic Versioning][].

### Changed

### Fixed

## [0.0.3] - 2024-08-21

### Added

- 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)

### Fixed

- Fixed bug which caused key to be listed twice in `tree_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

Expand Down
3 changes: 3 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
notebooks/getting-started

api.md

notebooks/concatenation

changelog.md
contributing.md
references.md
Expand Down
527 changes: 527 additions & 0 deletions docs/notebooks/concatenation.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ requires = ["hatchling"]

[project]
name = "treedata"
version = "0.0.2"
version = "0.0.3"
description = "anndata with trees"
readme = "README.md"
requires-python = ">=3.10"
Expand Down
12 changes: 11 additions & 1 deletion src/treedata/_core/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from __future__ import annotations

import typing
import warnings
from collections.abc import (
Callable,
Collection,
Expand Down Expand Up @@ -100,7 +101,16 @@ def concat(
fill_value=fill_value,
pairwise=pairwise,
)
tdata = TreeData(adata, allow_overlap=True)

# Create new TreeData object
label = {t.label for t in tdatas if t.label is not None}
if len(label) > 1:
warnings.warn("Multiple label values found. Setting to `tree`.", stacklevel=2)
label = "tree"
else:
label = next(iter(label), None)
allow_overlap = any(t.allow_overlap for t in tdatas)
tdata = TreeData(adata, allow_overlap=allow_overlap, label=label)

# Trees for concatenation axis
concat_trees = [getattr(t, f"{dim}t") for t in tdatas]
Expand Down
Loading