Bioconductor / LoomExperiment

A package to read, write, and manipulate loom files using LoomExperiments. Uses the loom file format from the Linnarson Lab. https://linnarssonlab.org/loompy/
https://www.bioconductor.org/packages/LoomExperiment
6 stars 5 forks source link

loompy can't read exported SingleCellLoomExperiment #5

Closed lazappi closed 5 years ago

lazappi commented 5 years ago

I'm having trouble reading a SingleCellLoomExperiment saved to a file into Python using loompy. Example using the L1 dataset:

library("LoomExperiment")
l1_file <- system.file("extdata", "L1_DRG_20_example.loom", package = "LoomExperiment")
l1 <- import(l1_file, type="SingleCellLoomExperiment")
export(l1, "l1.loom")

Then in Python:

import loompy
with loompy.connect("l1.loom") as ds:
    ds.shape

I get this error (paths trimmed):

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/python3.6/site-packages/loompy/loompy.py", line 1149, in connect
    return LoomConnection(filename, mode, validate=validate, spec_version=spec_version)
  File "python3.6/site-packages/loompy/loompy.py", line 84, in __init__
    if not lv.validate(filename):
  File "python3.6/site-packages/loompy/loom_validator.py", line 49, in validate
    valid1 = self.validate_spec(f)
  File "python3.6/site-packages/loompy/loom_validator.py", line 232, in validate_spec
    self._check(file["col_attrs"][ca].shape[0] == shape[1], f"Column attribute '{ca}' shape {file['col_attrs'][ca].shape[0]} first dimension does not match column dimension {shape}")
AttributeError: 'Group' object has no attribute 'shape'

If I convert the dataset to a LoomExperiment rather than a SingleCellLoomExperiment before exporting it works fine.

l1_new <- LoomExperiment(assays(l1, "matrix"), rowData = rowData(l1), colData = colData(l1))
export(l1_new, "l1_new.loom")

I guess this suggests the problem is somewhere in the single cell specific stuff? This has worked fine for me before so maybe something changed in the latest release? I'm using LoomExperiment v1.2.0 and loompy v2.0.17.

Thanks

dvantwisk commented 5 years ago

Apologies, for the delay! I am looking into it.

dvantwisk commented 5 years ago

I apologize this took so long. The issue in question involved changing how the reducedDims component of SIngleCellLoomExperiment objects were written to loom files. This change should correct the issue.