camlab-bioml/starling

Not using cell size throws error

kieranrcampbell opened this issue · 2 comments

In the main constructor, if the argument model_cell_size is set to False then all cell size modelling should subsequently be ignored. However, running that results in the following error that is not present if model_cell_size is set to True:

File [/usr/local/lib/python3.9/site-packages/pytorch_lightning/trainer/call.py:44](https://file+.vscode-resource.vscode-cdn.net/usr/local/lib/python3.9/site-packages/pytorch_lightning/trainer/call.py:44), in _call_and_handle_interrupt(trainer, trainer_fn, *args, **kwargs)
     [42](https://file+.vscode-resource.vscode-cdn.net/usr/local/lib/python3.9/site-packages/pytorch_lightning/trainer/call.py:42)     if trainer.strategy.launcher is not None:
     [43](https://file+.vscode-resource.vscode-cdn.net/usr/local/lib/python3.9/site-packages/pytorch_lightning/trainer/call.py:43)         return trainer.strategy.launcher.launch(trainer_fn, *args, trainer=trainer, **kwargs)
...
    [107](https://file+.vscode-resource.vscode-cdn.net/usr/local/lib/python3.9/site-packages/anndata/utils.py:107)     Returns None if `x` is an awkward array with variable length in the requested dimension.
    [108](https://file+.vscode-resource.vscode-cdn.net/usr/local/lib/python3.9/site-packages/anndata/utils.py:108)     """
--> [109](https://file+.vscode-resource.vscode-cdn.net/usr/local/lib/python3.9/site-packages/anndata/utils.py:109)     return x.shape[axis]

AttributeError: 'NoneType' object has no attribute 'shape'

I'm actually unsure where this comes from from looking at the code.

Can we implement a unit test that makes sure we can fit when not modelling cell size? Then take it from there.

The issue seems to stem from these lines: https://github.com/camlab-bioml/starling/blob/main/starling/starling.py#L163-L164, where None is assigned to varm, while anndata expects an array of the appropriate dimensions. It seems we'd need to pass in that array or, possibly, correct varm to uns to match the lines in the previous conditional block. This last solution made the tests pass for me.

closed with #45