Hello Again,
After getting a DecodedIntensityTable
from my data, I am unable to get information out of that object by either .to_decoded_dataframe()
or by AssignTargets.Label().run()
, and the error messages I am getting are not useful for helping locate the source of the problem.
I can provide additional code but by and large, the operations used are similar to those in the User Guide.
print(decoded_filtered)
print(decoded_filtered.to_decoded_dataframe())
With [truncated] output:
<xarray.DecodedIntensityTable (features: 14854, c: 12, r: 5)>
array([ removed ])
Coordinates:
radius (features) float64 4.0 1.0 1.0 1.0 ... 1.0 1.0 1.0 4.0
z (features) int64 0 0 0 0 0 0 0 0 0 ... 0 0 0 0 0 0 0 0 0
y (features) int64 2034 2022 2002 1995 1983 ... 6 3 3 0 0
x (features) int64 1946 2025 1966 1993 242 ... 596 43 423 8
* r (r) int64 0 1 2 3 4
* c (c) int64 0 1 2 3 4 5 6 7 8 9 10 11
xc (features) float64 0.9507 0.9893 ... 0.2066 0.003908
yc (features) float64 0.9936 0.9878 0.978 ... 0.0 0.0
zc (features) float64 0.05 0.05 0.05 0.05 ... 0.05 0.05 0.05
target (features) <U13 'Cnn3' 'Limd1' ... 'Fubp3' 'Polr3e'
distance (features) float64 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0
passes_thresholds (features) bool True True True True ... True True True
cell_id (features) <U8 'nan' 'nan' 'nan' ... 'nan' 'nan' 'nan'
Dimensions without coordinates: features
Attributes:
starfish: {"log": [{"method": "Reduce", "arguments": {"dims": "\"{<Axes....
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-30-0ffa0da52e8c> in <module>
1 print(decoded_filtered)
----> 2 print(decoded_filtered.to_decoded_dataframe())
/usr/local/lib/python3.6/dist-packages/starfish/core/intensity_table/decoded_intensity_table.py in to_decoded_dataframe(self)
102 df = self.to_features_dataframe()
103 pixel_coordinates = pd.Index([Axes.X, Axes.Y, Axes.ZPLANE])
--> 104 df = df.drop(pixel_coordinates.intersection(df.columns), axis=1).drop(Features.AXIS, axis=1)
105 return DecodedSpots(df)
106
/usr/local/lib/python3.6/dist-packages/pandas/core/frame.py in drop(self, labels, axis, index, columns, level, inplace, errors)
3995 level=level,
3996 inplace=inplace,
-> 3997 errors=errors,
3998 )
3999
/usr/local/lib/python3.6/dist-packages/pandas/core/generic.py in drop(self, labels, axis, index, columns, level, inplace, errors)
3934 for axis, labels in axes.items():
3935 if labels is not None:
-> 3936 obj = obj._drop_axis(labels, axis, level=level, errors=errors)
3937
3938 if inplace:
/usr/local/lib/python3.6/dist-packages/pandas/core/generic.py in _drop_axis(self, labels, axis, level, errors)
3968 new_axis = axis.drop(labels, level=level, errors=errors)
3969 else:
-> 3970 new_axis = axis.drop(labels, errors=errors)
3971 result = self.reindex(**{axis_name: new_axis})
3972
/usr/local/lib/python3.6/dist-packages/pandas/core/indexes/base.py in drop(self, labels, errors)
5016 if mask.any():
5017 if errors != "ignore":
-> 5018 raise KeyError(f"{labels[mask]} not found in axis")
5019 indexer = indexer[~mask]
5020 return self.delete(indexer)
KeyError: "['features'] not found in axis"
And after generating a BinaryMaskCollection
with cell labels from segmentation, cell ids cannot be added to the DecodedIntensityTable
.
print(area_filt)
assigner = AssignTargets.Label()
labeled = assigner.run(area_filt, decoded_filtered)
with output:
<starfish.core.morphology.binary_mask.binary_mask.BinaryMaskCollection object at 0x7f701dbb7470>
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/xarray/core/dataarray.py in _getitem_coord(self, key)
628 try:
--> 629 var = self._coords[key]
630 except KeyError:
KeyError: 'spot_id'
During handling of the above exception, another exception occurred:
KeyError Traceback (most recent call last)
<ipython-input-25-81259438a325> in <module>
1 assigner = AssignTargets.Label()
----> 2 labeled = assigner.run(area_filt, decoded_filtered)
3 labeled_filtered = labeled[labeled.cell_id != 'nan']
/usr/local/lib/python3.6/dist-packages/starfish/core/pipeline/algorithmbase.py in helper(*args, **kwargs)
21 @functools.wraps(func)
22 def helper(*args, **kwargs):
---> 23 result = func(*args, **kwargs)
24 if result is not None:
25 method_class_str = str(args[0].__class__)
/usr/local/lib/python3.6/dist-packages/starfish/core/spots/AssignTargets/label.py in run(self, masks, decoded_intensity_table, verbose, in_place)
94
95 """
---> 96 return self._assign(masks, decoded_intensity_table, in_place=in_place)
/usr/local/lib/python3.6/dist-packages/starfish/core/spots/AssignTargets/label.py in _assign(masks, decoded_intensities, in_place)
61 selectors['z'] = in_bbox.z
62 in_mask = mask.sel(**selectors)
---> 63 spot_ids = in_bbox[Features.SPOT_ID][in_mask.values]
64 decoded_intensities[Features.CELL_ID].loc[
65 decoded_intensities[Features.SPOT_ID].isin(spot_ids)] = mask.name
/usr/local/lib/python3.6/dist-packages/xarray/core/dataarray.py in __getitem__(self, key)
638 def __getitem__(self, key: Any) -> "DataArray":
639 if isinstance(key, str):
--> 640 return self._getitem_coord(key)
641 else:
642 # xarray-style array indexing
/usr/local/lib/python3.6/dist-packages/xarray/core/dataarray.py in _getitem_coord(self, key)
631 dim_sizes = dict(zip(self.dims, self.shape))
632 _, key, var = _get_virtual_variable(
--> 633 self._coords, key, self._level_coords, dim_sizes
634 )
635
/usr/local/lib/python3.6/dist-packages/xarray/core/dataset.py in _get_virtual_variable(variables, key, level_vars, dim_sizes)
169 ref_var = dim_var.to_index_variable().get_level_variable(ref_name)
170 else:
--> 171 ref_var = variables[ref_name]
172
173 if var_name is None:
KeyError: 'spot_id'