Multi-Dendrix Logo

This Page

multi_dendrix.permute.mutation_data.graph_to_mutation_data

multi_dendrix.permute.mutation_data.graph_to_mutation_data(H, genes, patients)[source]

Converts a bipartite NetworkX graph representing mutations in genes in different patients into the mutation data format used by Multi-Dendrix.

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

Parameters:
  • H (NetworkX graph) – Bipartite graph H(V, E) representation of mutation data. Vertices are genes and patients, and edges connect genes mutated in particular patients.
  • genes (list) – genes in the mutation data.
  • patients (list) – patients in the mutation data.
Returns:

Mutation data tuple in the same format as multi_dendrix.load_mutation_data().

Examples:
A view of example input:
>>> import networkx as nx
>>> H = nx.Graph()
>>> H.add_edges_from([("G1", "TCGA-01"), ("G1", "TCGA-02"), ("G1", "TCGA-03"),
                  ("G2", "TCGA-02")])
>>> nx.draw_spectral(H)
../../_images/mutation_graph.png
Converting the graph into Multi-Dendrix mutation data format:
>>> graph_to_mutation_data(H, ["G1", "G2"], ["TCGA-01", "TCGA-02", "TCGA-03"])
>>> (2, 3, ['G2', 'G1'], ['TCGA-03', 'TCGA-02', 'TCGA-01'],
        {'G2': set(['TCGA-02']), 'G1': set(['TCGA-03', 'TCGA-02', 'TCGA-01'])},
        {'TCGA-03': set(['G1']), 'TCGA-02': set(['G2', 'G1']), 'TCGA-01': set(['G1'])})

See also: permute_mutation_data(), construct_mutation_graph().