Multi-Dendrix Logo

This Page

multi_dendrix.permute.mutation_data.construct_mutation_graph

multi_dendrix.permute.mutation_data.construct_mutation_graph(mutation2patients, patient2mutations)[source]

Converts mutation data stored as dictionaries into a bipartite NetworkX graph.

Parameters:
  • mutation2patients (dictionary) – Mapping of genes to the patients in which they are mutated.
  • patient2mutations (dictionary) – Mapping of patients to the genes they have mutated.

For more information on the internal format of mutation data used by Multi-Dendrix, see multi_dendrix.load_mutation_data().

Returns:Bipartite NetworkX graph G=(V, E) with genes and patients as nodes, and edges representing a mutation in a particular gene in a particular patient.
Examples:
A view of example input:
>>> import networkx as nx
>>> mutation2patients = {"G1" : ["TCGA-01", "TCGA-02", "TCGA-03"], "G2" : ["TCGA-02"]}
>>> patient2mutations = {"TCGA-01" : ["G1"], "TCGA-02" : ["G1", "G2"], "TCGA-03" : ["G1"]}
Simple example of converting mutation data into a bipartite graph:
>>> G = construct_mutation_graph(mutation2patients, patient2mutations)
>>> nx.draw_spectral(G)
../../_images/mutation_graph.png

See also: graph_to_mutation_data(), permute_mutation_data().