simona provides functions for generating random DAGs. A random tree is first generated, later more links can be randomly added to form a more general DAG.
dag_random_tree()
generates a random tree. By default it generates a binary tree where all leaf terms have depth = 9.
## An ontology_DAG object:
## Source: dag_random_tree
## 1023 terms / 1022 relations / a tree
## Root: 1
## Terms: 1, 10, 100, 1000, ...
## Max depth: 9
## Aspect ratio: 56.89:1
Strictly speaking, tree1
is not random. The tree is growing from the root. In dag_random_tree()
, there are several arguments that can be used for generating random trees.
n_children
: Number of child terms. It can be a single value where each term will the same number of child terms. The value can also be a range, then the number of child terms will be randomly picked in that range.p_stop
: A branch can stop growing based on this probability. On a certain step of the tree growing, let’s denote the set of leaf terms as L
, then, in the next round, floor(length(L)*p_stop)
leaf terms will stop growing, while the remaining leaf terms will continue to grow. If a leaf term continues to grow, it will be linked to n_children
child terms if n_children
is a single value, or pick a number from the range of [n_children[1], n_children[2]]
.The tree growing stops when the number of total terms exceeds max
.
So the default call of dag_random_tree()
is identical to:
We can change these arguments to some other values, such as:
## An ontology_DAG object:
## Source: dag_random_tree
## 1999 terms / 1998 relations / a tree
## Root: 1
## Terms: 1, 10, 100, 1000, ...
## Max depth: 7
## Aspect ratio: 105.71:1
A more general random DAG is generated based on the random tree. Taking tree1
which is already generated, the function dag_add_random_children()
adds more random children to terms in tree1
.
## An ontology_DAG object:
## Source: dag_add_random_children
## 1023 terms / 1115 relations
## Root: 1
## Terms: 1, 10, 100, 1000, ...
## Max depth: 9
## Avg number of parents: 1.09
## Avg number of children: 1.03
## Aspect ratio: 56.89:1 (based on the longest distance from root)
## 52.78:1 (based on the shortest distance from root)