davidvi / pypanda

Python implementation of PANDA (Passing Attributes between Networks for Data Assimilation)
38 stars 11 forks source link

Error #5

Open NimritaKoul opened 6 years ago

NimritaKoul commented 6 years ago

I am getting this error while running this line p = Panda('ToyExpressionData.txt', 'ToyMotifData.txt', 'ToyPPIData.txt', remove_missing=False)

In anaconda Jupyter Notebook, Anaconda , Python 3

TypeError Traceback (most recent call last) pandas_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.Int64HashTable.get_item()

TypeError: an integer is required

During handling of the above exception, another exception occurred:

KeyError Traceback (most recent call last) C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance) 2441 try: -> 2442 return self._engine.get_loc(key) 2443 except KeyError:

pandas_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc()

KeyError: range(1, 51)

During handling of the above exception, another exception occurred:

TypeError Traceback (most recent call last) pandas_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.Int64HashTable.get_item()

TypeError: an integer is required

During handling of the above exception, another exception occurred:

KeyError Traceback (most recent call last)

in () ----> 1 p = Panda('ToyExpressionData.txt', 'ToyMotifData.txt') C:\ProgramData\Anaconda3\lib\site-packages\pypanda-0.1-py3.6.egg\pypanda\panda.py in __init__(self, expression_file, motif_file, ppi_file, remove_missing) 26 self.__remove_missing() 27 #expression data to matrix ---> 28 self.__expression_data_to_matrix() 29 #motif data to matrix 30 if self.motif_data is not None: C:\ProgramData\Anaconda3\lib\site-packages\pypanda-0.1-py3.6.egg\pypanda\panda.py in __expression_data_to_matrix(self) 66 self.gene_names = list(self.expression_data[0]) 67 self.num_genes = len(self.gene_names) ---> 68 self.expression_data = self.expression_data[range(1, len(self.expression_data.columns))] 69 self.expression_matrix = np.matrix(self.expression_data.as_matrix()) 70 return None C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\frame.py in __getitem__(self, key) 1962 return self._getitem_multilevel(key) 1963 else: -> 1964 return self._getitem_column(key) 1965 1966 def _getitem_column(self, key): C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\frame.py in _getitem_column(self, key) 1969 # get column 1970 if self.columns.is_unique: -> 1971 return self._get_item_cache(key) 1972 1973 # duplicate columns & possible reduce dimensionality C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\generic.py in _get_item_cache(self, item) 1643 res = cache.get(item) 1644 if res is None: -> 1645 values = self._data.get(item) 1646 res = self._box_item_values(item, values) 1647 cache[item] = res C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\internals.py in get(self, item, fastpath) 3588 3589 if not isnull(item): -> 3590 loc = self.items.get_loc(item) 3591 else: 3592 indexer = np.arange(len(self.items))[isnull(self.items)] C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance) 2442 return self._engine.get_loc(key) 2443 except KeyError: -> 2444 return self._engine.get_loc(self._maybe_cast_indexer(key)) 2445 2446 indexer = self.get_indexer([key], method=method, tolerance=tolerance) pandas\_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc() pandas\_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc() KeyError: range(1, 51)
isaacyeozhuern commented 6 years ago

Hello, I also get some errors while running the pypanda, so try using the fix below . Below is the solution I got from one of the author. All credit goes to her, I didnt own anything nor did I contribute anything. Btw.. I use python version 2.7... -----Original Message----- All credits goes to Alessandro Marin and Marieke Kuijjer

Before running AnalyzePanda you should import that module as follows: from pypanda.analyze_panda import AnalyzePanda David forgot to mention that in the README. Sorry for that.

In addition to this I noticed that some code fails because dependencies have changed in the last years. You should change these lines of code:

In pypanda/analyze_panda.py: bad>subset_panda_results = self.panda_results.sort(['force'], ascending = [0]) good>subset_panda_results = self.panda_results.sort_values(by=['force'], ascending = False)

In pypanda/pandas.py: bad>subset_indegree = self.export_panda_results[[1,3]] good>subset_indegree = self.export_panda_results.loc[:,['gene','force']] bad>subset_outdegree = self.export_panda_results[[0,3]] good>subset_outdegree = self.export_panda_results.loc[:,['tf','force']]

NimritaKoul commented 6 years ago

Thanks.

On 7 July 2018 at 10:32, isaacyeozhuern notifications@github.com wrote:

Hello, I got similiar errors so the below is the solution I got from one of the author. All credit goes to her, I didnt own anything nor did I contribute anything. -----Original Message----- All credits goes to Alessandro Marin and Marieke Kuijjer

Before running AnalyzePanda you should import that module as follows: from pypanda.analyze_panda import AnalyzePanda David forgot to mention that in the README. Sorry for that.

In addition to this I noticed that some code fails because dependencies have changed in the last years. You should change these lines of code:

In pypanda/analyze_panda.py: bad>subset_panda_results = self.panda_results.sort(['force'], ascending = [0]) good>subset_panda_results = self.panda_results.sort_values(by=['force'], ascending = False)

In pypanda/pandas.py: bad>subset_indegree = self.export_panda_results[[1,3]] good>subset_indegree = self.export_panda_results.loc[:,['gene','force']] bad>subset_outdegree = self.export_panda_results[[0,3]] good>subset_outdegree = self.export_panda_results.loc[:,['tf','force']]

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/davidvi/pypanda/issues/5#issuecomment-403189066, or mute the thread https://github.com/notifications/unsubscribe-auth/AbyuWKhXDk7F5YyfIhTp9wQx2pJA6Bqzks5uEEDrgaJpZM4UEF0B .

-- Thanks & Warm Regards Nimrita Koul