`ir.tl.chain_qc(adata)` error message with scirpy 0.18.0

I’m an amateur user of Python and the scverse ecosystem. I ran into an error with scirpy 0.18.0 that I don’t quite understand.

adata
AnnData object with n_obs × n_vars = 3618 × 16185
    obs: 'orig.ident', 'nCount_RNA', 'nFeature_RNA', ... 'sampleClusters', 'contigCellBarcode', 'barcode', 'CTgene', 'CTnt', 'CTaa', 'CTstrict', 'Frequency', 'cloneType', 'ident'
    var: 'highly_variable', 'means', 'dispersions', 'dispersions_norm', 'highly_variable_nbatches', 'highly_variable_intersection'
    uns: 'X_name', 'chain_indices', 'hvg', 'log1p'
    obsm: 'airr', 'chain_indices'
    layers: 'logcounts'
ir.tl.chain_qc(adata)

Error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[37], line 1
----> 1 ir.tl.chain_qc(adata)

File ~/miniconda3/envs/scirpy/lib/python3.11/site-packages/scirpy/tl/_chain_qc.py:86, in chain_qc(adata, airr_mod, airr_key, chain_idx_key, inplace, key_added)
     83 res_receptor_type = np.empty(dtype=f"<U{string_length}", shape=(params.adata.shape[0],))
     84 res_receptor_subtype = np.empty(dtype=f"<U{string_length}", shape=(params.adata.shape[0],))
---> 86 mask_has_ir = get._has_ir(params)
     87 mask_multichain = mask_has_ir & ak.to_numpy(params.chain_indices["multichain"])
     89 vj_loci = cast(np.ndarray, get.airr(params, "locus", ["VJ_1", "VJ_2"]).values)

File ~/miniconda3/envs/scirpy/lib/python3.11/site-packages/scirpy/get/__init__.py:207, in _has_ir(params)
    204 def _has_ir(params: DataHandler):
    205     """Return a mask of all cells that have a valid IR configuration"""
    206     return ak.to_numpy(
--> 207         (ak.count(params.chain_indices["VJ"], axis=1) + ak.count(params.chain_indices["VDJ"], axis=1)) > 0
    208     )

File ~/miniconda3/envs/scirpy/lib/python3.11/site-packages/awkward/_operators.py:53, in _binary_method.<locals>.func(self, other)
     51 if _disables_array_ufunc(other):
     52     return NotImplemented
---> 53 return ufunc(self, other)

File ~/miniconda3/envs/scirpy/lib/python3.11/site-packages/awkward/highlevel.py:1511, in Array.__array_ufunc__(self, ufunc, method, *inputs, **kwargs)
   1509 name = f"{type(ufunc).__module__}.{ufunc.__name__}.{method!s}"
   1510 with ak._errors.OperationErrorContext(name, inputs, kwargs):
-> 1511     return ak._connect.numpy.array_ufunc(ufunc, method, inputs, kwargs)

File ~/miniconda3/envs/scirpy/lib/python3.11/site-packages/awkward/_connect/numpy.py:466, in array_ufunc(ufunc, method, inputs, kwargs)
    458         raise TypeError(
    459             "no {}.{} overloads for custom types: {}".format(
    460                 type(ufunc).__module__, ufunc.__name__, ", ".join(error_message)
    461             )
    462         )
    464     return None
--> 466 out = ak._broadcasting.broadcast_and_apply(
    467     inputs, action, allow_records=False, function_name=ufunc.__name__
    468 )
    470 if len(out) == 1:
    471     return wrap_layout(out[0], behavior=behavior, attrs=attrs)

File ~/miniconda3/envs/scirpy/lib/python3.11/site-packages/awkward/_broadcasting.py:1140, in broadcast_and_apply(inputs, action, depth_context, lateral_context, allow_records, left_broadcast, right_broadcast, numpy_to_regular, regular_to_jagged, function_name, broadcast_parameters_rule)
   1138 backend = backend_of(*inputs, coerce_to_common=False)
   1139 isscalar = []
-> 1140 out = apply_step(
   1141     backend,
   1142     broadcast_pack(inputs, isscalar),
   1143     action,
   1144     0,
   1145     depth_context,
   1146     lateral_context,
   1147     {
   1148         "allow_records": allow_records,
   1149         "left_broadcast": left_broadcast,
   1150         "right_broadcast": right_broadcast,
   1151         "numpy_to_regular": numpy_to_regular,
   1152         "regular_to_jagged": regular_to_jagged,
   1153         "function_name": function_name,
   1154         "broadcast_parameters_rule": broadcast_parameters_rule,
   1155     },
   1156 )
   1157 assert isinstance(out, tuple)
   1158 return tuple(broadcast_unpack(x, isscalar) for x in out)

File ~/miniconda3/envs/scirpy/lib/python3.11/site-packages/awkward/_broadcasting.py:1118, in apply_step(backend, inputs, action, depth, depth_context, lateral_context, options)
   1116     return result
   1117 elif result is None:
-> 1118     return continuation()
   1119 else:
   1120     raise AssertionError(result)

File ~/miniconda3/envs/scirpy/lib/python3.11/site-packages/awkward/_broadcasting.py:1087, in apply_step.<locals>.continuation()
   1085 # Any non-string list-types?
   1086 elif any(x.is_list and not is_string_like(x) for x in contents):
-> 1087     return broadcast_any_list()
   1089 # Any RecordArrays?
   1090 elif any(x.is_record for x in contents):

File ~/miniconda3/envs/scirpy/lib/python3.11/site-packages/awkward/_broadcasting.py:623, in apply_step.<locals>.broadcast_any_list()
    620         nextinputs.append(x)
    621         nextparameters.append(NO_PARAMETERS)
--> 623 outcontent = apply_step(
    624     backend,
    625     nextinputs,
    626     action,
    627     depth + 1,
    628     copy.copy(depth_context),
    629     lateral_context,
    630     options,
    631 )
    632 assert isinstance(outcontent, tuple)
    633 parameters = parameters_factory(nextparameters, len(outcontent))

File ~/miniconda3/envs/scirpy/lib/python3.11/site-packages/awkward/_broadcasting.py:1100, in apply_step(backend, inputs, action, depth, depth_context, lateral_context, options)
   1093     else:
   1094         raise ValueError(
   1095             "cannot broadcast: {}{}".format(
   1096                 ", ".join(repr(type(x)) for x in inputs), in_function(options)
   1097             )
   1098         )
-> 1100 result = action(
   1101     inputs,
   1102     depth=depth,
   1103     depth_context=depth_context,
   1104     lateral_context=lateral_context,
   1105     continuation=continuation,
   1106     backend=backend,
   1107     options=options,
   1108 )
   1110 if isinstance(result, tuple) and all(isinstance(x, Content) for x in result):
   1111     if any(content.backend is not backend for content in result):

File ~/miniconda3/envs/scirpy/lib/python3.11/site-packages/awkward/_connect/numpy.py:458, in array_ufunc.<locals>.action(inputs, **ignore)
    456         else:
    457             error_message.append(type(x).__name__)
--> 458     raise TypeError(
    459         "no {}.{} overloads for custom types: {}".format(
    460             type(ufunc).__module__, ufunc.__name__, ", ".join(error_message)
    461         )
    462     )
    464 return None

TypeError: no numpy.add overloads for custom types: AwkwardArrayView, AwkwardArrayView

This error occurred while calling

    numpy.add.__call__(
        <AwkwardArrayView [1, 2, 1, 1, 2, ..., 1, 2, 1, 1, 1] type='3618 * ...'>
        <AwkwardArrayView [1, 1, 1, 1, 1, ..., 1, 1, 1, 2, 1] type='3618 * ...'>
    )

Session info

Click to view session information
-----
anndata             0.10.8
awkward             2.6.9
matplotlib          3.9.2
natsort             8.4.0
numpy               2.0.2
pandas              2.2.3
scanpy              1.10.3
scipy               1.14.1
scirpy              0.18.0
seaborn             0.13.2
session_info        1.0.0
-----
Click to view modules imported as dependencies
Levenshtein                 0.26.0
PIL                         11.0.0
adjustText                  1.2.0
airr                        1.5.1
asttokens                   NA
awkward_cpp                 NA
backports                   NA
charset_normalizer          3.4.0
comm                        0.2.2
cycler                      0.12.1
cython_runtime              NA
dateutil                    2.9.0.post0
debugpy                     1.8.7
decorator                   5.1.1
executing                   2.1.0
fsspec                      2024.9.0
h5py                        3.12.1
igraph                      0.11.6
importlib_metadata          NA
ipykernel                   6.29.5
jaraco                      NA
jedi                        0.19.1
joblib                      1.4.2
kiwisolver                  1.4.7
legacy_api_wrap             NA
llvmlite                    0.43.0
more_itertools              10.3.0
mpl_toolkits                NA
mudata                      0.3.1
networkx                    3.4.1
numba                       0.60.0
packaging                   24.1
parso                       0.8.4
patsy                       0.5.6
pexpect                     4.9.0
pkg_resources               NA
platformdirs                4.3.6
pooch                       v1.8.2
prompt_toolkit              3.0.48
psutil                      6.0.0
ptyprocess                  0.7.0
pure_eval                   0.2.3
pydev_ipython               NA
pydevconsole                NA
pydevd                      3.1.0
pydevd_file_utils           NA
pydevd_plugins              NA
pydevd_tracing              NA
pygments                    2.18.0
pyparsing                   3.2.0
pytz                        2024.2
rapidfuzz                   3.10.0
six                         1.16.0
sklearn                     1.5.2
stack_data                  0.6.3
statsmodels                 0.14.4
texttable                   1.7.0
threadpoolctl               3.5.0
tornado                     6.4.1
tqdm                        4.66.5
tracerlib                   NA
traitlets                   5.14.3
typing_extensions           NA
wcwidth                     0.2.13
yaml                        6.0.2
yamlordereddictloader       NA
zipp                        NA
zmq                         26.2.0
zoneinfo                    NA
-----
IPython             8.28.0
jupyter_client      8.6.3
jupyter_core        5.7.2
-----
Python 3.11.10 | packaged by conda-forge | (main, Oct 16 2024, 01:27:36) [GCC 13.3.0]
Linux-3.10.0-1160.118.1.el7.x86_64-x86_64-with-glibc2.17
-----
Session information updated at 2024-10-17 15:04

Thanks for reporting! This is definitely not your fault, possibly something has changed, most likely either in numpy, or awkward. I’ll look into this.

HI @yls2g13,

I was not able to reproduce the issue, but I created a patch that might fix it.

Could you please install this version from github using

pip install git+https://github.com/scverse/scirpy.git@fix-563

and let me know if it resolves your issue?

This works! Thanks for your prompt reply Gregor!