Cannot load filtered_contig_annotations.csv

Hi,

I keep getting an error " no fielded named ‘shape’." How should I continue?

thanks,
Morgan

# Load the BCR data
adata_bcr = ir.io.read_10x_vdj(
    "/home/jovyan/shared/Morgan/unsortApr24_VDJ/outs/filtered_contig_annotations.csv" ,
    filtered=True, include_fields=None
    )

# Load the associated transcriptomics data
adata = sc.read_10x_h5("/home/jovyan/shared/Morgan/unsortApr24_GEX/scabranger/cellranger/multi/Ag/outs/per_sample_outs/Ag/count/sample_filtered_feature_bc_matrix.h5")
adata.var_names_make_unique()
_______________________________________________________________________________________
AttributeError                            Traceback (most recent call last)
Cell In[46], line 2
      1 # Load the BCR data
----> 2 adata_bcr = ir.io.read_10x_vdj(
      3     "/home/jovyan/shared/Morgan/unsortApr24_VDJ/outs/filtered_contig_annotations.csv" ,
      4     filtered=True, include_fields=None
      5     )
      7 # Load the associated transcriptomics data
      8 adata = sc.read_10x_h5("/home/jovyan/shared/Morgan/unsortApr24_GEX/scabranger/cellranger/multi/Ag/outs/per_sample_outs/Ag/count/sample_filtered_feature_bc_matrix.h5")

File /opt/conda/lib/python3.11/site-packages/scirpy/io/_io.py:240, in read_10x_vdj(path, filtered, include_fields, **kwargs)
    237 else:
    238     airr_cells = _read_10x_vdj_csv(path, filtered)
--> 240 return from_airr_cells(airr_cells, **kwargs)

File /opt/conda/lib/python3.11/site-packages/scirpy/io/_convert_anndata.py:50, in from_airr_cells(airr_cells, key_added)
     44 obs.index = obs.index.astype(str)
     46 obsm = {
     47     key_added: ak.Array(c.chains for c in airr_cells),
     48 }
---> 50 adata = AnnData(
     51     X=None,
     52     obs=obs,
     53     obsm=obsm,
     54     uns={"scirpy_version": version("scirpy")},
     55 )
     57 return adata

File /opt/conda/lib/python3.11/site-packages/anndata/_core/anndata.py:362, in AnnData.__init__(self, X, obs, var, uns, obsm, varm, layers, raw, dtype, shape, filename, filemode, asview, obsp, varp, oidx, vidx)
    360     self._init_as_view(X, oidx, vidx)
    361 else:
--> 362     self._init_as_actual(
    363         X=X,
    364         obs=obs,
    365         var=var,
    366         uns=uns,
    367         obsm=obsm,
    368         varm=varm,
    369         raw=raw,
    370         layers=layers,
    371         dtype=dtype,
    372         shape=shape,
    373         obsp=obsp,
    374         varp=varp,
    375         filename=filename,
    376         filemode=filemode,
    377     )

File /opt/conda/lib/python3.11/site-packages/anndata/_core/anndata.py:564, in AnnData._init_as_actual(self, X, obs, var, uns, obsm, varm, varp, obsp, raw, layers, dtype, shape, filename, filemode)
    561 self.uns = uns or OrderedDict()
    563 # TODO: Think about consequences of making obsm a group in hdf
--> 564 self._obsm = AxisArrays(self, 0, vals=convert_to_dict(obsm))
    565 self._varm = AxisArrays(self, 1, vals=convert_to_dict(varm))
    567 self._obsp = PairwiseArrays(self, 0, vals=convert_to_dict(obsp))

File /opt/conda/lib/python3.11/site-packages/anndata/_core/aligned_mapping.py:288, in AxisArrays.__init__(self, parent, axis, vals)
    286 self._data = dict()
    287 if vals is not None:
--> 288     self.update(vals)

File <frozen _collections_abc>:949, in update(self, other, **kwds)

File /opt/conda/lib/python3.11/site-packages/anndata/_core/aligned_mapping.py:199, in AlignedActualMixin.__setitem__(self, key, value)
    198 def __setitem__(self, key: str, value: V):
--> 199     value = self._validate_value(value, key)
    200     self._data[key] = value

File /opt/conda/lib/python3.11/site-packages/anndata/_core/aligned_mapping.py:268, in AxisArraysBase._validate_value(self, val, key)
    266         msg = "Index.equals and pd.testing.assert_index_equal disagree"
    267         raise AssertionError(msg)
--> 268 return super()._validate_value(val, key)

File /opt/conda/lib/python3.11/site-packages/anndata/_core/aligned_mapping.py:72, in AlignedMapping._validate_value(self, val, key)
     65     warn_once(
     66         "Support for Awkward Arrays is currently experimental. "
     67         "Behavior may change in the future. Please report any issues you may encounter!",
     68         ExperimentalFeatureWarning,
     69         # stacklevel=3,
     70     )
     71 for i, axis in enumerate(self.axes):
---> 72     if self.parent.shape[axis] == dim_len(val, i):
     73         continue
     74     right_shape = tuple(self.parent.shape[a] for a in self.axes)

File /opt/conda/lib/python3.11/functools.py:909, in singledispatch.<locals>.wrapper(*args, **kw)
    905 if not args:
    906     raise TypeError(f'{funcname} requires at least '
    907                     '1 positional argument')
--> 909 return dispatch(args[0].__class__)(*args, **kw)

File /opt/conda/lib/python3.11/site-packages/anndata/utils.py:109, in dim_len(x, axis)
    102 @singledispatch
    103 def dim_len(x, axis):
    104     """\
    105     Return the size of an array in dimension `axis`.
    106 
    107     Returns None if `x` is an awkward array with variable length in the requested dimension.
    108     """
--> 109     return x.shape[axis]

File /opt/conda/lib/python3.11/site-packages/awkward/highlevel.py:1239, in Array.__getattr__(self, where)
   1234         raise AttributeError(
   1235             f"while trying to get field {where!r}, an exception "
   1236             f"occurred:\n{type(err)}: {err!s}"
   1237         ) from err
   1238 else:
-> 1239     raise AttributeError(f"no field named {where!r}")

AttributeError: no field named 'shape'

Hi Morgan,

thanks for reporting this issue! I can’t immediately tell why this is happening, but it seems like the versions of AnnData and awkward array are incompatible.

Could you please report back with the versions of AnnData and awkward you are using?

Best,
Gregor

Hi Gregor,

I am having the same issue.
Here are the version of the packages

Name: anndata
Version: 0.10.3

Name: awkward
Version: 2.6.5

Name: scirpy
Version: 0.17.0

Thank you!

Solved by downgrading awkward to 2.6.2

I couldn’t reproduce the issue with the given version numbers.

Looking at the AnnData code, I think this could happen if awkward is not installed when importing anndata, e.g. something like this:

import anndata # imports anndata, but doesn't register some awkward-specific functions because it's not installed yet. 
!pip install scirpy # installs scirpy, and awkward
import scirpy as ir
adata = ir.io.read_10x_vdj(...)