Add dataflow/move_anndata_slots component#1163
Open
jakubmajercik wants to merge 6 commits into
Open
Conversation
dorien-er
requested changes
Apr 15, 2026
5 tasks
DriesSchaumont
requested changes
Apr 29, 2026
| @@ -0,0 +1,141 @@ | |||
| name: move_anndata_slots | |||
| namespace: "dataflow" | |||
Member
There was a problem hiding this comment.
Let's use metadata as the namespace.
| Move slots (.obs, .var, .obsm, .varm, .obsp, .varp, .uns) from a modality | ||
| in a source MuData file into a modality in a target MuData file. | ||
| The specified slots are copied from the source modality into the target | ||
| modality, overwriting any existing data at those slots. |
Member
There was a problem hiding this comment.
What happens if the dimensions not match? (Please add it in the description if they need to match)
| needs_var = any(par[s] for s in ("var", "varm", "varp")) | ||
|
|
||
| mismatches = [] | ||
| if needs_obs and set(source_mod.obs_names) != set(target_mod.obs_names): |
Member
There was a problem hiding this comment.
I think its best to use https://pandas.pydata.org/docs/reference/api/pandas.Index.get_indexer.html#pandas.Index.get_indexer here. It will return -1 if no match is found.
This will use the same method as reindexing (which is used later in this script). I will take into account dtypes etc..
Comment on lines
+69
to
+72
| "Index mismatch between source and target modalities: " | ||
| + " and ".join(mismatches) | ||
| + " indices do not match." | ||
| ) |
Member
There was a problem hiding this comment.
Use string formatting here.
| ) | ||
|
|
||
| # Reindex source to match target order if needed. | ||
| if needs_obs and not (source_mod.obs_names == target_mod.obs_names).all(): |
| run_component( | ||
| [ | ||
| "--input_source", | ||
| str(source_h5mu_path), |
Member
There was a problem hiding this comment.
I dont think str is a requirement here anymore. Check other places as well.
10 tasks
Collaborator
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changelog
Add a new
dataflow/move_anndata_slotscomponent that selectively moves AnnData slots (.obs,.var,.obsm,.varm,.obsp,.varp,.uns) from a modality in a source MuData file into a modality in a target MuData file, without performing a full merge. Supports cross-modality transfers via--target_modality.Issue ticket number and link
N/A
Checklist before requesting a review
I have performed a self-review of my code
Conforms to the Contributor's guide
Check the correct box. Does this PR contain:
Proposed changes are described in the CHANGELOG.md
CI tests succeed!