Hi Kayson and Patricia,
I am also looking to extract the TE values for my research. I've gone ahead and implemented this functionality in the results.py file:
Line 637: def get_adjacency_matrix(self, weights, fdr=True, weight_type=int): # Added weight_type arg. with 'int' default. When you call this function you can specify weight_type = float for the TE values.
Line 668: adjacency_matrix = AdjacencyMatrix(self.data_properties.n_nodes, weight_type) # Added weight_type
After the elseif weights == 'binary' branch, add the following (sorry about the formatting here):
elif weights == 'te':
for t in self.targets_analysed:
single_result = self.get_single_target(target=t, fdr=fdr)
sources = np.zeros(
len(single_result.selected_vars_sources), dtype=int)
weights = np.zeros(
len(single_result.selected_vars_sources), dtype=weight_type) # Added weight_type
if single_result.selected_vars_sources is not None: # Checks if selected sources is none
sorted_sources = sorted(single_result.selected_vars_sources) # Sorts selected sources to match with 'te' array order
for i, s in enumerate(sorted_sources):
sources[i] = s[0]
if single_result.te is not None:
for i, s in enumerate(single_result.te):
weights[i] = s
adjacency_matrix.add_edge_list(
sources, np.ones(len(sources), dtype=int) * t, weights)
Then,
weights = 'te'
adj_matrix = result.get_adjacency_matrix(weights=weights, fdr=False, weight_type=float)
Would sending a push request be the best approach to incorporate this? If not, happy for this code to be integrated on your end.
Kind regards,
Jules