mazzalab / pyntacle

A high performance python package for network analysis based on non canonical metrics
http://pyntacle.css-mendel.it
9 stars 1 forks source link

[API] error in importing adjacency matrix with Pyntacle.importer #57

Open Bioswinger opened 3 years ago

Bioswinger commented 3 years ago

command used: g1=Pyntalce.importer.AdjacencyMatrix("my_directed_graph.adjm")

error received:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-221-d7b8e50b8195> in <module>()
      1 from pyntacle.io_stream.importer import PyntacleImporter as Pyimp
      2 
----> 3 g1=Pyimp.AdjacencyMatrix("pws_48_mass_transfer.txt")

/home/lorenzo/miniconda3/envs/new_pynt_env/lib/python3.7/site-packages/pyntacle/internal/io_utils.py in func_wrapper(file, *args, **kwargs)
     51             raise FileNotFoundError("Input file does not exist")
     52 
---> 53         return func(file, *args, **kwargs)
     54 
     55     return func_wrapper

/home/lorenzo/miniconda3/envs/new_pynt_env/lib/python3.7/site-packages/pyntacle/internal/io_utils.py in func_wrapper(file, sep, *args, **kwargs)
     97                 raise ValueError("\"sep\" must be a string {} found".format(type(sep).__name__))
     98 
---> 99         return func(file, sep, *args, **kwargs)
    100 
    101     return func_wrapper

/home/lorenzo/miniconda3/envs/new_pynt_env/lib/python3.7/site-packages/pyntacle/io_stream/importer.py in AdjacencyMatrix(file, sep, header)
    140                 f.index = f.index.map(str) #force index to string, in case is not identified properly
    141                 f = f.reindex(sorted(f.columns), axis=1)  # sort columns alphabetically
--> 142                 f = f.reindex(sorted(f.index), axis=0)  # sort indices alphabetically
    143                 node_names = f.columns.values.tolist()
    144 

/home/lorenzo/miniconda3/envs/new_pynt_env/lib/python3.7/site-packages/pandas/util/_decorators.py in wrapper(*args, **kwargs)
    307         @wraps(func)
    308         def wrapper(*args, **kwargs) -> Callable[..., Any]:
--> 309             return func(*args, **kwargs)
    310 
    311         kind = inspect.Parameter.POSITIONAL_OR_KEYWORD

/home/lorenzo/miniconda3/envs/new_pynt_env/lib/python3.7/site-packages/pandas/core/frame.py in reindex(self, *args, **kwargs)
   4034         kwargs.pop("axis", None)
   4035         kwargs.pop("labels", None)
-> 4036         return super().reindex(**kwargs)
   4037 
   4038     def drop(

/home/lorenzo/miniconda3/envs/new_pynt_env/lib/python3.7/site-packages/pandas/core/generic.py in reindex(self, *args, **kwargs)
   4460         # perform the reindex on the axes
   4461         return self._reindex_axes(
-> 4462             axes, level, limit, tolerance, method, fill_value, copy
   4463         ).__finalize__(self, method="reindex")
   4464 

/home/lorenzo/miniconda3/envs/new_pynt_env/lib/python3.7/site-packages/pandas/core/frame.py in _reindex_axes(self, axes, level, limit, tolerance, method, fill_value, copy)
   3881         if index is not None:
   3882             frame = frame._reindex_index(
-> 3883                 index, method, copy, level, fill_value, limit, tolerance
   3884             )
   3885 

/home/lorenzo/miniconda3/envs/new_pynt_env/lib/python3.7/site-packages/pandas/core/frame.py in _reindex_index(self, new_index, method, copy, level, fill_value, limit, tolerance)
   3903             copy=copy,
   3904             fill_value=fill_value,
-> 3905             allow_dups=False,
   3906         )
   3907 

/home/lorenzo/miniconda3/envs/new_pynt_env/lib/python3.7/site-packages/pandas/core/generic.py in _reindex_with_indexers(self, reindexers, fill_value, copy, allow_dups)
   4528                 fill_value=fill_value,
   4529                 allow_dups=allow_dups,
-> 4530                 copy=copy,
   4531             )
   4532             # If we've made a copy once, no need to make another one

/home/lorenzo/miniconda3/envs/new_pynt_env/lib/python3.7/site-packages/pandas/core/internals/managers.py in reindex_indexer(self, new_axis, indexer, axis, fill_value, allow_dups, copy, consolidate)
   1274         # some axes don't allow reindexing with dups
   1275         if not allow_dups:
-> 1276             self.axes[axis]._can_reindex(indexer)
   1277 
   1278         if axis >= self.ndim:

/home/lorenzo/miniconda3/envs/new_pynt_env/lib/python3.7/site-packages/pandas/core/indexes/base.py in _can_reindex(self, indexer)
   3287         # trying to reindex on an axis with duplicates
   3288         if not self.is_unique and len(indexer):
-> 3289             raise ValueError("cannot reindex from a duplicate axis")
   3290 
   3291     def reindex(self, target, method=None, level=None, limit=None, tolerance=None):

ValueError: cannot reindex from a duplicate axis
mazzalab commented 3 years ago

can you share here the "pws_48_mass_transfer.txt" file?

Bioswinger commented 3 years ago

of course, here the file pws_48_mass_transfer.txt