From 5e78748d3582a173cb20fd1b1c22521f60aa5e59 Mon Sep 17 00:00:00 2001 From: Lucas Czech Date: Fri, 28 Jun 2024 14:55:32 +0200 Subject: [PATCH] Add warning for single placement in analyze methods --- doc/md/dispersion.md | 2 +- src/commands/analyze/correlation.cpp | 8 ++++++++ src/commands/analyze/dispersion.cpp | 8 ++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/doc/md/dispersion.md b/doc/md/dispersion.md index eb48b5a..f0d725c 100644 --- a/doc/md/dispersion.md +++ b/doc/md/dispersion.md @@ -2,7 +2,7 @@ The command takes a set of `jplace` files, and calculates and visualizes the Edge Dispersion per edge of the reference tree. The files need to have the same reference tree. -Edge Dispersion is explained and evaluated in detail in our article (in preparation). The following figure and its caption are an example adapted from this article: +Edge Dispersion is explained and evaluated in detail in our article (doi:[10.1371/journal.pone.0217050](https://doi.org/10.1371/journal.pone.0217050)). The following figure and its caption are an example adapted from this article:
diff --git a/src/commands/analyze/correlation.cpp b/src/commands/analyze/correlation.cpp index b1d7a5f..cc6f76d 100644 --- a/src/commands/analyze/correlation.cpp +++ b/src/commands/analyze/correlation.cpp @@ -435,6 +435,14 @@ void run_correlation( CorrelationOptions const& options ) // Get the data. Read all samples and calcualte the matrices. auto const profile = options.jplace_input.placement_profile(); + assert( profile.edge_masses.rows() == profile.edge_imbalances.rows() ); + assert( profile.edge_masses.cols() == profile.edge_imbalances.cols() ); + if( profile.edge_masses.rows() <= 1 ) { + throw std::runtime_error( + "Cannot compute edge correlation of a single sample, as the method is meant to relate " + "a set of samples to their meta-data features." + ); + } LOG_MSG1 << "Calculating correlations and writing files."; diff --git a/src/commands/analyze/dispersion.cpp b/src/commands/analyze/dispersion.cpp index 52d0275..6ada083 100644 --- a/src/commands/analyze/dispersion.cpp +++ b/src/commands/analyze/dispersion.cpp @@ -405,6 +405,14 @@ void run_dispersion( DispersionOptions const& options ) // Get the data. Read all samples and calcualte the matrices. auto const profile = options.jplace_input.placement_profile(); + assert( profile.edge_masses.rows() == profile.edge_imbalances.rows() ); + assert( profile.edge_masses.cols() == profile.edge_imbalances.cols() ); + if( profile.edge_masses.rows() <= 1 ) { + throw std::runtime_error( + "Cannot compute edge dispersion of a single sample, as the method is meant to visualize " + "dispersion (variance) across a set of samples." + ); + } LOG_MSG2 << "Calculating dispersions and writing files.";