bioFAM / mofapy2

Multi-omics factor analysis v2
https://biofam.github.io/MOFA2/
GNU Lesser General Public License v3.0
34 stars 28 forks source link

Faulty construction of ThetaZ node #17

Closed cyianor closed 10 months ago

cyianor commented 1 year ago

Hi,

I was running MOFA2 (R package) on some simple test data with three views and two groups and wanted to try out the spike-slab prior on factors. So I set model_opts$spikeslab_factors <- TRUE and built a model as usual. However, I ran into a bizarre error in run_mofa:

Error: numpy.core._exceptions._UFuncNoLoopError: ufunc 'multiply' did not contain a loop with signature matching types (dtype('float64'), dtype('<U6')) -> None

Following the Python stack trace, I pinpointed it to https://github.com/bioFAM/mofapy2/blob/46513cf25198eed32fe81ee4c3260254bbd2cafc/mofapy2/build_model/build_model.py#L151-L156 on the v0.7.0 branch. It still looks the same on master though.

Comparing with the call signature in question https://github.com/bioFAM/mofapy2/blob/09062fb89a01b023df332174af8a15708653063b/mofapy2/build_model/init_model.py#L873 I assume that this is old code that was not updated. To my understanding, self.data_opts["samples_groups"] is a list of strings but is being passed as pa, which is supposed to be a scalar.

cyianor commented 11 months ago

@bv2 @rargelaguet @damienArnol @gtca Is this project still actively maintained? Seems like there were no updates since February.

gtca commented 11 months ago

Hey @cyianor, thanks for tagging!

Is there a quick snippet I could use to reproduce the issue?

cyianor commented 11 months ago

Sure! Calling MOFA from R here.

data("CLL_data", package = "MOFAdata")

MOFAobject <- MOFA2::create_mofa(CLL_data)

model_opts <- MOFA2::get_default_model_options(MOFAobject)
model_opts$spikeslab_factors <- TRUE

MOFAobject <- MOFA2::prepare_mofa(
  object = MOFAobject,
  model_options = model_opts
)

outfile <- file.path(tempdir(), "model.hdf5")
MOFAobject.trained <- MOFA2::run_mofa(
  MOFAobject, outfile, use_basilisk = FALSE
)

As I wrote in the issue initially, the error message is somewhat hard to make sense of, but I traced it to the code in mofapy above.

gtca commented 11 months ago

Thanks, @cyianor!

That should be fixed now, will be in v0.7.1, and at the moment available in the v0.7.1 branch as well as in the master branch.

Please let me know if that fixes the issue for you!

cyianor commented 10 months ago

The snippet I posted above works now on v0.7.1.

Thanks for fixing!