MCPcopy Index your code
hub / github.com/InternScience/InternAgent / GeneSimNetwork

Class GeneSimNetwork

tasks/AutoTPPR/code/experiment.py:530–565  ·  view source on GitHub ↗

GeneSimNetwork class Args: edge_list (pd.DataFrame): edge list of the network gene_list (list): list of gene names node_map (dict): dictionary mapping gene names to node indices Attributes: edge_index (torch.Tensor): edge index of the network ed

Source from the content-addressed store, hash-verified

528
529
530class GeneSimNetwork():
531 """
532 GeneSimNetwork class
533
534 Args:
535 edge_list (pd.DataFrame): edge list of the network
536 gene_list (list): list of gene names
537 node_map (dict): dictionary mapping gene names to node indices
538
539 Attributes:
540 edge_index (torch.Tensor): edge index of the network
541 edge_weight (torch.Tensor): edge weight of the network
542 G (nx.DiGraph): networkx graph object
543 """
544 def __init__(self, edge_list, gene_list, node_map):
545 """
546 Initialize GeneSimNetwork class
547 """
548
549 self.edge_list = edge_list
550 self.G = nx.from_pandas_edgelist(self.edge_list, source='source',
551 target='target', edge_attr=['importance'],
552 create_using=nx.DiGraph())
553 self.gene_list = gene_list
554 for n in self.gene_list:
555 if n not in self.G.nodes():
556 self.G.add_node(n)
557
558 edge_index_ = [(node_map[e[0]], node_map[e[1]]) for e in
559 self.G.edges]
560 self.edge_index = torch.tensor(edge_index_, dtype=torch.long).T
561 #self.edge_weight = torch.Tensor(self.edge_list['importance'].values)
562
563 edge_attr = nx.get_edge_attributes(self.G, 'importance')
564 importance = np.array([edge_attr[e] for e in self.G.edges])
565 self.edge_weight = torch.Tensor(importance)
566
567def get_GO_edge_list(args):
568 """

Callers 1

model_initializeMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected