FRED-2 / OptiType

Precision HLA typing from next-generation sequencing data

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OptiType crash due to pandas deprecation

Stikus opened this issue · comments

Hello.
Today I got this error:

Traceback (most recent call last):
  File "/soft/OptiType-1.3.2/OptiTypePipeline.py", line 433, in <module>
    hlatype = result.iloc[0][["A1", "A2", "B1", "B2", "C1", "C2"]].drop_duplicates().dropna()
  File "/usr/local/lib/python3.7/dist-packages/pandas/core/series.py", line 910, in __getitem__
    return self._get_with(key)
  File "/usr/local/lib/python3.7/dist-packages/pandas/core/series.py", line 958, in _get_with
    return self.loc[key]
  File "/usr/local/lib/python3.7/dist-packages/pandas/core/indexing.py", line 1767, in __getitem__
    return self._getitem_axis(maybe_callable, axis=axis)
  File "/usr/local/lib/python3.7/dist-packages/pandas/core/indexing.py", line 1953, in _getitem_axis
    return self._getitem_iterable(key, axis=axis)
  File "/usr/local/lib/python3.7/dist-packages/pandas/core/indexing.py", line 1594, in _getitem_iterable
    keyarr, indexer = self._get_listlike_indexer(key, axis, raise_missing=False)
  File "/usr/local/lib/python3.7/dist-packages/pandas/core/indexing.py", line 1552, in _get_listlike_indexer
    keyarr, indexer, o._get_axis_number(axis), raise_missing=raise_missing
  File "/usr/local/lib/python3.7/dist-packages/pandas/core/indexing.py", line 1654, in _validate_read_indexer
    "Passing list-likes to .loc or [] with any missing labels "
KeyError: 'Passing list-likes to .loc or [] with any missing labels is no longer supported, see https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#deprecate-loc-reindex-listlike'

The reason of this error is this line:
hlatype = result.iloc[0][["A1", "A2", "B1", "B2", "C1", "C2"]].drop_duplicates().dropna()

According to docs: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#deprecate-loc-reindex-listlike I modified this line to reindex:
hlatype = result.iloc[0].reindex(["A1", "A2", "B1", "B2", "C1", "C2"]).drop_duplicates().dropna().

For now it's working but I need some more tests and other opinions on this.

Thanks for great tool.

Thanks, I changed the slice operator to .reindex.