alevax / pyviper

Porting of Protein Activity and Pathway Inference to single cell and Python.
MIT License
4 stars 0 forks source link

network integration returns an error #76

Closed LucaZanella15 closed 3 weeks ago

LucaZanella15 commented 1 month ago

adata_PA = pyviper.viper(gex_data=adata_combined, interactome=list(a3_nets.values()), enrichment="area", eset_filter=False, store_input_data=True)

returns the following error: (perhaps could be due to multiple cells having the same name)


InvalidIndexError Traceback (most recent call last) Cell In[188], line 1 ----> 1 adata_PA = pyviper.viper(gex_data=adata_combined, interactome=list(a3_nets.values()), enrichment="area", eset_filter=False, store_input_data=True)

File ~/Desktop/ColumbiaProjects/pyviper/pyviper/_viper.py:272, in viper(gex_data, interactome, layer, eset_filter, method, enrichment, mvws, min_targets, njobs, batch_size, verbose, output_as_anndata, transfer_obs, store_input_data) 268 op.layers['pes'] = preOp["pes"] 270 if transfer_obs is True: 271 #op.obs = op.obs.join(gex_data.obs) --> 272 op.obs = pd.concat([op.obs.copy(), gex_data.obs.copy()],axis=1) 273 if store_input_data is True: 274 # If input data was pax_data for pathway enrichment 275 if 'gex_data' in gex_data.uns:

File ~/mambaforge/lib/python3.10/site-packages/pandas/util/_decorators.py:331, in deprecate_nonkeyword_arguments..decorate..wrapper(*args, *kwargs) 325 if len(args) > num_allow_args: 326 warnings.warn( 327 msg.format(arguments=_format_argument_list(allow_args)), 328 FutureWarning, 329 stacklevel=find_stack_level(), 330 ) --> 331 return func(args, **kwargs)

File ~/mambaforge/lib/python3.10/site-packages/pandas/core/reshape/concat.py:381, in concat(objs, axis, join, ignore_index, keys, levels, names, verify_integrity, sort, copy) 159 """ 160 Concatenate pandas objects along a particular axis. 161 (...) 366 1 3 4 367 """ 368 op = _Concatenator( 369 objs, 370 axis=axis, (...) 378 sort=sort, 379 ) --> 381 return op.get_result()

File ~/mambaforge/lib/python3.10/site-packages/pandas/core/reshape/concat.py:612, in _Concatenator.get_result(self) 610 obj_labels = obj.axes[1 - ax] 611 if not new_labels.equals(obj_labels): --> 612 indexers[ax] = obj_labels.get_indexer(new_labels) 614 mgrs_indexers.append((obj._mgr, indexers)) 616 new_data = concatenate_managers( 617 mgrs_indexers, self.new_axes, concat_axis=self.bm_axis, copy=self.copy 618 )

File ~/mambaforge/lib/python3.10/site-packages/pandas/core/indexes/base.py:3904, in Index.get_indexer(self, target, method, limit, tolerance) 3901 self._check_indexing_method(method, limit, tolerance) 3903 if not self._index_as_unique: -> 3904 raise InvalidIndexError(self._requires_unique_msg) 3906 if len(target) == 0: 3907 return np.array([], dtype=np.intp)

InvalidIndexError: Reindexing only valid with uniquely valued Index objects

LucaZanella15 commented 3 weeks ago

The issue was due to a few regulator-target pairs being present in multiple copies. Currently there aren't reasons why this function should allow for this behavior.

Issue closed.