broadinstitute / pooled-cell-painting-profiling-recipe

:woman_cook: Recipe repository for image-based profiling of Pooled Cell Painting experiments
BSD 3-Clause "New" or "Revised" License
6 stars 4 forks source link

Metadata in 7.visualize-cell-summary.py #32

Closed gwaybio closed 4 years ago

gwaybio commented 4 years ago

in these lines we load metadata and append to a metadata_list. However, this is never used in this script.

I did not see this when I reviewed #18, but I ran into it now when I came across this error:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-8-235105add032> in <module>
     10     metadata_df = (
     11         pd.read_csv(metadata_file, sep="\t")
---> 12         .loc[:, metadata_col_list]
     13         .reset_index(drop=True)
     14     )

~/miniconda3/envs/pooled-cp/lib/python3.7/site-packages/pandas/core/indexing.py in __getitem__(self, key)
   1759                 except (KeyError, IndexError, AttributeError):
   1760                     pass
-> 1761             return self._getitem_tuple(key)
   1762         else:
   1763             # we by definition only have the 0th axis

~/miniconda3/envs/pooled-cp/lib/python3.7/site-packages/pandas/core/indexing.py in _getitem_tuple(self, tup)
   1286                 continue
   1287 
-> 1288             retval = getattr(retval, self.name)._getitem_axis(key, axis=i)
   1289 
   1290         return retval

~/miniconda3/envs/pooled-cp/lib/python3.7/site-packages/pandas/core/indexing.py in _getitem_axis(self, key, axis)
   1951                     raise ValueError("Cannot index with multidimensional key")
   1952 
-> 1953                 return self._getitem_iterable(key, axis=axis)
   1954 
   1955             # nested tuple slicing

~/miniconda3/envs/pooled-cp/lib/python3.7/site-packages/pandas/core/indexing.py in _getitem_iterable(self, key, axis)
   1592         else:
   1593             # A collection of keys
-> 1594             keyarr, indexer = self._get_listlike_indexer(key, axis, raise_missing=False)
   1595             return self.obj._reindex_with_indexers(
   1596                 {axis: [keyarr, indexer]}, copy=True, allow_dups=True

~/miniconda3/envs/pooled-cp/lib/python3.7/site-packages/pandas/core/indexing.py in _get_listlike_indexer(self, key, axis, raise_missing)
   1550 
   1551         self._validate_read_indexer(
-> 1552             keyarr, indexer, o._get_axis_number(axis), raise_missing=raise_missing
   1553         )
   1554         return keyarr, indexer

~/miniconda3/envs/pooled-cp/lib/python3.7/site-packages/pandas/core/indexing.py in _validate_read_indexer(self, key, indexer, axis, raise_missing)
   1652             if not (ax.is_categorical() or ax.is_interval()):
   1653                 raise KeyError(
-> 1654                     "Passing list-likes to .loc or [] with any missing labels "
   1655                     "is no longer supported, see "
   1656                     "https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#deprecate-loc-reindex-listlike"  # noqa:E501

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'

@ErinWeisbart - is it safe to remove metadata references in this script?

ErinWeisbart commented 4 years ago

Yes. It is safe to remove those lines as well as line 65 metadata_list = [] It's an artifact of leaving out some outputs that were in the original script (see discussion here). Sorry for missing that.