simplicity.tree package

Submodules

simplicity.tree.filtered_infection_tree module

simplicity.tree.json_tree module

Created on Sun Mar 9 13:53:52 2025

@author: pietro

simplicity.tree.json_tree.deserialize(data, parent=None)[source]
simplicity.tree.json_tree.get_node_attributes(node)[source]

Extract all JSON-serializable attributes from an anytree Node, printing warnings for user-defined non-serializable ones.

simplicity.tree.json_tree.import_tree(json_tree_filepath)[source]

Import a tree from JSON and reconstruct the hierarchy with attributes.

simplicity.tree.json_tree.serialize(node)[source]
simplicity.tree.json_tree.write_json_tree_file(root, json_tree_filepath)[source]

simplicity.tree.newick module

Created on Tue Jan 18 19:57:13 2022

@author: pietro

simplicity.tree.newick.export_newick(root)[source]
simplicity.tree.newick.get_newick_str_from_root(node_to_children) str[source]

Generate newick string from python AnyTree tree.

simplicity.tree.newick.write_newick_file(root, newick_filepath)[source]

simplicity.tree.nexus module

Created on Wed Jan 19 01:35:14 2022

@author: pietro

simplicity.tree.nexus.write_nexus_file(tree, nexus_filepath)[source]

Generate NEXUS file from AnyTree tree, including branch lengths in time units and time_emergence annotations

simplicity.tree.tree_builder module

Created on Thu Jan 16 09:51:20 2025

@author: pietro

simplicity.tree.tree_builder.build_ete_from_anytree(any_node)[source]
simplicity.tree.tree_builder.create_infection_node(row, parent_node)[source]

Creates a new infection node as a child of the given parent node.

simplicity.tree.tree_builder.extend_parent_node(parent_node)[source]

Creates a duplicate of the parent node as a leaf child to prolong the branch.

simplicity.tree.tree_builder.get_tree(experiment_name, seeded_simulation_output_dir, tree_type, tree_subtype='binary', coloring='lineage', save_plot=True, export_filetype='json', dashplot=False)[source]

Build the infection tree or the phylogenetic tree of the simulation.

Parameters:
  • tree_type (str) – ‘infection’ or ‘phylogenetic’. Selects the type of tree to render.

  • tree_subtype (str)

  • TREE___________________________ (__________________________FOR INFECTION)

  • infection (binary - binary infection tree where each internal node is an) – event that has as offspring the newly infected individual and the parent that can continue to infect more individuals;

  • individual (compact - infection tree. Each node is an) – connected with all the people they infected

  • TREE__________________________ (_________________________FOR PHYLOGENETIC)

  • is (binary - binary phylogenetic tree where each internal node) – substitution event happening in the simulation

  • and (compact - lineages tree where each edge connects parent) – offspring lineages

  • ________________________________________________________________________

  • save_plot (bool)

  • export (str) – file type to export tree (newick or nexus). The default is ‘nexus’.

simplicity.tree.tree_builder.infection_tree(seeded_simulation_output_dir)[source]
simplicity.tree.tree_builder.phylogenetic_tree(seeded_simulation_output_dir)[source]

Module contents