barry: Your go-to motif accountant  0.0-1
Full enumeration of sample space and fast count of sufficient statistics for binary arrays
Geese Class Reference

Annotated Phylo Model. More...

#include <geese-bones.hpp>

Public Member Functions

 ~Geese ()
 
void init (size_t bar_width=BARRY_PROGRESS_BAR_WIDTH)
 
void inherit_support (const Geese &model_, bool delete_support_=false)
 
void calc_sequence (Node *n=nullptr)
 
void calc_reduced_sequence ()
 
double likelihood (const std::vector< double > &par, bool as_log=false, bool use_reduced_sequence=true, size_t ncores=1u, bool no_update_pset_probs=false)
 
double likelihood_exhaust (const std::vector< double > &par)
 
std::vector< double > get_probabilities () const
 
void set_seed (const size_t &s)
 
std::vector< std::vector< size_t > > simulate (const std::vector< double > &par)
 
std::vector< std::vector< double > > observed_counts ()
 
void print_observed_counts ()
 
void print () const
 Prints information about the GEESE. More...
 
void print_nodes () const
 
void init_node (Node &n)
 
void update_annotations (size_t nodeid, std::vector< size_t > newann)
 
std::vector< std::vector< bool > > get_states () const
 Powerset of a gene's possible states. More...
 
std::vector< size_t > get_annotated_nodes () const
 Returns the ids of the nodes with at least one annotation. More...
 
std::vector< size_t > get_annotations () const
 Returns the annotations of the nodes with at least one annotation. More...
 
Construct a new Geese object

The model includes a total of N + 1 nodes, the + 1 beign the root node.

Parameters
annotationsA vector of vectors with annotations. It should be of length k (number of functions). Each vector should be of length N (equal to the number of nodes, including interior). Possible values are 0, 1, and 9.
geneidId of the gene. It should be of length N.
parentId of the parent gene. Also of length N
duplicationLogical scalar indicating the type of event (true: duplication, false: speciation.)

The ordering of the entries does not matter. Passing the nodes in post order or not makes no difference to the constructor.

 Geese ()
 
 Geese (std::vector< std::vector< size_t > > &annotations, std::vector< size_t > &geneid, std::vector< int > &parent, std::vector< bool > &duplication)
 
 Geese (const Geese &model_, bool copy_data=true)
 
 Geese (Geese &&x) noexcept
 
Geeseoperator= (const Geese &model_)=delete
 
Geeseoperator= (Geese &&model_) noexcept=delete
 
Information about the model
Parameters
verbWhen true it will print out information about the encountered polytomies.
size_t nfuns () const noexcept
 Number of functions analyzed. More...
 
size_t nnodes () const noexcept
 Number of nodes (interior + leaf) More...
 
size_t nleafs () const noexcept
 Number of leaf. More...
 
size_t nterms () const
 Number of terms included. More...
 
size_t support_size () const noexcept
 Number of unique sets of sufficient stats. More...
 
std::vector< size_t > nannotations () const noexcept
 Number of annotations. More...
 
std::vector< std::string > colnames () const
 Names of the terms in the model. More...
 
size_t parse_polytomies (bool verb=true, std::vector< size_t > *dist=nullptr) const noexcept
 Check polytomies and return the largest. More...
 
Geese prediction

Calculate the conditional probability

Parameters
parVector of parameters (terms + root).
res_probVector indicating each nodes' state probability.
leave_one_outWhen true, it will compute the predictions using leave-one-out, thus the prediction will be repeated nleaf times.
only_annotatedWhen true, it will make the predictions only on the induced sub-tree with annotated leafs.
use_reduced_sequencePassed to the likelihood method.
preorderFor the tree traversal.

When res_prob is specified, the function will attach the member vector probabilities from the Nodes objects. This contains the probability that the ith node has either of the possible states.

Returns
std::vector< double > Returns the posterior probability
std::vector< std::vector< double > > predict (const std::vector< double > &par, std::vector< std::vector< double > > *res_prob=nullptr, bool leave_one_out=false, bool only_annotated=false, bool use_reduced_sequence=true)
 
std::vector< std::vector< double > > predict_backend (const std::vector< double > &par, bool use_reduced_sequence, const std::vector< size_t > &preorder)
 
std::vector< std::vector< double > > predict_exhaust_backend (const std::vector< double > &par, const std::vector< size_t > &preorder)
 
std::vector< std::vector< double > > predict_exhaust (const std::vector< double > &par)
 
std::vector< std::vector< double > > predict_sim (const std::vector< double > &par, bool only_annotated=false, size_t nsims=10000u)
 
Non-const pointers to shared objects in <tt>Geese</tt>

These functions provide direct access to some member objects that are shared by the nodes within Geese.

Returns
get_rengine() returns the Pseudo-RNG engine used.
get_counters() returns the vector of counters used.
get_model() returns the Model object used.
get_support_fun() returns the computed support of the model.
std::mt19937 * get_rengine ()
 
PhyloCountersget_counters ()
 
PhyloModelget_model ()
 
PhyloSupportget_support_fun ()
 

Public Attributes

size_t nfunctions
 
std::map< size_t, Nodenodes
 
barry::MapVec_type< size_t > map_to_state_id
 
std::vector< std::vector< std::vector< size_t > > > pset_loc
 Locations of columns. More...
 
std::vector< size_t > sequence
 
std::vector< size_t > reduced_sequence
 
bool initialized = false
 
bool delete_rengine = false
 
bool delete_support = false
 

Static Public Attributes

static const size_t etype_default = 1ul
 
static const size_t etype_speciation = 0ul
 
static const size_t etype_duplication = 1ul
 
static const size_t etype_either = 2ul
 

Detailed Description

Annotated Phylo Model.

A list of available terms for this model can be found in the Phylo counters section.

Class representing a phylogenetic tree model with annotations.

The Geese class represents a phylogenetic tree model with annotations. It includes a total of N + 1 nodes, the + 1 being the root node. The class provides methods for initializing the model, calculating the likelihood, simulating trees, and making predictions.

The class includes shared objects within a Geese object, such as rengine, model, states, n_zeros, n_ones, n_dupl_events, and n_spec_events. It also includes information about the type of event, such as etype_default, etype_speciation, etype_duplication, and etype_either.

The class provides constructors, a destructor, and methods for initializing the model, inheriting support, calculating the sequence, calculating the reduced sequence, calculating the likelihood, calculating the likelihood exhaustively, getting probabilities, setting the seed, simulating trees, parsing polytomies, getting observed counts, printing observed counts, printing information about the GEESE, and making predictions.

See also
Flock

Definition at line 114 of file geese-bones.hpp.

Constructor & Destructor Documentation

◆ Geese() [1/4]

Geese::Geese ( )
inline

Definition at line 6 of file geese-meat-constructors.hpp.

◆ Geese() [2/4]

Geese::Geese ( std::vector< std::vector< size_t > > &  annotations,
std::vector< size_t > &  geneid,
std::vector< int > &  parent,
std::vector< bool > &  duplication 
)
inline

Definition at line 20 of file geese-meat-constructors.hpp.

◆ Geese() [3/4]

Geese::Geese ( const Geese model_,
bool  copy_data = true 
)
inline

Definition at line 230 of file geese-meat-constructors.hpp.

◆ Geese() [4/4]

Geese::Geese ( Geese &&  x)
inlinenoexcept

Definition at line 309 of file geese-meat-constructors.hpp.

◆ ~Geese()

Geese::~Geese ( )
inline

Definition at line 119 of file geese-meat.hpp.

Member Function Documentation

◆ calc_reduced_sequence()

void Geese::calc_reduced_sequence ( )
inline

Definition at line 361 of file geese-meat.hpp.

◆ calc_sequence()

void Geese::calc_sequence ( Node n = nullptr)
inline

Definition at line 317 of file geese-meat.hpp.

◆ colnames()

std::vector< std::string > Geese::colnames ( ) const
inline

Names of the terms in the model.

Definition at line 482 of file geese-meat.hpp.

◆ get_annotated_nodes()

std::vector< size_t > Geese::get_annotated_nodes ( ) const
inline

Returns the ids of the nodes with at least one annotation.

Definition at line 771 of file geese-meat.hpp.

◆ get_annotations()

std::vector< size_t > Geese::get_annotations ( ) const
inline

Returns the annotations of the nodes with at least one annotation.

Definition at line 794 of file geese-meat.hpp.

◆ get_counters()

PhyloCounters * Geese::get_counters ( )
inline

Definition at line 754 of file geese-meat.hpp.

◆ get_model()

PhyloModel * Geese::get_model ( )
inline

Definition at line 759 of file geese-meat.hpp.

◆ get_probabilities()

std::vector< double > Geese::get_probabilities ( ) const
inline

Definition at line 409 of file geese-meat.hpp.

◆ get_rengine()

std::mt19937 * Geese::get_rengine ( )
inline

Definition at line 749 of file geese-meat.hpp.

◆ get_states()

std::vector< std::vector< bool > > Geese::get_states ( ) const
inline

Powerset of a gene's possible states.

This list of vectors is used throughout Geese. It lists all possible combinations of functional states for any gene. Thus, for P functions, there will be 2^P possible combinations.

Returns
std::vector< std::vector< bool > > of length 2^P.

Definition at line 767 of file geese-meat.hpp.

◆ get_support_fun()

PhyloSupport * Geese::get_support_fun ( )
inline

Definition at line 763 of file geese-meat.hpp.

◆ inherit_support()

void Geese::inherit_support ( const Geese model_,
bool  delete_support_ = false 
)
inline

Definition at line 260 of file geese-meat.hpp.

◆ init()

void Geese::init ( size_t  bar_width = BARRY_PROGRESS_BAR_WIDTH)
inline

Definition at line 131 of file geese-meat.hpp.

◆ init_node()

void Geese::init_node ( Node n)
inline

Definition at line 6 of file geese-meat.hpp.

◆ likelihood()

double Geese::likelihood ( const std::vector< double > &  par,
bool  as_log = false,
bool  use_reduced_sequence = true,
size_t  ncores = 1u,
bool  no_update_pset_probs = false 
)
inline

Definition at line 103 of file geese-meat-likelihood.hpp.

◆ likelihood_exhaust()

double Geese::likelihood_exhaust ( const std::vector< double > &  par)
inline

Definition at line 7 of file geese-meat-likelihood_exhaust.hpp.

◆ nannotations()

std::vector< size_t > Geese::nannotations ( ) const
inlinenoexcept

Number of annotations.

Definition at line 473 of file geese-meat.hpp.

◆ nfuns()

size_t Geese::nfuns ( ) const
inlinenoexcept

Number of functions analyzed.

Definition at line 430 of file geese-meat.hpp.

◆ nleafs()

size_t Geese::nleafs ( ) const
inlinenoexcept

Number of leaf.

Definition at line 444 of file geese-meat.hpp.

◆ nnodes()

size_t Geese::nnodes ( ) const
inlinenoexcept

Number of nodes (interior + leaf)

Definition at line 437 of file geese-meat.hpp.

◆ nterms()

size_t Geese::nterms ( ) const
inline

Number of terms included.

Definition at line 456 of file geese-meat.hpp.

◆ observed_counts()

std::vector< std::vector< double > > Geese::observed_counts ( )
inline

Definition at line 524 of file geese-meat.hpp.

◆ operator=() [1/2]

Geese& Geese::operator= ( const Geese model_)
delete

◆ operator=() [2/2]

Geese& Geese::operator= ( Geese &&  model_)
deletenoexcept

◆ parse_polytomies()

size_t Geese::parse_polytomies ( bool  verb = true,
std::vector< size_t > *  dist = nullptr 
) const
inlinenoexcept

Check polytomies and return the largest.

Definition at line 489 of file geese-meat.hpp.

◆ predict()

std::vector< std::vector< double > > Geese::predict ( const std::vector< double > &  par,
std::vector< std::vector< double > > *  res_prob = nullptr,
bool  leave_one_out = false,
bool  only_annotated = false,
bool  use_reduced_sequence = true 
)
inline

Definition at line 279 of file geese-meat-predict.hpp.

◆ predict_backend()

std::vector< std::vector< double > > Geese::predict_backend ( const std::vector< double > &  par,
bool  use_reduced_sequence,
const std::vector< size_t > &  preorder 
)
inline

< True if the array belongs to the set

Definition at line 6 of file geese-meat-predict.hpp.

◆ predict_exhaust()

std::vector< std::vector< double > > Geese::predict_exhaust ( const std::vector< double > &  par)
inline

Definition at line 5 of file geese-meat-predict_exhaust.hpp.

◆ predict_exhaust_backend()

std::vector< std::vector< double > > Geese::predict_exhaust_backend ( const std::vector< double > &  par,
const std::vector< size_t > &  preorder 
)
inline

Definition at line 47 of file geese-meat-predict_exhaust.hpp.

◆ predict_sim()

std::vector< std::vector< double > > Geese::predict_sim ( const std::vector< double > &  par,
bool  only_annotated = false,
size_t  nsims = 10000u 
)
inline

Definition at line 6 of file geese-meat-predict_sim.hpp.

◆ print()

void Geese::print ( ) const
inline

Prints information about the GEESE.

Definition at line 658 of file geese-meat.hpp.

◆ print_nodes()

void Geese::print_nodes ( ) const
inline

Definition at line 676 of file geese-meat.hpp.

◆ print_observed_counts()

void Geese::print_observed_counts ( )
inline

Definition at line 595 of file geese-meat.hpp.

◆ set_seed()

void Geese::set_seed ( const size_t &  s)
inline

Definition at line 4 of file geese-meat-simulate.hpp.

◆ simulate()

std::vector< std::vector< size_t > > Geese::simulate ( const std::vector< double > &  par)
inline

Definition at line 8 of file geese-meat-simulate.hpp.

◆ support_size()

size_t Geese::support_size ( ) const
inlinenoexcept

Number of unique sets of sufficient stats.

Definition at line 463 of file geese-meat.hpp.

◆ update_annotations()

void Geese::update_annotations ( size_t  nodeid,
std::vector< size_t >  newann 
)
inline

Definition at line 288 of file geese-meat.hpp.

Member Data Documentation

◆ delete_rengine

bool Geese::delete_rengine = false

Definition at line 153 of file geese-bones.hpp.

◆ delete_support

bool Geese::delete_support = false

Definition at line 154 of file geese-bones.hpp.

◆ etype_default

const size_t Geese::etype_default = 1ul
static

Definition at line 167 of file geese-bones.hpp.

◆ etype_duplication

const size_t Geese::etype_duplication = 1ul
static

Definition at line 169 of file geese-bones.hpp.

◆ etype_either

const size_t Geese::etype_either = 2ul
static

Definition at line 170 of file geese-bones.hpp.

◆ etype_speciation

const size_t Geese::etype_speciation = 0ul
static

Definition at line 168 of file geese-bones.hpp.

◆ initialized

bool Geese::initialized = false

Definition at line 152 of file geese-bones.hpp.

◆ map_to_state_id

barry::MapVec_type< size_t > Geese::map_to_state_id

Definition at line 144 of file geese-bones.hpp.

◆ nfunctions

size_t Geese::nfunctions

Definition at line 141 of file geese-bones.hpp.

◆ nodes

std::map< size_t, Node > Geese::nodes

Definition at line 142 of file geese-bones.hpp.

◆ pset_loc

std::vector< std::vector< std::vector< size_t > > > Geese::pset_loc

Locations of columns.

Definition at line 145 of file geese-bones.hpp.

◆ reduced_sequence

std::vector< size_t > Geese::reduced_sequence

Definition at line 149 of file geese-bones.hpp.

◆ sequence

std::vector< size_t > Geese::sequence

Definition at line 148 of file geese-bones.hpp.


The documentation for this class was generated from the following files: