The pyp_network Module

pyp_network contains a set of procedures for working with pedigrees as directed graphs.

Module Contents

count_offspring(pedgraph, anid) ⇒ integer [#]

immediate_family() returns the number of offspring of an animal.

pedgraph
An instance of a networkx DiGraph.
anid
The animal for whom offspring are to be counted.
Returns:
Count of offspring.

find_ancestors(pedgraph, anid, _ancestors=[]) ⇒ list [#]

find_ancestors() identifies the ancestors of an animal and returns them in a list.

pedgraph
An instance of a networkx DiGraph.
anid
The animal for whom ancestors are to be found.
_ancestors
The list of ancestors already found.
Returns:
List of ancestors of anid.

find_descendants(pedgraph, anid, _descendants=[]) ⇒ list [#]

find_descendants() identifies the descendants of an animal and returns them in a list.

pedgraph
An instance of a networkx DiGraph.
anid
The animal for whom descendants are to be found.
_descendants
The list of descendants already found.
Returns:
List of descendants of anid.

get_founder_descendants(pedgraph) ⇒ dictionary [#]

get_founder_descendants() returns a dictionary containing a list of descendants of each founder in the pedigree.

pedgraph
An instance of a NetworkX DiGraph.
Returns:
A dictionary containing a list of descendants for each founder in the graph.

immediate_family(pedgraph, anid) ⇒ list [#]

immediate_family() returns parents and offspring of an animal.

pedgraph
An instance of a networkx DiGraph.
anid
The animal for whom immediate family are to be found.
Returns:
List of immediate family members of anid.

most_influential_offspring(pedgraph, anid, resolve='all') ⇒ dictionary [#]

most_influential_offspring() returns the most influential offspring of an animal as measured by their number of offspring.

pedgraph
An instance of a networkx DiGraph.
anid
The animal for whom the most influential offspring is to be found.
resolve
Indicates how ties should be handled ('first'|'last'|'all').
Returns:
The most influential offspring of anid.

offspring_influence(pedgraph, anid) ⇒ dictionary [#]

offspring_influence() returns the number of grand-children by each child of a given animal.

pedgraph
An instance of a networkx DiGraph.
anid
The animal for whom grand-progeny are to be counted.
Returns:
A dictionary of counts of progeny per child.

ped_to_graph(pedobj, oid=0) ⇒ graph [#]

ped_to_graph() Takes a PyPedal pedigree object and returns a networkx XDiGraph object.

pedobj
A PyPedal pedigree object.
oid
Flag indicating if original (1) or renumbered (0) IDs should be used.
Returns:
DiGraph object