theislab / moscot

Multi-omic single-cell optimal transport tools
https://moscot-tools.org
BSD 3-Clause "New" or "Revised" License
101 stars 9 forks source link

`TranslationProblem.prepare` method can't set `joint_attr={"attr":"X"}` #687

Closed selmanozleyen closed 2 weeks ago

selmanozleyen commented 2 months ago

When I try to run this

tp = tp.prepare(batch_key="batch", src_attr=src_attr, tgt_attr=tgt_attr, joint_attr={"attr": "X"})

TemporalProblem will give an error because of this line https://github.com/theislab/moscot/blob/3151da7b324672fab6757b8a84bcd1d0bcb9f027/src/moscot/problems/cross_modality/_translation.py#L167 with the message KeyError: 'x_key'

MUCDK commented 2 months ago

Thanks @selmanozleyen , good catch. It happens because of this: https://github.com/theislab/moscot/blob/3151da7b324672fab6757b8a84bcd1d0bcb9f027/src/moscot/problems/_utils.py#L26

Now I am wondering whether this scenario is realistic, as the joint attribute in the case you describe would be the full gene space (no dim. reduction).

Still I think it's fair to implement it. The easiest way would be to do an if-else statement to get the shapes (i.e. where it fails atm). wdyt?

selmanozleyen commented 2 months ago

Now I am wondering whether this scenario is realistic, as the joint attribute in the case you describe would be the full gene space (no dim. reduction).

@MUCDK yeah I can do it, just wanted to check with the use case, if I should implement it or throw an error etc.