XingyanLiu/CAME

Error when plotting (pipeline.main_for_unaligned)

abigailelliot26 opened this issue · 1 comments

Hi, after battling through the process of installing and re-installing old versions of dependencies I am hitting up against a new error that hasn't been reported before. I'm using the test data. The epochs run successfully! But then I get this problem with plotting the second figure:

figure has been saved into:
_temp/('Baron_human', 'Baron_mouse')-(08-31 18.53.59)/figs/cluster_index.png
states loaded from: _temp/('Baron_human', 'Baron_mouse')-(08-31 18.53.59)/_models/weights_epoch231.pt
object saved into:
_temp/('Baron_human', 'Baron_mouse')-(08-31 18.53.59)/datapair_init.pickle
WARNING:root:An error occurred when plotting results: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Help would be much appreciated! Really keen to use this tool.

Hi, I recently encountered the same error and another error came up when I plotting the Abstracted graph:

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
Cell In[43], line 10
      7 var_labels1, var_labels2 = gadt1.obs[groupby_var], gadt2.obs[groupby_var]
      9 sp1, sp2 = 'human', 'mouse'
---> 10 g = came.make_abstracted_graph(
     11     obs_labels1, obs_labels2,
     12     var_labels1, var_labels2,
     13     avg_expr1, avg_expr2,
     14     df_var_links,
     15     tags_obs=(f'{sp1} ', f'{sp2} '),
     16     tags_var=(f'{sp1} module ', f'{sp2} module '),
     17     cut_ov=cut_ov,
     18     norm_mtd_ov=norm_ov,
     19 )

File ~/miniconda3/envs/came/lib/python3.8/site-packages/came/utils/analyze.py:1141, in make_abstracted_graph(obs_labels1, obs_labels2, var_labels1, var_labels2, avg_expr1, avg_expr2, df_var_links, tags_obs, tags_var, key_weight, cut_ov, norm_mtd_ov, ov_norm_first, global_adjust_ov, global_adjust_vv, vargroup_filtered, **kwds)
   1131 var_labels1, var_labels2, avg_expr1, avg_expr2, df_var_links = \
   1132     _filter_for_abstract(
   1133         var_labels1, var_labels2, avg_expr1, avg_expr2, df_var_links,
   1134         name=vargroup_filtered)
   1135 #    obs_group_order1 = _unique_cats(obs_labels1, obs_group_order1)
   1136 #    obs_group_order2 = _unique_cats(obs_labels2, obs_group_order2)
   1137 # var_group_order1 = _unique_cats(var_labels1, var_group_order1)
   1138 # var_group_order2 = _unique_cats(var_labels2, var_group_order2)
   1139 # print('--->', var_group_order1)
   1140 # obs-var edge abstraction #
-> 1141 edges_ov1, avg_vo1 = abstract_ov_edges(
   1142     avg_expr1, var_labels1,
   1143     norm_method=norm_mtd_ov,
   1144     cut=cut_ov,
   1145     tag_var=tag_var1, tag_obs=tag_obs1,
   1146     norm_first=ov_norm_first,
   1147     global_adjust=global_adjust_ov,
   1148     return_full_adj=True)
   1149 edges_ov2, avg_vo2 = abstract_ov_edges(
   1150     avg_expr2, var_labels2,
   1151     norm_method=norm_mtd_ov,
   (...)
   1155     global_adjust=global_adjust_ov,
   1156     return_full_adj=True)
   1157 # print('---> avg_vo1\n', avg_vo1)
   1158 # var-weights abstraction #

File ~/miniconda3/envs/came/lib/python3.8/site-packages/came/utils/analyze.py:1398, in abstract_ov_edges(avg_expr, var_labels, norm_method, norm_axis, tag_var, tag_obs, cut, norm_first, global_adjust, return_full_adj)
   1396 # averaged by varible-groups
   1397 groupby_var = '__temp_labels__'
-> 1398 df[groupby_var] = var_labels
   1399 df_avg = df.groupby(groupby_var).mean()
   1400 df_avg.dropna(inplace=True)

IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices

The following is the version of the packages I use:

CentOS Linux 7 , python 3.8
numpy                     1.23.2                   
numpy-base                1.23.3             
pandas                    1.4.3 
scanpy                    1.9.1 
scikit-learn              1.1.2 
scipy                     1.9.1  
dgl                     0.9.0 (<1.0.0)
torch                 1.12.1