LineageTree properties¶
The core properties of a LineageTree. The user may access them by lT.property.
LineageTree properties¶
lineagetree._core
¶
Functions:
| Name | Description |
|---|---|
t_b |
The first timepoint of the lineage tree |
t_e |
The last timepoint of the lineage tree |
nodes |
Set of node ids of the lineage tree |
number_of_nodes |
Number of nodes in the lineage tree |
depth |
The depth of each node in the lineage tree |
roots |
Set of roots of the lineage tree |
leaves |
Set of leaves of the lineage tree |
edges |
Set of edges of the lineage tree |
all_chains |
List of all chains in the tree, ordered in depth-first search. |
time_nodes |
Dictionary that maps a time to the set of nodes at that time. |
Attributes:
| Name | Type | Description |
|---|---|---|
successor |
MappingProxyType[int, tuple[int]]
|
Dictionary that maps a node to its successors |
predecessor |
MappingProxyType[int, tuple[int]]
|
Dictionary that maps a node to its predecessors |
time |
MappingProxyType[int, int]
|
Dictionary that maps a node to its time |
labels |
dict[int, str]
|
Dictionary that maps a node to its label |
time_resolution |
float
|
Time resolution of the lineage tree |
parenting |
|
successor
property
¶
Dictionary that maps a node to its successors
predecessor
property
¶
Dictionary that maps a node to its predecessors
t_b
¶
t_e
¶
nodes
¶
number_of_nodes
¶
depth
¶
The depth of each node in the lineage tree
Source code in src/lineagetree/_core/_properties.py
roots
¶
leaves
¶
edges
¶
all_chains
¶
List of all chains in the tree, ordered in depth-first search.
time_nodes
¶
Dictionary that maps a time to the set of nodes at that time.
Source code in src/lineagetree/_core/_properties.py
LineageTree navigation functions¶
Functions to access different data that is available in LineageTree.
lineagetree._core
¶
Functions:
| Name | Description |
|---|---|
change_labels |
Change the dictionary that serves at labels with |
find_leaves |
Finds the leaves of a tree spawned by one or more nodes. |
get_all_chains_of_subtree |
Computes all the chains of the subtree spawn by a given node. |
get_ancestor_at_t |
Find the id of the ancestor of a give node |
get_ancestor_with_attribute |
General purpose function to help with searching the first ancestor that has an attribute. |
get_available_labels |
Returns the list all the available label dictionaries |
get_chain_of_node |
Computes the predecessors and successors of the node |
get_labelled_ancestor |
Finds the first labelled ancestor and returns its ID otherwise returns -1 |
get_predecessors |
Computes the predecessors of the node |
get_subtree_nodes |
Computes the list of nodes from the subtree spawned by x |
get_successors |
Computes the successors of the node |
nodes_at_t |
Returns the list of nodes at time |
change_labels
¶
change_labels(
lT: LineageTree,
new_labels_name: str | None = None,
new_labels_dict: dict[int, str] | None = None,
only_first_node_in_chain: bool = False,
) -> None
Change the dictionary that serves at labels with
the LineageTree attribute new_labels_name.
It has to be a dictionary mapping node id to string.
If new_labels_dict is provided, it will be used to
label the cells.
If new_labels_name is not specified, the labels are reset.
One can decide to only label the first node of the chain instead of all the nodes of the chain. That can help readability in the napari plugin reLAX.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
LineageTree
|
|
required |
|
string
|
The name of the dictionary to use
(the list of potential dictionaries can be found
with |
None
|
|
dictionary mapping integers to strings
|
The new names as a dictionary mapping each named node id to its string label
If not provided and lT has a fitting attribute named |
None
|
|
bool
|
If |
True
|
Source code in src/lineagetree/_core/_navigation.py
find_leaves
¶
Finds the leaves of a tree spawned by one or more nodes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
LineageTree
|
The LineageTree instance. |
required |
|
int or Iterable
|
The roots of the trees spawning the leaves |
required |
Returns:
| Type | Description |
|---|---|
set
|
The leaves of one or more trees. |
Source code in src/lineagetree/_core/_navigation.py
get_all_chains_of_subtree
¶
get_all_chains_of_subtree(
lT: LineageTree, node: int, end_time: int | None = None
) -> list[list[int]]
Computes all the chains of the subtree spawn by a given node. Similar to get_all_chains().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
LineageTree
|
The LineageTree instance. |
required |
|
int
|
The node from which we want to get its chains. |
required |
|
int
|
The time at which we want to stop the chains. |
None
|
Returns:
| Type | Description |
|---|---|
list of list of int
|
list of chains |
Source code in src/lineagetree/_core/_navigation.py
get_ancestor_at_t
¶
Find the id of the ancestor of a give node n
at a given time time.
If there is no ancestor, returns None
If time is None return the root of the subtree that spawns
the node n.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
LineageTree
|
The LineageTree instance. |
required |
|
int
|
node for which to look the ancestor |
required |
|
int
|
time at which the ancestor has to be found.
If |
None
|
Returns:
| Type | Description |
|---|---|
int
|
the id of the ancestor at time |
Source code in src/lineagetree/_core/_navigation.py
get_ancestor_with_attribute
¶
General purpose function to help with searching the first ancestor that has an attribute. Similar to get_labeled_ancestor and may make it redundant.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
LineageTree
|
The LineageTree instance. |
required |
|
int
|
The id of the node |
required |
Returns:
| Type | Description |
|---|---|
int
|
Returns the first ancestor found that has an attribute otherwise |
Source code in src/lineagetree/_core/_navigation.py
get_available_labels
¶
Returns the list all the available label dictionaries
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
LineageTree
|
The LineageTree instance. |
required |
Returns:
| Type | Description |
|---|---|
list of string
|
list of the names of all the available properties to label the nodes |
Source code in src/lineagetree/_core/_navigation.py
get_chain_of_node
¶
get_chain_of_node(
lT: LineageTree,
x: int,
depth: int | None = None,
depth_pred: int | None = None,
depth_succ: int | None = None,
end_time: int | None = None,
) -> list[int]
Computes the predecessors and successors of the node x up to
depth_pred predecessors plus depth_succ successors.
If the value depth is provided and not None,
depth_pred and depth_succ are overwriten by depth.
The ordered list of ids is returned.
If all depth are None, the full chain is returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
LineageTree
|
The LineageTree instance. |
required |
|
int
|
id of the node to compute |
required |
|
int
|
maximum number of predecessors and successor to return |
None
|
|
int
|
maximum number of predecessors to return |
None
|
|
int
|
maximum number of successors to return |
None
|
Returns:
| Type | Description |
|---|---|
list of int
|
list of node ids |
Source code in src/lineagetree/_core/_navigation.py
get_labelled_ancestor
¶
Finds the first labelled ancestor and returns its ID otherwise returns -1
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
LineageTree
|
The LineageTree instance. |
required |
|
int
|
The id of the node |
required |
Returns:
| Type | Description |
|---|---|
int
|
Returns the first ancestor found that has a label otherwise |
Source code in src/lineagetree/_core/_navigation.py
get_predecessors
¶
get_predecessors(
lT: LineageTree,
x: int,
depth: int | None = None,
start_time: int | None = None,
end_time: int | None = None,
) -> list[int]
Computes the predecessors of the node x up to
depth predecessors or the begining of the life of x.
The ordered list of ids is returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
LineageTree
|
The LineageTree instance. |
required |
|
int
|
id of the node to compute |
required |
|
int
|
maximum number of predecessors to return |
None
|
|
int
|
maximum time to consider, if not provided the beginning of the life of |
None
|
|
int
|
maximum time to consider, if not provided the end of the life of |
None
|
Returns:
| Type | Description |
|---|---|
list of int
|
list of ids, the last id is |
Source code in src/lineagetree/_core/_navigation.py
get_subtree_nodes
¶
get_subtree_nodes(
lT: LineageTree,
x: int | Iterable,
end_time: int | None = None,
preorder: bool = False,
) -> list[int]
Computes the list of nodes from the subtree spawned by x
The default output order is Breadth First Traversal.
Unless preorder is True in that case the order is
Depth First Traversal (DFT) preordered.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
LineageTree
|
The LineageTree instance. |
required |
|
int
|
id of root node |
required |
|
bool
|
if True the output preorder is Depth First Traversal (DFT) Otherwise it is Breadth First Traversal (BFT) |
False
|
Returns:
| Type | Description |
|---|---|
list of int
|
the ordered list of node ids |
Source code in src/lineagetree/_core/_navigation.py
get_successors
¶
get_successors(
lT: LineageTree,
x: int,
depth: int | None = None,
end_time: int | None = None,
) -> list[int]
Computes the successors of the node x up to
depth successors or the end of the life of x.
The ordered list of ids is returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
LineageTree
|
The LineageTree instance. |
required |
|
int
|
id of the node to compute |
required |
|
int
|
maximum number of predecessors to return |
None
|
|
int
|
maximum time to consider |
None
|
Returns:
| Type | Description |
|---|---|
list of int
|
list of ids, the first id is |
Source code in src/lineagetree/_core/_navigation.py
nodes_at_t
¶
Returns the list of nodes at time t that are spawn by the node(s) r.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
LineageTree
|
The LineageTree instance. |
required |
|
int
|
target time, if |
required |
|
int or Iterable of int
|
id or list of ids of the spawning node |
required |
Returns:
| Type | Description |
|---|---|
list of int
|
list of ids of the nodes at time |