|
A library for working with phylogenetic and population genetic data.
v0.32.0
|
|
Go to the documentation of this file.
79 #pragma omp parallel for
82 #pragma omp parallel for
91 result += place_i.like_weight_ratio * place_j.like_weight_ratio * dist;
100 auto result = std::vector<double>( sample.
size(), 0 );
103 #pragma omp parallel for
104 for(
size_t qi = 0; qi < sample.
size(); ++qi ) {
105 auto const& pquery = sample.
at( qi );
106 result[qi] =
edpl( pquery, node_distances );
114 return edpl( pquery, node_distances );
120 return edpl( sample, node_distances );
130 bool with_pendant_length
133 throw std::invalid_argument(
"pairwise_distance: Incompatible trees.");
142 std::vector<PqueryPlain>
const pqueries_a =
plain_queries( smp_a );
143 std::vector<PqueryPlain>
const pqueries_b =
plain_queries( smp_b );
153 auto dist =
pquery_distance( pqry_a, pqry_b, node_distances, with_pendant_length );
154 dist *= pqry_a.multiplicity * pqry_b.multiplicity;
175 std::vector<PqueryPlain>
const& pqrys_b,
177 bool with_pendant_length
179 double partial = 0.0;
184 if (pqry_a.
index >= pqry_b.index) {
187 double dist =
pquery_distance(pqry_a, pqry_b, node_distances, with_pendant_length);
189 partial += dist * dist;
197 bool with_pendant_length
213 #pragma omp parallel for
214 for(
size_t i = 0; i < vd_pqueries.size(); ++i ) {
224 for(
auto const& pqry : vd_pqueries ) {
225 for(
auto const& place : pqry.placements ) {
226 mass += place.like_weight_ratio * pqry.multiplicity;
double total_placement_mass_with_multiplicities(Sample const &smp)
Get the mass of all PqueryPlacements of the Sample, using the multiplicities as factors.
PlacementTree & tree()
Get the PlacementTree of this Sample.
double sum(const Histogram &h)
size_t size() const
Return the number of Pqueries that are stored in this Sample.
Simple POD struct that stores the information of a Pquery in a simple format for speeding up some cal...
double pquery_distance(PqueryPlain const &pquery_a, PqueryPlain const &pquery_b, utils::Matrix< double > const &node_distances, bool with_pendant_length)
Calculate the weighted distance between two plain pqueries. It is mainly a helper method for distance...
Manage a set of Pqueries along with the PlacementTree where the PqueryPlacements are placed on.
std::vector< PqueryPlain > plain_queries(Sample const &smp)
Return a plain representation of all pqueries of this map.
Provides functions for working with Placements and Pqueries.
double pairwise_distance(const Sample &smp_a, const Sample &smp_b, bool with_pendant_length)
Calculate the normalized pairwise distance between all placements of the two Samples.
Header of CommonTree distance methods.
static double variance_partial_(PqueryPlain const &pqry_a, std::vector< PqueryPlain > const &pqrys_b, utils::Matrix< double > const &node_distances, bool with_pendant_length)
Internal function that calculates the sum of distances contributed by one pquery for the variance....
PqueryPlacement & placement_at(size_t index)
Return the PqueryPlacement at a certain index.
Header for Placement Measures functions.
Provides easy and fast logging functionality.
A pquery holds a set of PqueryPlacements and a set of PqueryNames.
Pquery & at(size_t index)
Return the Pquery at a certain index.
double placement_distance(PqueryPlacement const &place_a, PqueryPlacement const &place_b, utils::Matrix< double > const &node_distances)
Calculate the distance between two PqueryPlacements, using their position on the tree::TreeEdges,...
double variance(const Sample &smp, bool with_pendant_length)
Calculate the variance of the placements on a tree.
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
size_t placement_size() const
Return the number of PqueryPlacements stored in this Pquery.
Header of PqueryPlain class.
utils::Matrix< double > node_branch_length_distance_matrix(Tree const &tree)
Return a distance matrix containing pairwise distances between all Nodes, using the branch_length of ...
double edpl(Pquery const &pquery, utils::Matrix< double > const &node_distances)
Calculate the EDPL uncertainty values for a Pquery.
Header of Tree distance methods.
bool compatible_trees(PlacementTree const &lhs, PlacementTree const &rhs)
Return whether two PlacementTrees are compatible.