A toolkit for working with phylogenetic data.
v0.18.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
placement/function/functions.cpp File Reference

Detailed Description

Implementation of the Placement Functions.

Definition in file placement/function/functions.cpp.

#include "genesis/placement/function/functions.hpp"
#include "genesis/placement/function/helper.hpp"
#include "genesis/placement/function/operators.hpp"
#include "genesis/tree/default/distances.hpp"
#include "genesis/tree/default/functions.hpp"
#include "genesis/tree/function/distances.hpp"
#include "genesis/tree/function/functions.hpp"
#include "genesis/tree/function/operators.hpp"
#include "genesis/utils/core/std.hpp"
#include <algorithm>
#include <cassert>
#include <cmath>
#include <exception>
#include <regex>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

Go to the source code of this file.

Namespaces

 genesis
 Container namespace for all symbols of genesis in order to keep them separate when used as a library.
 
 genesis::placement
 

Functions

void adjust_branch_lengths (Sample &sample, tree::Tree const &source)
 Take the branch lengths of the source Tree and use them as the new branch lengths of the sample. More...
 
std::unordered_set< std::string > all_pquery_names (Sample const &sample)
 Return a set of all unique PqueryNames of the Pqueries of the given sample. More...
 
std::vector< int > closest_leaf_depth_histogram (Sample const &smp)
 Return a histogram representing how many placements have which depth with respect to their closest leaf node. More...
 
std::vector< int > closest_leaf_distance_histogram (Sample const &smp, const double min, const double max, const int bins=10)
 Returns a histogram counting the number of placements that have a certain distance to their closest leaf node, divided into equally large intervals between a min and a max distance. More...
 
std::vector< int > closest_leaf_distance_histogram_auto (Sample const &smp, double &min, double &max, const int bins=10)
 Returns the same type of histogram as closest_leaf_distance_histogram(), but automatically determines the needed boundaries. More...
 
std::vector< double > closest_leaf_weight_distribution (Sample const &sample)
 
void collect_duplicate_pqueries (Sample &smp)
 Find all Pqueries that share a common name and combine them into a single Pquery containing all their collective PqueryPlacements and PqueryNames. More...
 
void copy_pqueries (Sample const &source, Sample &target)
 Copy all Pqueries from the source Sample (left parameter) to the target Sample (right parameter). More...
 
void filter_min_accumulated_weight (Pquery &pquery, double threshold=0.99)
 Remove the PqueryPlacements with the lowest like_weight_ratio, while keeping the accumulated weight (sum of all remaining like_weight_ratios) above a given threshold. More...
 
void filter_min_accumulated_weight (Sample &smp, double threshold=0.99)
 Remove the PqueryPlacements with the lowest like_weight_ratio, while keeping the accumulated weight (sum of all remaining like_weight_ratios) above a given threshold. More...
 
void filter_min_weight_threshold (Pquery &pquery, double threshold=0.01)
 Remove all PqueryPlacements that have a like_weight_ratio below the given threshold. More...
 
void filter_min_weight_threshold (Sample &smp, double threshold=0.01)
 Remove all PqueryPlacements that have a like_weight_ratio below the given threshold from all Pqueries of the Sample. More...
 
void filter_n_max_weight_placements (Pquery &pquery, size_t n=1)
 Remove all PqueryPlacements but the n most likely ones from the Pquery. More...
 
void filter_n_max_weight_placements (Sample &smp, size_t n=1)
 Remove all PqueryPlacements but the n most likely ones from all Pqueries in the Sample. More...
 
void filter_pqueries_differing_names (Sample &sample_1, Sample &sample_2)
 Remove all Pqueries from the two Samples that have a name in common. More...
 
void filter_pqueries_intersecting_names (Sample &sample_1, Sample &sample_2)
 Remove all Pqueries from the two Samples except the ones that have names in common. More...
 
void filter_pqueries_keeping_names (Sample &smp, std::string const &regex)
 Remove all Pqueries which do not have at least one name that matches the given regex. More...
 
void filter_pqueries_keeping_names (Sample &smp, std::unordered_set< std::string > keep_list)
 Remove all Pqueries which do not have at least one name that is in the given keep list. More...
 
void filter_pqueries_removing_names (Sample &smp, std::string const &regex)
 Remove all Pqueries which have at least one name that matches the given regex. More...
 
void filter_pqueries_removing_names (Sample &smp, std::unordered_set< std::string > remove_list)
 Remove all Pqueries which have at least one name that is in the given remove list. More...
 
Pquery const * find_pquery (Sample const &smp, std::string const &name)
 Return the first Pquery that has a particular name, or nullptr of none has. More...
 
Pquery * find_pquery (Sample &smp, std::string const &name)
 Return the first Pquery that has a particular name, or nullptr of none has. More...
 
bool has_name (Pquery const &pquery, std::string const &name)
 Return true iff the given Pquery contains a particular name. More...
 
bool has_name (Sample const &smp, std::string const &name)
 Return true iff the given Sample contains a Pquery with a particular name, i.e., a PqueryName whose name member equals the given name. More...
 
void merge_duplicate_names (Pquery &pquery)
 Merge all PqueryNames that have the same name property into one, while adding up their multiplicity. More...
 
void merge_duplicate_names (Sample &smp)
 Call merge_duplicate_names() for each Pquery of the Sample. More...
 
void merge_duplicate_placements (Pquery &pquery)
 Merge all PqueryPlacements of a Pquery that are on the same TreeEdge into one averaged PqueryPlacement. More...
 
void merge_duplicate_placements (Sample &smp)
 Call merge_duplicate_placements( Pquery& ) for each Pquery of a Sample. More...
 
void merge_duplicates (Sample &smp)
 Look for Pqueries with the same name and merge them. More...
 
void normalize_weight_ratios (Pquery &pquery)
 Recalculate the like_weight_ratio of the PqueryPlacement&s of a Pquery, so that their sum is 1.0, while maintaining their ratio to each other. More...
 
void normalize_weight_ratios (Sample &smp)
 Recalculate the like_weight_ratio of the PqueryPlacement&s of each Pquery in the Sample, so that their sum is 1.0, while maintaining their ratio to each other. More...
 
std::pair< PlacementTreeEdge
const *, size_t > 
placement_count_max_edge (Sample const &smp)
 Get the number of placements on the edge with the most placements, and a pointer to this edge. More...
 
std::pair< PlacementTreeEdge
const *, double > 
placement_mass_max_edge (Sample const &smp)
 Get the summed mass of the placements on the heaviest edge, measured by their like_weight_ratio, and a pointer to this edge. More...
 
size_t remove_empty_pqueries (Sample &sample)
 Remove all Pqueries from the Sample that have no PqueryPlacements. More...
 
void scale_all_branch_lengths (Sample &smp, double factor=1.0)
 Scale all branch lengths of the Tree and the position of the PqueryPlacements by a given factor. More...
 
void sort_placements_by_weight (Pquery &pquery)
 Sort the PqueryPlacements of a Pquery by their like_weight_ratio, in descending order (most likely first). More...
 
void sort_placements_by_weight (Sample &smp)
 Sort the PqueryPlacements of all Pqueries by their like_weight_ratio, in descending order (most likely first). More...
 
double total_multiplicity (Pquery const &pqry)
 Return the sum of all multiplicities of the Pquery. More...
 
double total_multiplicity (Sample const &sample)
 Return the sum of all multiplicities of all the Pqueries of the Sample. More...
 
size_t total_placement_count (Sample const &smp)
 Get the total number of PqueryPlacements in all Pqueries of the given Sample. More...
 
double total_placement_mass (Sample const &smp)
 Get the summed mass of all PqueryPlacements in all Pqueries of the given Sample, where mass is measured by the like_weight_ratios of the PqueryPlacements. More...
 
double total_placement_mass_with_multiplicities (Sample const &smp)
 Get the mass of all PqueryPlacements of the Sample, using the multiplicities as factors. More...