cellgeni / sceasy

A package to help convert different single-cell data formats to each other
GNU General Public License v3.0
363 stars 53 forks source link

conversion to loom from sce #29

Closed akhst7 closed 3 years ago

akhst7 commented 3 years ago

Hi ,

I have this sce file;

dat.mod.se
class: SingleCellExperiment 
dim: 36601 10194 
metadata(0):
assays(2): counts logcounts
rownames(36601): BX004987.1 AC145212.1 ... CDY1 TTTY3
rowData names(0):
colnames(10194): AAAGAACAGAGATTCA-1 AAAGAACTCCTCAGGG-1 ... TTTGGTTCAAATCAAG-1 TTTGGAGAGACTTAAG-1
colData names(6): orig.ident nCount_spliced ... nFeature_unspliced ident
reducedDimNames(0):
altExpNames(0):

and converted to loom by a following warmings;

convertFormat(ldat.mod.se, from = "sce", to="loom", outFile = "~/Desktop/ldat.loom")
You created a large dataset with compression and chunking.
The chunk size is equal to the dataset dimensions.
If you want to read subsets of the dataset, you should testsmaller chunk sizes to improve read times.
You created a large dataset with compression and chunking.
The chunk size is equal to the dataset dimensions.
If you want to read subsets of the dataset, you should testsmaller chunk sizes to improve read times.
Error in H5Ldelete(h5loc = loc$H5Identifier, name = name) : 
  Specified link doesn't exist.
In addition: Warning message:
In .regularise_df(SummarizedExperiment::colData(obj), drop_single_values = drop_single_values) :
  Dropping single category variables:orig.ident, ident

Conversion successfully created a loom file however, when I tried to import the file in question to scvelo as follows;

ldata=scv.read_loom("/Volumes/Documents/R/ldat.loom")

-------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-11-c43bed4d070b> in <module>
----> 1 ldata=scv.read_loom("/Volumes/Documents/R/ldat.loom")

/usr/local/Cellar/python@3.9/3.9.2_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/anndata/_io/read.py in read_loom(filename, sparse, cleanup, X_name, obs_names, obsm_names, var_names, varm_names, dtype, **kwargs)
    192     from loompy import connect
    193 
--> 194     with connect(filename, "r", **kwargs) as lc:
    195         if X_name not in lc.layers.keys():
    196             X_name = ""

/usr/local/Cellar/python@3.9/3.9.2_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/loompy/loompy.py in connect(filename, mode, validate, spec_version)
   1387                 Note: if validation is requested, an exception is raised if validation fails.
   1388     """
-> 1389         return LoomConnection(filename, mode, validate=validate)

/usr/local/Cellar/python@3.9/3.9.2_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/loompy/loompy.py in __init__(self, filename, mode, validate)
     79                 if validate:
     80                         lv = loompy.LoomValidator()
---> 81                         if not lv.validate(filename):
     82                                 raise ValueError("\n".join(lv.errors) + f"\n{filename} does not appead to be a valid Loom file according to Loom spec version '{lv.version}'")
     83 

/usr/local/Cellar/python@3.9/3.9.2_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/loompy/loom_validator.py in validate(self, path, strictness)
     49                         if self.version == None:
     50                                 self.version = get_loom_spec_version(f)
---> 51                         valid1 = self.validate_spec(f)
     52                         if not valid1:
     53                                 self.errors.append("For help, see http://linnarssonlab.org/loompy/format/")

/usr/local/Cellar/python@3.9/3.9.2_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/loompy/loom_validator.py in validate_spec(self, file)
    202                 if self.version == "3.0.0":
    203                         self._check("attrs" in file, "Global attributes missing")
--> 204                         for attr in file["attrs"]:
    205                                 if type(attr) is np.ndarray:
    206                                         delay_print(f"{attr: >{width}} {attr.dtype} {attr.shape}")

h5py/_objects.pyx in h5py._objects.with_phil.wrapper()

h5py/_objects.pyx in h5py._objects.with_phil.wrapper()

/usr/local/Cellar/python@3.9/3.9.2_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/h5py/_hl/group.py in __getitem__(self, name)
    286                 raise ValueError("Invalid HDF5 object reference")
    287         else:
--> 288             oid = h5o.open(self.id, self._e(name), lapl=self._lapl)
    289 
    290         otype = h5i.get_type(oid)

h5py/_objects.pyx in h5py._objects.with_phil.wrapper()

h5py/_objects.pyx in h5py._objects.with_phil.wrapper()

h5py/h5o.pyx in h5py.h5o.open()

KeyError: "Unable to open object (object 'attrs' doesn't exist)"

I got a similar error when I tried to import in R

ldat.test<-ReadVelocity("/Volumes/Documents/R/ldat.loom", verbose = T)
reading loom file via hdf5r...
Error in `[[.H5File`(f, "col_attrs/CellID") : 
  An object with name col_attrs/CellID does not exist in this group

I've been absolute getting stuck in the conversion and I'd really appreciate any help.

THanks.

> py_config()
python:         /usr/local/bin/python3
libpython:      /usr/local/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/config-3.9-darwin/libpython3.9.dylib
pythonhome:     /usr/local/Cellar/python@3.9/3.9.2_1/Frameworks/Python.framework/Versions/3.9:/usr/local/Cellar/python@3.9/3.9.2_1/Frameworks/Python.framework/Versions/3.9
version:        3.9.2 (default, Feb 24 2021, 13:30:36)  [Clang 12.0.0 (clang-1200.0.32.29)]
numpy:          /usr/local/lib/python3.9/site-packages/numpy
numpy_version:  1.20.1

python versions found: 
 /usr/local/bin/python3
 /usr/bin/python3
 /usr/bin/python
 /Users/me/my-test-env/bin/python
sw_vers
ProductName:    Mac OS X
ProductVersion: 10.15.7
BuildVersion:   19H512
nh3 commented 3 years ago

Apologies for late reply. Please see #31