1 #ifndef GEESE_BONES_HPP
2 #define GEESE_BONES_HPP 1
9 template<
typename Ta,
typename Tb>
12 std::vector< Ta > ans;
13 ans.reserve(x.size());
15 for (
auto i = x.begin();
i != x.end(); ++
i)
16 ans.push_back(
static_cast< Ta
>(*
i));
22 #define INITIALIZED() if (!this->initialized) \
23 throw std::logic_error("The model has not been initialized yet.");
28 return Array(
i,
j) == 9u;
42 std::vector< double > dat = {
43 static_cast<double>(array.nrow()) * 100000 +
44 static_cast<double>(array.ncol()),
48 array.D_ptr()->duplication ? 1.0 : 0.0,
55 for (
bool i : array.D_ptr()->states) {
56 dat[1u] += (
i ? 1.0 : 0.0) * pow10;
72 const std::vector< size_t > & s,
73 const std::vector< size_t > & a
76 for (
size_t i = 0u;
i < a.size(); ++
i)
77 if ((a[
i] != 9u) && (a[
i] != s[
i]))
129 std::mt19937 * rengine =
nullptr;
131 std::vector< std::vector< bool > > states;
134 size_t n_dupl_events = 0u;
135 size_t n_spec_events = 0u;
145 std::vector< std::vector< std::vector< size_t > > >
pset_loc;
196 std::vector< std::vector<size_t> > & annotations,
197 std::vector< size_t > & geneid,
198 std::vector< int > & parent,
199 std::vector< bool > & duplication
203 Geese(
const Geese & model_,
bool copy_data =
true);
227 const std::vector< double > & par,
229 bool use_reduced_sequence =
true,
231 bool no_update_pset_probs =
false
239 std::vector< std::vector< size_t > >
simulate(
240 const std::vector< double > & par
255 std::vector< std::
string >
colnames() const;
258 std::vector<
size_t > * dist =
nullptr
294 std::vector< std::vector<
double > >
predict(
295 const std::vector<
double > & par,
296 std::vector< std::vector<
double > > * res_prob =
nullptr,
297 bool leave_one_out = false,
298 bool only_annotated = false,
299 bool use_reduced_sequence = true
303 const std::vector<
double > & par,
304 bool use_reduced_sequence,
305 const std::vector<
size_t > & preorder
309 const std::vector<
double > & par,
310 const std::vector<
size_t > & preorder
314 const std::vector<
double > & par
318 const std::vector<
double > & par,
319 bool only_annotated = false,
320 size_t nsims = 10000u
327 std::vector<
size_t > newann
356 std::vector< std::vector<
bool > >
get_states() const;
A Flock is a group of Geese.
std::vector< size_t > reduced_sequence
std::vector< std::vector< bool > > get_states() const
Powerset of a gene's possible states.
std::vector< size_t > sequence
void calc_reduced_sequence()
static const size_t etype_either
std::vector< std::vector< std::vector< size_t > > > pset_loc
Locations of columns.
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< size_t > get_annotations() const
Returns the annotations of the nodes with at least one annotation.
void print() const
Prints information about the GEESE.
PhyloSupport * get_support_fun()
PhyloCounters * get_counters()
size_t support_size() const noexcept
Number of unique sets of sufficient stats.
void print_observed_counts()
size_t parse_polytomies(bool verb=true, std::vector< size_t > *dist=nullptr) const noexcept
Check polytomies and return the largest.
std::vector< std::string > colnames() const
Names of the terms in the model.
void init(size_t bar_width=BARRY_PROGRESS_BAR_WIDTH)
size_t nnodes() const noexcept
Number of nodes (interior + leaf)
Geese & operator=(Geese &&model_) noexcept=delete
std::vector< double > get_probabilities() const
std::vector< std::vector< double > > predict_sim(const std::vector< double > &par, bool only_annotated=false, size_t nsims=10000u)
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)
std::vector< std::vector< double > > observed_counts()
Geese & operator=(const Geese &model_)=delete
size_t nleafs() const noexcept
Number of leaf.
std::vector< std::vector< double > > predict_exhaust_backend(const std::vector< double > &par, const std::vector< size_t > &preorder)
static const size_t etype_duplication
void calc_sequence(Node *n=nullptr)
void inherit_support(const Geese &model_, bool delete_support_=false)
std::vector< size_t > get_annotated_nodes() const
Returns the ids of the nodes with at least one annotation.
std::vector< std::vector< size_t > > simulate(const std::vector< double > &par)
std::vector< size_t > nannotations() const noexcept
Number of annotations.
void update_annotations(size_t nodeid, std::vector< size_t > newann)
std::vector< std::vector< double > > predict_exhaust(const std::vector< double > &par)
std::map< size_t, Node > nodes
static const size_t etype_speciation
std::vector< std::vector< double > > predict_backend(const std::vector< double > &par, bool use_reduced_sequence, const std::vector< size_t > &preorder)
std::mt19937 * get_rengine()
barry::MapVec_type< size_t > map_to_state_id
size_t nterms() const
Number of terms included.
size_t nfuns() const noexcept
Number of functions analyzed.
void set_seed(const size_t &s)
double likelihood_exhaust(const std::vector< double > &par)
static const size_t etype_default
A single node for the model.
Data_Type &&counter_ noexcept
RULE_FUNCTION(rule_empty_free)
std::vector< Ta > vector_caster(const std::vector< Tb > &x)
std::vector< double > keygen_full(const PhyloArray &array, const PhyloCounterData *d)
bool vec_diff(const std::vector< size_t > &s, const std::vector< size_t > &a)
barry::Counters< PhyloArray, PhyloCounterData > PhyloCounters
barry::Model< PhyloArray, PhyloCounterData, PhyloRuleData, PhyloRuleDynData > PhyloModel
barry::BArrayDense< size_t, NodeData > PhyloArray
barry::Support< PhyloArray, PhyloCounterData, PhyloRuleData, PhyloRuleDynData > PhyloSupport
#define BARRY_PROGRESS_BAR_WIDTH