aprile.utils module

aprile.utils.args_parse_pred(drug_index_1, drug_index_2, side_effect_index, n_drug, n_side_effect)
Parameters
  • drug_index_1 – char ‘*’ or string of the format list of int, like 2,3,4

  • drug_index_2 – char ‘*’ or string of the format list of int

  • side_effect_index – char ‘*’ or string of the format list of int

Returns

three lists of int

aprile.utils.args_parse_train(drug_index_1, drug_index_2, side_effect_index, rg, et, idx)
Parameters
  • drug_index_1 – char ‘*’ or string of the format list of int, like 2,3,4

  • drug_index_2 – char ‘*’ or string of the format list of int

  • side_effect_index – char ‘*’ or string of the format list of int

  • rg – int tensor of shape (n_side_effect, 2)

  • et – int tensor of shape (n_dd_edge)

  • idx – int tensor of shape (2, n_dd_edge)

Returns

three lists of int

aprile.utils.auprc_auroc_ap(target_tensor, score_tensor)
aprile.utils.dense_id(n)
aprile.utils.dict_ep_to_nparray(out_dict, epoch)
aprile.utils.get_edge_index_from_coo(mat, bidirection)
aprile.utils.get_indices_mask(indices, in_indices)
aprile.utils.get_range_list(edge_list)
aprile.utils.negative_sampling(pos_edge_index, num_nodes)
aprile.utils.normalize(input)
aprile.utils.process_edges(raw_edge_list, p=0.9)
aprile.utils.remove_bidirection(edge_index, edge_type)
aprile.utils.sparse_id(n)
aprile.utils.to_bidirection(edge_index, edge_type=None)
aprile.utils.typed_negative_sampling(pos_edge_index, num_nodes, range_list)
aprile.utils.uniform(size, tensor)
aprile.utils.visualize_graph(pp_idx, pp_weight, pd_idx, pd_weight, d1, d2, out_path, protein_name_dict=None, drug_name_dict=None, hiden=True, size=(40, 40))
visualize Aprile-Exp’s outputs
  1. use different color for pp and pd edges

  2. annotate the weight of each edge near the edge (or annotate with the tranparentness of edges for each edge)

  3. annotate the name of each node near the node, if name_dict=None, then annotate with node’s index

Parameters
  • pp_idx (torch.Tensor) – integer tensor (2, n_pp_edges)

  • pp_weight (torch.Tensor) – float tensor (1, n_pp_edges), values with (0, 1)

  • pd_idx (torch.Tensor) – integer tensor (2, n_pd_edges)

  • pd_weight (torch.Tensor) – float tensor (1, n_pd_edges), values with (0, 1)

  • d1 (list) – drug list

  • d2 (list) – drug list pairing with d1

  • out_path (str) – output path

  • protein_name_dict (dict, optional) – the mapping for protein makers’ text. Defaults to None.

  • drug_name_dict (dict, optional) – the mapping for drug markers’ text. Defaults to None.

  • hiden (bool, optional) – if show related edge with edge weight of 0.01. Defaults to True.

  • size (tuple, optional) – the figure size. Defaults to (40, 40).

Returns

the graph object matplotlib.pyplot.figure: the ploted figure

Return type

networkx.Graph