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

MOFA on multiple groups with single view #113

Open
martinrohbeck opened this issue Jun 25, 2023 · 1 comment
Open

MOFA on multiple groups with single view #113

martinrohbeck opened this issue Jun 25, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@martinrohbeck
Copy link

Hi there,

I am trying to run MOFA on a MuData object with a single view and multiple groups, i.e. all feature dimensions are shared across the groups. However, muon is throwing some error complaining about dimensions.
ValueError: Value passed for key 'LFs' is of incorrect shape. Values of varm must match dimensions (1,) of parent. Value had shape (2000, 15) while it should have had (1000,).

To reproduce the error, run:

import muon as mu
import numpy as np
from mudata import MuData, AnnData

n1, n2, d = 100, 500, 1000

ad1 = AnnData(np.random.normal(size=(n1, d)))
ad2 = AnnData(np.random.normal(size=(n2, d)))

ad1.obs_names = [f"dat1-cell{i+1}" for i in range(n1)]
ad2.obs_names = [f"dat2-cell{i+1}" for i in range(n2)]
ad1.obs["group_id"] = "group_dat1"
ad2.obs["group_id"] = "group_dat2"

mdata = MuData({"dat1": ad1, "dat2": ad2}, axis=1)

mu.tl.mofa(mdata, groups_label="group_id", use_obs="union", n_factors=15, convergence_mode="fast")

I never used Muon/MuData before, so my mdata object might already be incorrectly constructed. Sorry, if this is the case.
However, assuming the mdata object is as expected, the error might begin here:

M = model.dimensionalities["M"] = len(mdata.mod)

where the value of M is set to 2, although it should likely be 1 - representing a single modality?

If you agree that this is indeed a bug, I'm happy to dig into it and open a PR.

I installed the latest version of muon from master, including
muon 0.1.5
mudata 0.2.3
python 3.11.4

@martinrohbeck martinrohbeck added the bug Something isn't working label Jun 25, 2023
@gtca
Copy link
Collaborator

gtca commented Jun 26, 2023

Hey @martinrohbeck,

The explanation is rather that the axis interface of MuData objects is newer than most muon interfaces, and the latter still need to be upgraded to handle non-standard axes. For multi-group MOFA (this issue) this is going to be rather straightforward but in general custom axes are undefined behaviour for muon so far.

@gtca gtca added enhancement New feature or request and removed bug Something isn't working labels Jun 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants