PersonalizedPageRankMachine

class PersonalizedPageRankMachine(host, graphname, username, secret, password)[source]

Bases: object

Define a drug-protein graph and compute the Personalized PageRank of nodes.

Methods Summary

connect()

Connect to the host with the authentication details.

get_personalized_pagerank(node_ids[, …])

Compute the pruned Personalized PageRank for a list of nodes.

install_query([url])

Install a query on the host.

personalized_pagerank(node_id[, node_type, …])

Compute the pagerank for a specific node.

upload_graph(new_graph, edges)

Uploadthe edges from a dataframe using the PyTigerGraph connection.

Methods Documentation

connect()[source]

Connect to the host with the authentication details.

get_personalized_pagerank(node_ids, edge_type='interacts', print_accum=True, damping=0.5, iterations=100, top_k=100)[source]

Compute the pruned Personalized PageRank for a list of nodes.

Parameters
  • node_ids (List) – Identifiers of the nodes of interest.

  • edge_type (str) – Type of the node.

  • print_accum (bool) – Accumulation flag.

  • damping (float) – Non return probability.

  • iterations (int) – Number of steps per walk.

  • top_k (int) – Number of closest neighbors to return for the query.

Return type

DataFrame

Returns

A table of node pairs with PageRank scores.

install_query(url='https://raw.githubusercontent.com/tigergraph/gsql-graph-algorithms/master/algorithms/Centrality/pagerank/personalized/multi_source/tg_pagerank_pers.gsql')[source]

Install a query on the host.

Parameters

url (str) – A url to the query string.

personalized_pagerank(node_id, node_type='drug', edge_type='interacts', print_accum=True, damping=0.85, iterations=20, top_k=40)[source]

Compute the pagerank for a specific node.

Parameters
  • node_id – Identifier of the node of interest.

  • node_type – Type of the node.

  • edge_type – Type of the edge.

  • print_accum – Accumulation flag.

  • damping – Non return probability.

  • iterations – Number of steps per walk.

  • top_k – Number of closest neighbors to return for the query.

Returns

Personalized PageRank nodes for a specific node in the Graph.

upload_graph(new_graph, edges)[source]

Uploadthe edges from a dataframe using the PyTigerGraph connection.

Parameters
  • new_graph (bool) – Decision about deleting the existing nodes in the graph.

  • edges (DataFrame) – The dataframe with the edges between drugs and proteins.