Durenlab / LINGER

73 stars 14 forks source link

error in LINGER_tr.training #40

Open feanaros opened 2 months ago

feanaros commented 2 months ago
Selection deleted
import LingerGRN.LINGER_tr as LINGER_tr
activef='ReLU' # active function chose from 'ReLU','sigmoid','tanh'
LINGER_tr.training(GRNdir,method,outdir,activef)

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[33], line 3
      1 import LingerGRN.LINGER_tr as LINGER_tr
      2 activef='ReLU' # active function chose from 'ReLU','sigmoid','tanh'
----> 3 LINGER_tr.training(GRNdir,method,outdir,activef)

TypeError: training() missing 1 required positional argument: 'species'

Hello, I was following the tutorial for other species -> Mus musculus. I tried to solve by myself the error setting the species:

import LingerGRN.LINGER_tr as LINGER_tr
activef='ReLU' # active function chose from 'ReLU','sigmoid','tanh'
species='Mus_musculus'
LINGER_tr.training(GRNdir,method,outdir,activef,species)

But there is a new error that I don't understand.

 0%|                                                    | 0/21 [00:00<?, ?it/s]

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
Cell In[34], line 4
      2 activef='ReLU' # active function chose from 'ReLU','sigmoid','tanh'
      3 species='Mus_musculus'
----> 4 LINGER_tr.training(GRNdir,method,outdir,activef,species)

File ~/anaconda3/envs/LINGER/lib/python3.10/site-packages/LingerGRN/LINGER_tr.py:460, in training(GRNdir, method, outdir, activef, species)
    458 #res = Parallel(n_jobs=n_jobs)(delayed(sc_nn_NN)(ii,RE_TGlink_temp,Target,netall,Exp,Opn,l1_lambda,activef)  for ii in tqdm(range(RE_TGlink.shape[0]))
    459 RE_TGlink_temp=RE_TGlink1.values[ii,:]
--> 460 res=sc_nn_NN(ii,RE_TGlink_temp,Target,Exp,Opn,l1_lambda,activef)
    461 warnings.resetwarnings()
    462 netall_s[ii]=res[0]

File ~/anaconda3/envs/LINGER/lib/python3.10/site-packages/LingerGRN/LINGER_tr.py:271, in sc_nn_NN(ii, RE_TGlink_temp, Target, Exp, Opn, l1_lambda, activef)
    269 else:
    270     TFtemp=Exp.values
--> 271 REtemp=Opn.loc[RE_TGlink_temp[1]].values
    272 inputs=np.vstack((TFtemp, REtemp))
    273 targets = torch.tensor(Target.loc[RE_TGlink_temp[0],:])

File ~/anaconda3/envs/LINGER/lib/python3.10/site-packages/pandas/core/indexing.py:1103, in _LocationIndexer.__getitem__(self, key)
   1100 axis = self.axis or 0
   1102 maybe_callable = com.apply_if_callable(key, self.obj)
-> 1103 return self._getitem_axis(maybe_callable, axis=axis)

File ~/anaconda3/envs/LINGER/lib/python3.10/site-packages/pandas/core/indexing.py:1332, in _LocIndexer._getitem_axis(self, key, axis)
   1329     if hasattr(key, "ndim") and key.ndim > 1:
   1330         raise ValueError("Cannot index with multidimensional key")
-> 1332     return self._getitem_iterable(key, axis=axis)
   1334 # nested tuple slicing
   1335 if is_nested_tuple(key, labels):

File ~/anaconda3/envs/LINGER/lib/python3.10/site-packages/pandas/core/indexing.py:1272, in _LocIndexer._getitem_iterable(self, key, axis)
   1269 self._validate_key(key, axis)
   1271 # A collection of keys
-> 1272 keyarr, indexer = self._get_listlike_indexer(key, axis)
   1273 return self.obj._reindex_with_indexers(
   1274     {axis: [keyarr, indexer]}, copy=True, allow_dups=True
   1275 )

File ~/anaconda3/envs/LINGER/lib/python3.10/site-packages/pandas/core/indexing.py:1462, in _LocIndexer._get_listlike_indexer(self, key, axis)
   1459 ax = self.obj._get_axis(axis)
   1460 axis_name = self.obj._get_axis_name(axis)
-> 1462 keyarr, indexer = ax._get_indexer_strict(key, axis_name)
   1464 return keyarr, indexer

File ~/anaconda3/envs/LINGER/lib/python3.10/site-packages/pandas/core/indexes/base.py:5877, in Index._get_indexer_strict(self, key, axis_name)
   5874 else:
   5875     keyarr, indexer, new_indexer = self._reindex_non_unique(keyarr)
-> 5877 self._raise_if_missing(keyarr, indexer, axis_name)
   5879 keyarr = self.take(indexer)
   5880 if isinstance(key, Index):
   5881     # GH 42790 - Preserve name from an Index

File ~/anaconda3/envs/LINGER/lib/python3.10/site-packages/pandas/core/indexes/base.py:5938, in Index._raise_if_missing(self, key, indexer, axis_name)
   5936     if use_interval_msg:
   5937         key = list(key)
-> 5938     raise KeyError(f"None of [{key}] are in the [{axis_name}]")
   5940 not_found = list(ensure_index(key)[missing_mask.nonzero()[0]].unique())
   5941 raise KeyError(f"{not_found} not in index")

KeyError: "None of [Index(['chr15:98475090-98475953', 'chr15:98504191-98505090',\n       'chr15:98510251-98511131', 'chr15:98512688-98513592',\n       'chr15:98517138-98518032', 'chr15:98533784-98534664',\n       'chr15:98567357-98568241', 'chr15:98579835-98580734',\n       'chr15:98585262-98586164', 'chr15:98602202-98603131',\n       'chr15:98607266-98608091', 'chr15:98608982-98609899',\n       'chr15:98616907-98617781', 'chr15:98628476-98629388',\n       'chr15:98631357-98632081', 'chr15:98632199-98632486',\n       'chr15:98634384-98635289', 'chr15:98639894-98640687',\n       'chr15:98656776-98657698', 'chr15:98662449-98663311',\n       'chr15:98664107-98664848', 'chr15:98677036-98677912',\n       'chr15:98682904-98683802', 'chr15:98688423-98689309',\n       'chr15:98691146-98691939', 'chr15:98692089-98692811',\n       'chr15:98699219-98700100', 'chr15:98707740-98708643',\n       'chr15:98710171-98711066', 'chr15:98723449-98724271',\n       'chr15:98727541-98728357', 'chr15:98737710-98738468',\n       'chr15:98738599-98739344', 'chr15:98744591-98745520',\n       'chr15:98755297-98756176', 'chr15:98761924-98762665',\n       'chr15:98762797-98763603', 'chr15:98772256-98773152',\n       'chr15:98776151-98777005', 'chr15:98780343-98781155',\n       'chr15:98787663-98788475', 'chr15:98789337-98790265',\n       'chr15:98793261-98793719', 'chr15:98796136-98796959',\n       'chr15:98797653-98798512', 'chr15:98799185-98800054',\n       'chr15:98803820-98804614', 'chr15:98805140-98805968',\n       'chr15:98807772-98808583', 'chr15:98821140-98821934',\n       'chr15:98831004-98831841'],\n      dtype='object')] are in the [index]"

any help is very appreciated

zoezzy0125 commented 3 weeks ago

I meet the same problems here. Does anyone solve it?