Skip to content

Commit

Permalink
Merge pull request #27 from YosefLab/concat-tutorial
Browse files Browse the repository at this point in the history
Concat tutorial
  • Loading branch information
colganwi authored Aug 21, 2024
2 parents 4ac765a + 0c51fd0 commit 8d32bfa
Show file tree
Hide file tree
Showing 5 changed files with 554 additions and 3 deletions.
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

0 comments on commit 8d32bfa

Please sign in to comment.