PayneLab/cptac

`cptac` package failing on Import

Closed this issue · 3 comments

We are unable to use the CPTAC package primary bug here due to failure to import that package.

ValueError                                Traceback (most recent call last)
Cell In[1], line 1
----> 1 import cptac

File /opt/homebrew/lib/python3.11/site-packages/cptac/__init__.py:83
     79     # options_df.loc[options_df.iloc[:2].str.contains('miRNA')] = 'miRNA' # condense all forms of micro RNA
     80     # options_df = options_df.unique().reset_index(drop=True)
     81     return options_df
---> 83 OPTIONS = _load_options()
     85 def list_datasets(*, condense_on = None, column_order = None, print_tree=False):
     86     """
     87     List all available datasets.
     88     
     89     :param condense_on (list): A list of column names. Values in selected columns will be aggregated into a list.
     90     :param print_tree (bool): If True, returns the database split in a pretty tree.
     91     """

File /opt/homebrew/lib/python3.11/site-packages/cptac/__init__.py:77, in _load_options()
     75 """Load the tsv file with all the possible cancer, source, datatype combinations"""
     76 options_df = pd.DataFrame(INDEX['description'].str.split('-').tolist())
---> 77 options_df.columns = ['Source', 'Cancer', 'Datatype']
     78 options_df = options_df[['Cancer', 'Source', 'Datatype']]
     79 # options_df.loc[options_df.iloc[:2].str.contains('miRNA')] = 'miRNA' # condense all forms of micro RNA
     80 # options_df = options_df.unique().reset_index(drop=True)

File /opt/homebrew/lib/python3.11/site-packages/pandas/core/generic.py:6218, in NDFrame.__setattr__(self, name, value)
   6216 try:
   6217     object.__getattribute__(self, name)
-> 6218     return object.__setattr__(self, name, value)
   6219 except AttributeError:
   6220     pass

File properties.pyx:69, in pandas._libs.properties.AxisProperty.__set__()

File /opt/homebrew/lib/python3.11/site-packages/pandas/core/generic.py:767, in NDFrame._set_axis(self, axis, labels)
    762 """
    763 This is called from the cython code when we set the `index` attribute
    764 directly, e.g. `series.index = [1, 2, 3]`.
    765 """
    766 labels = ensure_index(labels)
--> 767 self._mgr.set_axis(axis, labels)
    768 self._clear_item_cache()

File /opt/homebrew/lib/python3.11/site-packages/pandas/core/internals/managers.py:227, in BaseBlockManager.set_axis(self, axis, new_labels)
    225 def set_axis(self, axis: AxisInt, new_labels: Index) -> None:
    226     # Caller is responsible for ensuring we have an Index object.
--> 227     self._validate_set_axis(axis, new_labels)
    228     self.axes[axis] = new_labels

File /opt/homebrew/lib/python3.11/site-packages/pandas/core/internals/base.py:85, in DataManager._validate_set_axis(self, axis, new_labels)
     82     pass
     84 elif new_len != old_len:
---> 85     raise ValueError(
     86         f"Length mismatch: Expected axis has {old_len} elements, new "
     87         f"values have {new_len} elements"
     88     )

ValueError: Length mismatch: Expected axis has 1 elements, new values have 3 elements

I apologize for the inconvenience! We just released a version 1.5.11 that should fix this issue, so please try pip install once again or --upgrade. Please let us know if the issue persists!

Re-opening this because I'm still finding it with 1.5.11 - can you let us know what version of pandas is recommended?

bm600 commented

Hello, sorry for the delay in responding. We have just released a new version (v1.5.14) that fixes other minor bugs. CPTAC should be compatible with pandas 1.5.3 and later versions. Please let us know if the error continues.