Multi-Dendrix Logo

This Page

multi_dendrix.permute.mutation_data.permute_mutation_data

multi_dendrix.permute.mutation_data.permute_mutation_data(G, genes, patients, Q=100)[source]

Permutes the given mutation data stored in bipartite graph G=(V, E) by performing | E | * Q edge swaps.

Parameters:
  • G (NetworkX Graph) – Bipartite graph G=(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.
  • Q (int) – constant multiplier for number Q * | E | of edge swaps to perform (default and suggested value: 100). See Milo et al. (2003) for details on choosing Q.
Returns:

Permuted version of G reformatted into the mutation data format used by Multi-Dendrix (see graph_to_mutation_data() and multi_dendrix.load_mutation_data()).

Examples:
A view of example input:
>>> import networkx as nx
>>> G = nx.Graph()
>>> G.add_edges_from([("G1", "TCGA-01"), ("G1", "TCGA-02"), ("G1", "TCGA-03"),
    ("G2", "TCGA-02"), ("G3", "TCGA-01"), ("G3", "TCGA-02"), ("G4", "TCGA-03")])
>>> nx.draw_spectral(G, dpi=72, node_size=125, font_size=8)
../../_images/permute_mutation_data_before.png
Permute the mutation data:
>>> M = permute_mutation_data(G, ["G1", "G2", "G3", "G4"], ["TCGA-01", "TCGA-02", "TCGA-03"])
>>> M
(4, 3, ['G4', 'G3', 'G2', 'G1'], ['TCGA-03', 'TCGA-02', 'TCGA-01'],
    {'G4': set(['TCGA-02']), 'G3': set(['TCGA-02', 'TCGA-01']), 'G2': set(['TCGA-03']),
    'G1': set(['TCGA-03', 'TCGA-02', 'TCGA-01'])},
    {'TCGA-03': set(['G2', 'G1']), 'TCGA-02': set(['G4', 'G3', 'G1']),
    'TCGA-01': set(['G3', 'G1'])})
>>> H = construct_mutation_graph(M[-1], M[-2])
>>> nx.draw_spectral(H, dpi=72, node_size=125, font_size=8)
../../_images/permute_mutation_data_after.png

See also: construct_mutation_graph(), graph_to_mutation_data().