VirtualMicrobes.post_analysis package¶
Submodules¶
VirtualMicrobes.post_analysis.lod module¶
Created on Apr 11, 2015
@author: thocu
-
class
VirtualMicrobes.post_analysis.lod.
LOD
(lod, name, stride, time_interval, lod_range, save_dir=None)[source]¶ Bases:
object
classdocs
-
class
VirtualMicrobes.post_analysis.lod.
LOD_Analyser
(args)[source]¶ Bases:
object
Analyses the evolutionary history of a population by tracing ancestors in the line of descent.
Loads a simulation save from a file, keeping a reference in
ref_sim
. From this, initialiseref_pop_hist
as aPopulationHistory
object that analyses the phylogenetic tree of the population.The
PopulationHistory
generates aLOD
for 1 or more individuals in the saved population. For eachLOD
, evolutionary data and network and genome plots can be produced.It is possible to load additional simulation snapshots that preceed the
ref_pop_hist
and compare individuals to their contemporaries present in the preceding populations.compare_saves
contains a list of file names of populations-saves that should be compared.-
args
= None¶ config and command line arguments used for initialisation
-
compare_saves
= []¶ names of snapshot files to copmare to ref_sim
-
compare_to_pops
()[source]¶ Compare reference simulation to a set of previous population snapshots.
Compares each of the simulation snapshot saves in
compare_saves
to theref_pop_hist
. APopulationHistory
is constructed for each of the compare snapshots. Within the compare snapshot, individuals that correspond to the are part of (any of) theLOD`(s) of the :attr:`ref_pop_hist
will be identified. Properties of these ancestors will then be compare with their statistical values for the whole population.
-
init_ref_history
(ref_sim=None, nr_lods=None, prune_depth=0, pop_hist_dir='population_history')[source]¶ Create a
PopulationHistory
from theref_sim
VirtualMicrobes.simulation.Simulation.Simulation
object.For the
PopulationHistory
object constructs its phylogenetic tree and prune back the tree to a maximum depth of (max_depth - prune_depth) counted from the root. Then createLOD
objects representing the line of descent of the nr_lods most diverged branches in the tree.Parameters: - ref_sim (
VirtualMicrobes.simulation.Simulation.Simulation
object) – simulation snapshot that is the basis for LOD analysis - nr_lods (int nr_lods) – nr of separate (most distant)
LOD
s to initialize - prune_depth (int) – prune back the phylogenetic tree with this many timesteps
- pop_hist_dir (str) – name of directory to store lod analysis output
- ref_sim (
-
lod_graphs
(stride=None, time_interval=None, lod_range=None, formats=None)[source]¶ Draw network and genome graphs for
LOD
sIt is possible to set an interval and a range to sample individuals in the
LOD
.Parameters: Note
Either use a stride or a time interval to sample individuals from the lod.
-
lod_network_stats
()[source]¶ Write time series for evolutionary network property changes along all
LOD
s.
-
lod_time_course_plots
(stride=None, time_interval=None, lod_range=None, formats=None)[source]¶ Draw time course diagrams for individuals in the
LOD
s.It is possible to set an interval and a range to sample individuals in the
LOD
.Parameters: Note
Either use a stride or a time interval to sample individuals from the lod.
-
lod_time_courses
(lod_range=None, chunk_size=None)[source]¶ Write time series of molecule concentrations within the
LOD
It is possible to set a range to sample individuals in the
LOD
.Parameters: - lod_range ((float,float)) – bounds in fractions of the total range of the
LOD
- chunk_size (int) – number of generations in LOD to concatenate per chunk
- lod_range ((float,float)) – bounds in fractions of the total range of the
-
ref_pop_hist
= None¶ PopulationHistory
for the reference simulation (ref_sim) snapshot
-
ref_sim
= None¶ VirtualMicrobes.simulation.Simulation
snapshot to analyse
-
-
class
VirtualMicrobes.post_analysis.lod.
PopulationHistory
(sim, params, save_dir=None, prune_depth=None)[source]¶ Bases:
object
Performs and stores evolutionary history analysis of
VirtualMicrobes.simulation.Simulation.Simulation
snapshots.Generates
LOD
s for 1 or more individuals in the population plot the evolutionary events along the line of descent.A reference
PopulationHistory
can also be compared to population history at earlier simulation time points. In this case the ancestors of individuals in the reference population history will be identified and compared to the rest of the population at that point in time. In this way, evolutionary biases on the line of descent can be brought to light.-
compare_to_pop
(compare_save, prune_depth=None, leafs_sample_size=None)[source]¶ Compare the reference
PopulationHistory
to an earlier population-save.Parameters: - compare_save (str) – file location of population-save
- prune_depth (int) – prune back phylogeny of the :param:compare_save with this many timesteps
- leafs_sample_size (int) – maximum number of phylogenetic tree leafs to use for comparison
-
environment
= None¶ Short cut to
VirtualMicrobes.environment.Environment
of sim.
-
identify_lod_ancestor
(ete_tree_struct, lod)[source]¶ Identify the individual in the population that is on the line of descent (lod) under consideration.
The nodes in the ete tree corresponding to the lod will be annotated with a tag.
Parameters: - ete_tree_struct (
VirtualMicrobes.my_tools.utility.ETEtreeStruct
) – container structure for phylogenetic tree representations - lod (
LOD
) – line of descent
Returns: - (
VirtualMicrobes.virtual_cell.Cell.Cell
,ete3.TreeNode
) - (oldest ancestor cell, its tree node representation)
- ete_tree_struct (
-
init_integrator
(diffusion_steps=None, between_diffusion_reports=None, max_retries=3, retry_steps_factor=2.0)[source]¶
-
init_lods
(nr_lods, save_dir=None, stride=None, time_interval=None, lod_range=None)[source]¶ Initialize the line of descent (
LOD
) container objects.Iterate over the phylogenetic trees of the
population
and for each tree select nr_lods leaf nodes that are at maximum phylogenetic distance.For each of the selected leafs, construct a line of descent object (
LOD
).Parameters: - nr_lods (int) – number of
LOD
objects per phylogenetic tree - save_dir (str) –
- stride (int) – stride in generations for sampling individuals along the
LOD
- time_interval (int) – interval in simulation time for sampling individuals along the
LOD
- lod_range ((float,float)) – bounds in fractions of the total range of the
LOD
- nr_lods (int) – number of
-
init_phylo_tree
(prune_depth=None)[source]¶ Update the phylogenetic tree of the population.
Clears the change in the population of the final regular simulation step. Prunes back the tree to a maximum depth.
Parameters: prune_depth (int) – number of generations to prune from the leafs of phylogenetic tree
-
lod_binding_conservation
()[source]¶ Write time series for line of descent properties such as network connectivity, protein expression etc.
Either use a stride or a time interval to sample individuals from the lod.
-
lod_network_stats
()[source]¶ Write time series for line of descent properties such as network connectivity, protein expression etc.
Either use a stride or a time interval to sample individuals from the lod.
-
lod_stats
()[source]¶ Write time series for line of descent properties such as network connectivity, protein expression etc.
Either use a stride or a time interval to sample individuals from the lod.
-
lods_time_course_data
(lod_range, chunk_size)[source]¶ Write time series data in the line of descent.
Concatenates time courses of individuals along a
LOD
. Concatenations are done in chunks of a chosen chunk_size. For each chunk .csv files are stored in a directory named part*n*, where n is the chunk number.Parameters: - ancestors (list of
VirtualMicrobes.virtual_cell.Cell.Cell
s) – - base_save_dir (str) –
- viewer_path (str) – path to utility files for html data viewer
- chunk_size (int) – length of chunks of concatenated data
- ancestors (list of
-
params
= None¶ The (updated) simulation parameters.
-
population
= None¶ Short cut to
VirtualMicrobes.virtual_cell.Population.Population
of sim.
-
prune_depth
= 0¶ Number of generations from leaves to prune the phylogenetic tree of the pophist.
-
sim
= None¶ The
VirtualMicrobes.simulation.Simulation.Simulation
snapshot for which this pophist was made.
-
time_point
= None¶ Last simulation time of the sim.
-
VirtualMicrobes.post_analysis.network_properties module¶
Created on Feb 9, 2016
@author: thocu
-
class
VirtualMicrobes.post_analysis.network_properties.
PhyloGeneticAnalysis
[source]¶ Bases:
object
Analyze biological networks
-
VirtualMicrobes.post_analysis.network_properties.
calculate_overlap
(tf_connections, connections_of_homologous_tfs, closest_bound_homologs_dict)[source]¶ Calculate the overlap in bound genes between tf homologs.
Parameters: - tf_connections (list of
VirtualMicrobes.virtual_cell.Gene.Gene
s) – Downstream connections of the reference TF - connections_of_homologous_tfs (list of sets of
VirtualMicrobes.virtual_cell.Gene.Gene
s) – List of sets of downstream genes for each homolog of the reference TF - closest_bound_homologs_dict (dict of sets of
VirtualMicrobes.virtual_cell.Gene.Gene
s) – Mapping of each original downstream gene of the reference TF to sets of homologs of these downstream genes.
Returns: Tuple of fractions: [0]: Fraction of downstream genes who’s homologs are bound by a homolog of the reference TF. [1]: Fraction of new connections (averaged over tf homologs) per original connection of the reference TF.
Return type: float,float
- tf_connections (list of
-
VirtualMicrobes.post_analysis.network_properties.
find_homolog_distances
(gene, genome, closest_homolog=False)[source]¶ Find homologs and their distance for a gene in a target genome.
Parameters: - gene (
VirtualMicrobes.virtual_cell.GenomicElement.GenomicElement
) – Reference gene for homology search. - genome (
VirtualMicrobes.virtual_cell.Genome.Genome
) – Genome in which to search for homologs. - closest_homolog (bool) – Flag to filter found homologs to those that have the shortest phylogenetic distance to the gene.
- gene (
-
VirtualMicrobes.post_analysis.network_properties.
find_homologs
(gene, genome)[source]¶ For a gene, find all its homologs in a given genome.
This is a naive approach that uses a combination of the gene’s type and its
VirtualMicrobes.virtual_cell.Identifier.Identifier
attribute to detect common descent.Parameters: - gene (
VirtualMicrobes.virtual_cell.GenomicElement.GenomicElement
) – Reference gene for homology search. - genome (
VirtualMicrobes.virtual_cell.Genome.Genome
) – Genome in which to search for homologs.
Returns: Return type: The set of homologs of gene in the genome.
- gene (
-
VirtualMicrobes.post_analysis.network_properties.
tf_binding_overlap
(cell1, cell2, closest_homolog=False, no_phylogeny=False, verbose=False)[source]¶ Measure the overlap in target genes for tf homologs in phylogenetically related individuals.
- cell1 :
- Reference individual for which to find homologs
- cell2 :
- Homologs of TFs and downstream targets will be detected in this individual.
- closest_homolog : bool
- Flag to filter found homologs to those that have the shortest phylogenetic distance to the gene.
- verbose : bool
- Print messages about homologs found.
VirtualMicrobes.virtual_cell.Cell.Cell
VirtualMicrobes.virtual_cell.Cell.Cell
Returns: Mapping from VirtualMicrobes.virtual_cell.Gene.TranscriptionFactor
to (maximum) binding overlap score.Return type: dict