PotentialMrcaProcessedGraph#
- class potential_mrca_processed_graph.PotentialMrcaProcessedGraph(initialize_ancestor_maps=True, *args, **kwargs)#
Bases:
PloidPedigree
This class represents a preprocessed pedigree graph. Apart from having the usual parents and children mappings, it also contains the following information about the pedigree:
1) The assignments of every vertex to its level. The vertex level is defined to be the length of longest path from a proband vertex to the vertex being considered.
2) A dictionary of dictionaries (a matrix) that maps a vertex u to a dictionary whose keys the u’s ancestors and the values are the “access vertices” through which u can reach the particular ancestor.
- __init__(initialize_ancestor_maps=True, *args, **kwargs)#
Initialize a graph with edges, name, or graph attributes.
Parameters#
- incoming_graph_datainput graph (optional, default: None)
Data to initialize graph. If None (default) an empty graph is created. The data can be an edge list, or any NetworkX graph object. If the corresponding optional Python packages are installed the data can also be a 2D NumPy array, a SciPy sparse array, or a PyGraphviz graph.
- attrkeyword arguments, optional (default= no attributes)
Attributes to add to graph as key=value pairs.
See Also#
convert
Examples#
>>> G = nx.Graph() # or DiGraph, MultiGraph, MultiDiGraph, etc >>> G = nx.Graph(name="my graph") >>> e = [(1, 2), (2, 3), (3, 4)] # list of edges >>> G = nx.Graph(e)
Arbitrary graph attribute pairs (key=value) may be assigned
>>> G = nx.Graph(e, day="Friday") >>> G.graph {'day': 'Friday'}
- classmethod from_pedigree(pedigree, initialize_ancestor_maps=True)#
- get_minimal_path_length(descendant, ancestor)#
- Return type:
int
- static get_processed_graph_from_file(filepath, missing_parent_notation=None, separation_symbol=' ', preprocess_graph=True, probands=None, skip_first_line=False)#
Parses the pedigree file and builds the graph.
- Parameters:
filepath (
str
|Path
) – The path to the pedigree file.missing_parent_notation – String representing an unspecified parent.
separation_symbol – The sting used to separate columns in the input file.
preprocess_graph (
bool
) – Specifies whether the graph should be preprocessed for the alignment algorithm.probands ([<class ‘int’>]) – If specified, the parsed graph is reduced to the ascending genealogy of the specified probands.
skip_first_line (
bool
) – Specifies whether the first line should be skipped.
Returns:
- get_vertex_ancestors(vertex)#
Returns the vertex’s ancestors.
- Parameters:
vertex (int) – The vertex for which the ancestors should be returned.
- initialize_potential_mrca_map()#
This method preprocesses the pedigree and stores the so called “access-to-ancestor” matrix which is used during the alignment process. This matrix maps a pair (descendant, ancestor) to the list of the ancestor’s children vertices through which the descendant can reach the ancestor.