We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Following is an error I get when I read an anndata file which I unfortunately cannot share but I thought it might be helpful nevertheless:
--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-19-5c8f9dcd2470> in <module> ----> 1 hair_ad = sc.read('hair_follicle_and_glands.h5ad') ~/.miniconda/lib/python3.8/site-packages/scanpy/readwrite.py in read(filename, backed, sheet, ext, delimiter, first_column_names, backup_url, cache, cache_compression, **kwargs) 110 filename = Path(filename) # allow passing strings 111 if is_valid_filename(filename): --> 112 return _read( 113 filename, 114 backed=backed, ~/.miniconda/lib/python3.8/site-packages/scanpy/readwrite.py in _read(filename, backed, sheet, ext, delimiter, first_column_names, backup_url, cache, cache_compression, suppress_cache_warning, **kwargs) 711 if ext in {'h5', 'h5ad'}: 712 if sheet is None: --> 713 return read_h5ad(filename, backed=backed) 714 else: 715 logg.debug(f'reading sheet {sheet} from file {filename}') ~/.miniconda/lib/python3.8/site-packages/anndata/_io/h5ad.py in read_h5ad(filename, backed, as_sparse, as_sparse_fmt, chunk_size) 435 _clean_uns(d) # backwards compat 436 --> 437 return AnnData(**d) 438 439 ~/.miniconda/lib/python3.8/site-packages/anndata/_core/anndata.py in __init__(self, X, obs, var, uns, obsm, varm, layers, raw, dtype, shape, filename, filemode, asview, obsp, varp, oidx, vidx) 306 self._init_as_view(X, oidx, vidx) 307 else: --> 308 self._init_as_actual( 309 X=X, 310 obs=obs, ~/.miniconda/lib/python3.8/site-packages/anndata/_core/anndata.py in _init_as_actual(self, X, obs, var, uns, obsm, varm, varp, obsp, raw, layers, dtype, shape, filename, filemode) 509 # TODO: Think about consequences of making obsm a group in hdf 510 self._obsm = AxisArrays(self, 0, vals=convert_to_dict(obsm)) --> 511 self._varm = AxisArrays(self, 1, vals=convert_to_dict(varm)) 512 513 self._obsp = PairwiseArrays(self, 0, vals=convert_to_dict(obsp)) ~/.miniconda/lib/python3.8/site-packages/anndata/_core/aligned_mapping.py in __init__(self, parent, axis, vals) 233 self._data = dict() 234 if vals is not None: --> 235 self.update(vals) 236 237 ~/.miniconda/lib/python3.8/_collections_abc.py in update(self, other, **kwds) 830 if isinstance(other, Mapping): 831 for key in other: --> 832 self[key] = other[key] 833 elif hasattr(other, "keys"): 834 for key in other.keys(): ~/.miniconda/lib/python3.8/site-packages/anndata/_core/aligned_mapping.py in __setitem__(self, key, value) 149 150 def __setitem__(self, key: str, value: V): --> 151 value = self._validate_value(value, key) 152 self._data[key] = value 153 ~/.miniconda/lib/python3.8/site-packages/anndata/_core/aligned_mapping.py in _validate_value(self, val, key) 213 f"value.index does not match parent’s axis {self.axes[0]} names" 214 ) --> 215 return super()._validate_value(val, key) 216 217 @property ~/.miniconda/lib/python3.8/site-packages/anndata/_core/aligned_mapping.py in _validate_value(self, val, key) 48 """Raises an error if value is invalid""" 49 for i, axis in enumerate(self.axes): ---> 50 if self.parent.shape[axis] != val.shape[i]: 51 right_shape = tuple(self.parent.shape[a] for a in self.axes) 52 raise ValueError( AttributeError: 'dict' object has no attribute 'shape'
The text was updated successfully, but these errors were encountered:
OK, figured out having a key with "/" character in varm e.g. adata.varm['a/b'] = pd.DataFrame() causes the error.
adata.varm['a/b'] = pd.DataFrame()
Code to reproduce:
import scanpy as sc ad = sc.datasets.paul15() ad.varm['a/b'] = ad.X.T ad.write('ppp.h5ad') # interestingly, success ad = sc.read('ppp.h5ad') #uninterestingly, failure
Sorry, something went wrong.
Apparently it's already known (#321 (comment)), so closing this one, damn it already ate up 30min of my life :/
It would be good to at least warn users about this when we can.
No branches or pull requests
Following is an error I get when I read an anndata file which I unfortunately cannot share but I thought it might be helpful nevertheless:
The text was updated successfully, but these errors were encountered: