fmaschietto / mdigest

GNU General Public License v3.0
29 stars 10 forks source link

KeyError: 'gcc_mi' #6

Open srp106 opened 9 months ago

srp106 commented 9 months ago

Hello, Thanks for developing this program for the analysis of MD TRAJ data.

While plotting the data using the gcc_mi matrix, I was getting the following error. Could you please suggest the fix, if possible?

plots = Plots(dyncorrMUT_load, dyncorrWT_load, matrix_type='gcc_mi', save=rd+'MptpA_ca_mi') plots.load_parameters({ 'fig': plt.subplots(1, 3, figsize=(16,5)), 'labels': ['WT', 'R75D_R88D']}) plots.plot_gcc_per_replica()

plots.load_parameters({ 'fig': plt.subplots(1+1,1, figsize=(13,6))}) plots.plot_eigcent_per_replica()


KeyError Traceback (most recent call last) Cell In[27], line 1 ----> 1 plots = Plots(dyncorrMUT_load, dyncorrWT_load, matrix_type='gcc_mi', save=rd+'MptpA_ca_mi') 2 plots.load_parameters({ 3 'fig': plt.subplots(1, 3, figsize=(16,5)), 4 'labels': ['WT', 'R75D_R88D']}) 5 plots.plot_gcc_per_replica()

File ~/workflow2024/mdigest-master/mdigest/core/plots/plot_correlation.py:56, in Plots.init(self, MDSIMA, MDSIMB, matrix_type, compute_centrality, **kwargs) 52 self.nresidues = MDSIMA.nresidues 54 if matrix_type == 'gcc_mi': 55 self.matrix_A = np.asarray( ---> 56 [d['gcc_mi'] for d in list(OrderedDict(sorted(MDSIMA.gcc_allreplicas.items())).values())]) 57 self.matrix_B = np.asarray( 58 [d['gcc_mi'] for d in list(OrderedDict(sorted(MDSIMB.gcc_allreplicas.items())).values())]) 60 if compute_centrality:

File ~/workflow2024/mdigest-master/mdigest/core/plots/plot_correlation.py:56, in (.0) 52 self.nresidues = MDSIMA.nresidues 54 if matrix_type == 'gcc_mi': 55 self.matrix_A = np.asarray( ---> 56 [d['gcc_mi'] for d in list(OrderedDict(sorted(MDSIMA.gcc_allreplicas.items())).values())]) 57 self.matrix_B = np.asarray( 58 [d['gcc_mi'] for d in list(OrderedDict(sorted(MDSIMB.gcc_allreplicas.items())).values())]) 60 if compute_centrality:

KeyError: 'gcc_mi'

vas2201 commented 9 months ago

I resolve the above issue by defining the matrix type. However, I am getting following error while executing the cell at Save dataframe to visualize interactively (in pymol) WT MptpA networks


IndexError Traceback (most recent call last) Cell In[85], line 16 14 vizcorr.filter_by_distance(matrixtype='gcc_WT', distmat=True) 15 vizcorr.filter_by_distance(matrixtype='dgcc_WT', distmat=True) ---> 16 vizcorr.filter_by_distance(matrixtype='ks_gcc_WT', distmat=True) 17 vizcorr.to_df(normalize=True) 18 df_WT = vizcorr.df

File ~/workflow2024/mdigest-devel/mdigest/core/networkcanvas.py:258, in ProcCorr.filter_by_distance(self, matrixtype, distmat) 256 for i in range(0, len(matrix)): 257 for j in range(i + 1, len(matrix)): --> 258 if ((dist_mat[i, j] < self.lower_thr) or 259 (dist_mat[i, j] >= self.upper_thr)): 260 matrix[i, j] = 0.0 261 matrix[j][i] = 0.0

IndexError: index 195 is out of bounds for axis 1 with size 195

@> setting gcc_WT attribute @> setting dgcc_WT attribute @> setting ks_gcc_WT attribute @>: lower distance threshold is set to 0 @>: upper distance threshold is set to 5.0 @>: loc_factor is set to None @>: inv_loc_factor is set to None Pruning based on distance matrix values @>: filtering correlations corresponding to inter-residue distances lower than 0 Angstrom and @>: higher than 5.0 Angstrom Pruning based on distance matrix values @>: filtering correlations corresponding to inter-residue distances lower than 0 Angstrom and @>: higher than 5.0 Angstrom Pruning based on distance matrix values @>: filtering correlations corresponding to inter-residue distances lower than 0 Angstrom and @>: higher than 5.0 Angstrom dist_WT = np.mean([dyncorrWT_load.distancesallreplicas['rep%s' %i].copy() for i in range(1)], axis=0) gcc_WT = np.mean([dyncorrWT_load.gccallreplicas['rep%s' %i]['gcc_lmi'].copy() for i in range(1)], axis=0) dgcc_WT = np.mean([dyncorrWT_load.dih_gccallreplicas['rep%s' %i]['gcc_lmi'].copy() for i in range(1)], axis=0) ks_gcc_WT = np.mean([dyncorrWT_load.KS_DA_LMI_corrallrep['rep%s' %i]['don_acc'].copy() for i in range(1)], axis=0) matrix_dictionary = {'gcc_WT': gcc_WT, 'dgcc_WT':dgcc_WT, 'ks_gcc_WT': ks_gcc_WT} vizcorr = ProcCorr() vizcorr.source_universe(mdsWT.mda_u) vizcorr.writePDBforframe(0, rd + 'frame0') vizcorr.set_outputparams({'outdir': rd }) vizcorr.load_matrix_dictionary(matrix_dictionary.copy()) vizcorr.populate_attributes(matrix_dictionary.copy())

vizcorr.set_thresholds(prune_upon=np.asarray(dist_WT.copy()), lower_thr=0, upper_thr=5.) vizcorr.filter_by_distance(matrixtype='gcc_WT', distmat=True) vizcorr.filter_by_distance(matrixtype='dgcc_WT', distmat=True) vizcorr.filter_by_distance(matrixtype='ks_gcc_WT', distmat=True) vizcorr.to_df(normalize=True) df_WT = vizcorr.df to_pickle(df_WT, output= rd + 'network_Ptpa_WT_filter_d_0_5.pkl'.format(0,5))

SnehaBheemireddy1 commented 2 months ago

same here