-
Notifications
You must be signed in to change notification settings - Fork 26
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Description of the bug
I want to convert AIRR from scirpy to dandelion, but I get an error and cannot do it.Please help me.
Minimal reproducible example
import dandelion as ddl
mdata = md.read("iunput/mdata.h5mu")
vdj = ddl.from_scirpy(mdata)The error message produced by the code above
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[30], line 1
----> 1 vdj = ddl.from_scirpy(mdata)
File ~/mambaforge/envs/scanpy/lib/python3.12/site-packages/dandelion/utilities/_io.py:1242, in from_scirpy(data)
1240 data = data.copy()
1241 data.obsm["airr"]["cell_id"] = data.obs.index
-> 1242 data = from_ak(data.obsm["airr"])
1244 return Dandelion(data)
File ~/mambaforge/envs/scanpy/lib/python3.12/site-packages/dandelion/utilities/_io.py:1033, in from_ak(airr)
1013 """
1014 Convert an AIRR-formatted array to a pandas DataFrame.
1015
(...)
1029 If `sequence_id` not found in the data.
1030 """
1031 import awkward as ak
-> 1033 df = ak.to_dataframe(airr)
1034 # check if 'sequence_id' column does not exist or if any value in 'sequence_id' is NaN
1035 if "sequence_id" not in df.columns or df["sequence_id"].isnull().any():
File ~/mambaforge/envs/scanpy/lib/python3.12/site-packages/awkward/_dispatch.py:64, in named_high_level_function.<locals>.dispatch(*args, **kwargs)
62 # Failed to find a custom overload, so resume the original function
63 try:
---> 64 next(gen_or_result)
65 except StopIteration as err:
66 return err.value
File ~/mambaforge/envs/scanpy/lib/python3.12/site-packages/awkward/operations/ak_to_dataframe.py:141, in to_dataframe(array, how, levelname, anonymous)
138 yield (array,)
140 # Implementation
--> 141 return _impl(array, how, levelname, anonymous)
File ~/mambaforge/envs/scanpy/lib/python3.12/site-packages/awkward/operations/ak_to_dataframe.py:160, in _impl(array, how, levelname, anonymous)
158 if how is not None:
159 out = None
--> 160 for df in to_dataframe(
161 array, how=None, levelname=levelname, anonymous=anonymous
162 ):
163 if out is None:
164 out = df
File ~/mambaforge/envs/scanpy/lib/python3.12/site-packages/awkward/_dispatch.py:64, in named_high_level_function.<locals>.dispatch(*args, **kwargs)
62 # Failed to find a custom overload, so resume the original function
63 try:
---> 64 next(gen_or_result)
65 except StopIteration as err:
66 return err.value
File ~/mambaforge/envs/scanpy/lib/python3.12/site-packages/awkward/operations/ak_to_dataframe.py:141, in to_dataframe(array, how, levelname, anonymous)
138 yield (array,)
140 # Implementation
--> 141 return _impl(array, how, levelname, anonymous)
File ~/mambaforge/envs/scanpy/lib/python3.12/site-packages/awkward/operations/ak_to_dataframe.py:229, in _impl(array, how, levelname, anonymous)
227 tables = []
228 last_row_arrays = None
--> 229 for column, row_arrays, col_names in recurse(layout2, [], ()):
230 if isinstance(layout, ak.record.Record):
231 row_arrays = row_arrays[1:] # Record --> one-element RecordArray
File ~/mambaforge/envs/scanpy/lib/python3.12/site-packages/awkward/operations/ak_to_dataframe.py:192, in _impl.<locals>.recurse(layout, row_arrays, col_names)
187 newrows = [numpy.repeat(x, counts) for x in row_arrays]
188 newrows.append(
189 numpy.arange(offsets[-1], dtype=counts.dtype)
190 - numpy.repeat(starts, counts)
191 )
--> 192 return recurse(flattened, newrows, col_names)
194 elif layout.is_union:
195 layout = _union_to_record(layout, anonymous)
File ~/mambaforge/envs/scanpy/lib/python3.12/site-packages/awkward/operations/ak_to_dataframe.py:209, in _impl.<locals>.recurse(layout, row_arrays, col_names)
199 return reduce(
200 iconcat,
201 (
(...)
205 [],
206 )
208 elif isinstance(layout, ak.contents.RecordArray):
--> 209 return reduce(
210 iconcat,
211 (
212 recurse(layout._getitem_field(n), row_arrays, (*col_names, n))
213 for n in layout.fields
214 ),
215 [],
216 )
218 else:
219 return [(ak.operations.to_numpy(layout), row_arrays, col_names)]
File ~/mambaforge/envs/scanpy/lib/python3.12/site-packages/awkward/operations/ak_to_dataframe.py:212, in <genexpr>(.0)
199 return reduce(
200 iconcat,
201 (
(...)
205 [],
206 )
208 elif isinstance(layout, ak.contents.RecordArray):
209 return reduce(
210 iconcat,
211 (
--> 212 recurse(layout._getitem_field(n), row_arrays, (*col_names, n))
213 for n in layout.fields
214 ),
215 [],
216 )
218 else:
219 return [(ak.operations.to_numpy(layout), row_arrays, col_names)]
File ~/mambaforge/envs/scanpy/lib/python3.12/site-packages/awkward/operations/ak_to_dataframe.py:195, in _impl.<locals>.recurse(layout, row_arrays, col_names)
192 return recurse(flattened, newrows, col_names)
194 elif layout.is_union:
--> 195 layout = _union_to_record(layout, anonymous)
196 if layout.is_union:
197 return [(ak.operations.to_numpy(layout), row_arrays, col_names)]
File ~/mambaforge/envs/scanpy/lib/python3.12/site-packages/awkward/operations/ak_to_dataframe.py:305, in _union_to_record(unionarray, anonymous)
302 contents.append(layout)
304 if not any(isinstance(x, ak.contents.RecordArray) for x in contents):
--> 305 return ak.contents.UnionArray(
306 unionarray.tags,
307 unionarray.index,
308 contents,
309 parameters=unionarray.parameters,
310 )
312 else:
313 seen = set()
File ~/mambaforge/envs/scanpy/lib/python3.12/site-packages/awkward/contents/unionarray.py:142, in UnionArray.__init__(self, tags, index, contents, parameters)
138 raise TypeError(
139 f"{type(self).__name__} all 'contents' must be Content subclasses, not {content!r}"
140 )
141 if content.is_union:
--> 142 raise TypeError(
143 "{0} cannot contain union-types in its 'contents' ({1}); try {0}.simplified instead".format(
144 type(self).__name__, type(content).__name__
145 )
146 )
147 elif content.is_option:
148 n_seen_options += 1
TypeError: UnionArray cannot contain union-types in its 'contents' (UnionArray); try UnionArray.simplified instead
This error occurred while calling
ak.to_dataframe(
<Array [[{c_call: 'TRBC1', ...}, ...], ...] type='28660 * var * {c_...'>
)OS information
No response
Version information
dandelio=0.55 scirpy=0.21.0
Additional context
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working