27 if (command ==
"GA (fixed elemental contribution)")
31 if (command ==
"GA (disregarding targets)")
35 if (command ==
"Levenberg-Marquardt")
39 if (command ==
"Levenberg-Marquardt-Batch")
43 if (command ==
"OM-Size Correct")
51 if (command ==
"CovMat")
55 if (command ==
"CorMat")
64 if (command ==
"DFAOnevsRest")
68 if (command ==
"DFAM")
72 if (command ==
"SDFA")
77 if (command ==
"SDFAM")
82 if (command ==
"SDFAOnevsRest")
91 if (command ==
"KS-individual")
95 if (command ==
"CMB Bayesian")
99 if (command ==
"CMB Bayesian-Batch")
103 if (command ==
"Test CMB Bayesian")
113 if (command ==
"Bracketing Analysis")
117 if (command ==
"Bracketing Analysis Batch")
121 if (command ==
"BoxCox")
126 if (command ==
"Outlier")
131 if (command ==
"EDP")
136 if (command ==
"EDPM")
140 if (command ==
"ANOVA")
145 if (command ==
"Error_Analysis")
150 if (command ==
"Source_Verify")
155 if (command ==
"AutoSelect")
169 if (NegativeCheckResults.size()>0)
172 for (
unsigned int i=0; i<NegativeCheckResults.size(); i++)
174 message += QString::fromStdString(NegativeCheckResults[i]+
"\n");
186 for (map<
string,vector<string>>::iterator it = negative_elements.begin(); it!=negative_elements.end(); it++)
188 if (it->second.size()>0)
189 { message +=
"For target sample '" + QString::fromStdString(it->first) +
":\n";
190 for (
unsigned int i=0; i<it->second.size(); i++)
192 message += QString::fromStdString(
"\t" + it->second[i]) +
"\n";
210 bool organic_size_correction;
211 if (arguments.at(
"Apply size and organic matter correction") ==
"true")
213 organic_size_correction =
true;
214 if (
Data()->OMandSizeConstituents()[0] ==
"" &&
Data()->OMandSizeConstituents()[1] ==
"")
216 host->
ShowWarning(
"Perform Organic Matter and Size Correction first!\n");
222 organic_size_correction =
false;
226 arguments.at(
"Sample"),
227 organic_size_correction,
228 Data()->GetElementInformation()
237 GA = std::make_unique<CGA<SourceSinkData>>(&corrected_data);
239 GA->SetRunTimeWindow(rtw);
240 GA->SetProperties(arguments);
241 GA->InitiatePopulation();
246 ResultItem result_contribution =
GA->Model_out.GetContribution();
252 ResultItem result_modeled_vs_measured =
GA->Model_out.GetObservedvsModeledElementalProfile();
257 ResultItem result_modeled_vs_measured_isotope =
GA->Model_out.GetObservedvsModeledElementalProfile_Isotope();
262 ResultItem result_calculated_means =
GA->Model_out.GetCalculatedElementMeans();
267 ResultItem result_estimated_means =
GA->Model_out.GetEstimatedElementMean();
272 ResultItem result_calculated_mu =
GA->Model_out.GetCalculatedElementMu();
277 ResultItem result_estimated_mu =
GA->Model_out.GetEstimatedElementMu();
282 ResultItem result_calculated_sigma =
GA->Model_out.GetCalculatedElementSigma();
287 ResultItem result_estimated_sigma =
GA->Model_out.GetEstimatedElementSigma();
302 bool organic_size_correction;
303 if (arguments.at(
"Apply size and organic matter correction") ==
"true")
305 organic_size_correction =
true;
306 if (
Data()->OMandSizeConstituents()[0] ==
"" &&
Data()->OMandSizeConstituents()[1] ==
"")
308 host->
ShowWarning(
"Perform Organic Matter and Size Correction first!\n");
314 organic_size_correction =
false;
318 arguments.at(
"Sample"),
319 organic_size_correction,
320 Data()->GetElementInformation()
328 arguments.at(
"Sample"),
333 GA = std::make_unique<CGA<SourceSinkData>>(&corrected_data);
335 GA->SetRunTimeWindow(rtw);
336 GA->SetProperties(arguments);
337 GA->InitiatePopulation();
342 ResultItem result_contribution =
GA->Model_out.GetContribution();
360 arguments.at(
"Sample"),
365 GA = std::make_unique<CGA<SourceSinkData>>(
Data());
367 GA->SetRunTimeWindow(rtw);
368 GA->SetProperties(arguments);
369 GA->InitiatePopulation();
374 ResultItem result_calculated_means =
GA->Model_out.GetCalculatedElementMeans();
377 ResultItem result_estimated_means =
GA->Model_out.GetEstimatedElementMean();
380 ResultItem result_calculated_stds =
GA->Model_out.GetCalculatedElementSigma();
383 ResultItem result_estimated_stds =
GA->Model_out.GetEstimatedElementSigma();
393 bool organic_size_correction;
394 if (arguments.at(
"Apply size and organic matter correction") ==
"true")
396 organic_size_correction =
true;
397 if (
Data()->OMandSizeConstituents()[0] ==
"" &&
Data()->OMandSizeConstituents()[1] ==
"")
399 host->
ShowWarning(
"Perform Organic Matter and Size Correction first!\n");
405 organic_size_correction =
false;
411 arguments.at(
"Sample"),
412 organic_size_correction,
413 Data()->GetElementInformation()
422 if (arguments.at(
"Softmax transformation") ==
"true")
456 bool organic_size_correction;
457 if (arguments.at(
"Apply size and organic matter correction") ==
"true")
459 organic_size_correction =
true;
460 if (
Data()->OMandSizeConstituents()[0] ==
"" &&
Data()->OMandSizeConstituents()[1] ==
"")
462 host->
ShowWarning(
"Perform Organic Matter and Size Correction first!\n");
468 organic_size_correction =
false;
476 std::map<std::string, std::vector<std::string>> negative_elements;
478 if (arguments.at(
"Softmax transformation") ==
"true")
482 organic_size_correction,
490 organic_size_correction,
495 if (negative_elements.size() > 0)
507 contributions_result_item.
SetName(
"Levenberg-Marquardt-Batch");
508 contributions_result_item.
SetResult(contributions);
526 bool exclude_samples = (arguments.at(
"Use only selected samples") ==
"true");
527 bool exclude_elements = (arguments.at(
"Use only selected elements") ==
"true");
535 arguments.at(
"Sample")
540 results.
SetName(
"Corrected Elemental Profiles for Target" + arguments.at(
"Sample"));
542 for (
size_t i = 0; i < result_items.size(); i++)
552 if (arguments.at(
"Organic Matter constituent") ==
"" &&
553 arguments.at(
"Particle Size constituent") ==
"")
556 "Particle Size constituent must be selected");
562 bool exclude_samples = (arguments.at(
"Use only selected samples") ==
"true");
570 double p_value_threshold = QString::fromStdString(arguments.at(
"P-value threshold")).toDouble();
572 if (arguments.at(
"Equation") ==
"Linear")
575 arguments.at(
"Organic Matter constituent"),
576 arguments.at(
"Particle Size constituent"),
584 arguments.at(
"Organic Matter constituent"),
585 arguments.at(
"Particle Size constituent"),
592 arguments.at(
"Organic Matter constituent"),
593 arguments.at(
"Particle Size constituent")
596 for (std::map<std::string, Elemental_Profile_Set>::iterator it =
Data()->begin();
602 it->second.SetRegressionModels(transformed_data[it->first].GetRegressionModels());
606 std::vector<ResultItem> regression_results = transformed_data.
GetMLRResults();
608 for (
size_t i = 0; i < regression_results.size(); i++)
618 results.
SetName(
"Covariance Matrix for " + arguments.at(
"Source/Target group"));
621 covariance_matrix_item.
SetName(
"Covariance Matrix for " + arguments.at(
"Source/Target group"));
627 Data()->at(arguments.at(
"Source/Target group")).CalculateCovarianceMatrix()
630 covariance_matrix_item.
SetResult(covariance_matrix);
639 results.
SetName(
"Correlation Matrix for " + arguments.at(
"Source/Target group"));
642 correlation_matrix_item.
SetName(
"Correlation Matrix");
644 correlation_matrix_item.
setTableTitle(
"Correlation Matrix for source group '" +
645 arguments.at(
"Source/Target group") +
"'");
649 double threshold = QString::fromStdString(arguments.at(
"Threshold")).toDouble();
650 bool exclude_samples = (arguments.at(
"Use only selected samples") ==
"true");
651 bool exclude_elements = (arguments.at(
"Use only selected elements") ==
"true");
659 if (arguments.at(
"OM and Size Correct based on target sample") !=
"")
661 if (
Data()->OMandSizeConstituents()[0] ==
"" &&
Data()->OMandSizeConstituents()[1] ==
"")
663 host->
ShowWarning(
"Perform Organic Matter and Size Correction first!\n");
667 arguments.at(
"OM and Size Correct based on target sample"),
669 Data()->GetElementInformation()
674 transformed_data.at(arguments.at(
"Source/Target group")).CalculateCorrelationMatrix()
680 correlation_matrix_item.
SetResult(correlation_matrix);
688 if (arguments.at(
"Source/Target group I") == arguments.at(
"Source/Target group II"))
697 results.
SetName(
"DFA between " + arguments.at(
"Source/Target group I") +
698 "&" + arguments.at(
"Source/Target group II"));
700 bool exclude_samples = (arguments.at(
"Use only selected samples") ==
"true");
701 bool exclude_elements = (arguments.at(
"Use only selected elements") ==
"true");
705 if (arguments.at(
"OM and Size Correct based on target sample") !=
"")
707 if (
Data()->OMandSizeConstituents()[0] ==
"" &&
Data()->OMandSizeConstituents()[1] ==
"")
709 host->
ShowWarning(
"Perform Organic Matter and Size Correction first!\n");
713 arguments.at(
"OM and Size Correct based on target sample"),
715 Data()->GetElementInformation()
727 if (arguments.at(
"Box-cox transformation") ==
"true")
733 arguments.at(
"Source/Target group I"),
734 arguments.at(
"Source/Target group II")
739 host->
ShowWarning(
"Singular matrix in within group scatter matrix!\n");
746 dfa_p_value.
SetName(
"Chi-squared P-Value");
756 dfa_f_test_p_value.
SetName(
"F-test P-Value");
760 dfa_f_test_p_value.
SetResult(f_test_p_value);
765 dfa_projected.
SetName(
"Projected Elemental Profiles");
776 dfa_eigen_vector.
SetName(
"Eigen vector");
782 dfa_eigen_vector.
SetResult(eigen_vector);
795 results.
SetName(
"DFA between " + arguments.at(
"Source group") +
"& the rest");
797 bool exclude_samples = (arguments.at(
"Use only selected samples") ==
"true");
798 bool exclude_elements = (arguments.at(
"Use only selected elements") ==
"true");
802 if (arguments.at(
"OM and Size Correct based on target sample") !=
"")
804 if (
Data()->OMandSizeConstituents()[0] ==
"" &&
Data()->OMandSizeConstituents()[1] ==
"")
806 host->
ShowWarning(
"Perform Organic Matter and Size Correction first!\n");
810 arguments.at(
"OM and Size Correct based on target sample"),
812 Data()->GetElementInformation()
824 if (arguments.at(
"Box-cox transformation") ==
"true")
830 arguments.at(
"Source group")
835 host->
ShowWarning(
"Singular matrix in within group scatter matrix!\n");
842 dfa_p_value.
SetName(
"Chi-squared P-Value");
852 dfa_f_test_p_value.
SetName(
"F-test P-Value");
856 dfa_f_test_p_value.
SetResult(f_test_p_value);
861 dfa_projected.
SetName(
"Projected Elemental Profiles");
872 dfa_eigen_vector.
SetName(
"Eigen vector");
878 dfa_eigen_vector.
SetResult(eigen_vector);
893 bool exclude_samples = (arguments.at(
"Use only selected samples") ==
"true");
894 bool exclude_elements = (arguments.at(
"Use only selected elements") ==
"true");
898 if (arguments.at(
"OM and Size Correct based on target sample") !=
"")
900 if (
Data()->OMandSizeConstituents()[0] ==
"" &&
Data()->OMandSizeConstituents()[1] ==
"")
902 host->
ShowWarning(
"Perform Organic Matter and Size Correction first!\n");
906 arguments.at(
"OM and Size Correct based on target sample"),
908 Data()->GetElementInformation()
923 if (arguments.at(
"Box-cox transformation") ==
"true")
932 host->
ShowWarning(
"Singular matrix in within group scatter matrix!\n");
939 dfa_p_value.
SetName(
"Chi-squared P-Value");
949 dfa_f_test_p_value.
SetName(
"F-test P-Value");
953 dfa_f_test_p_value.
SetResult(f_test_p_value);
958 dfa_projected.
SetName(
"Multiway Projected Elemental Profiles");
969 dfa_eigen_vectors.
SetName(
"Eigen vector");
975 dfa_eigen_vectors.
SetResult(eigen_vectors);
985 if (arguments.at(
"Source/Target group I") == arguments.at(
"Source/Target group II"))
994 results.
SetName(
"Stepwise DFA between " + arguments.at(
"Source/Target group I") +
995 "&" + arguments.at(
"Source/Target group II"));
997 bool exclude_samples = (arguments.at(
"Use only selected samples") ==
"true");
998 bool exclude_elements = (arguments.at(
"Use only selected elements") ==
"true");
1002 if (arguments.at(
"OM and Size Correct based on target sample") !=
"")
1006 host->
ShowWarning(
"Perform Organic Matter and Size Correction first!\n");
1010 arguments.at(
"OM and Size Correct based on target sample"),
1012 Data()->GetElementInformation()
1027 if (arguments.at(
"Box-cox transformation") ==
"true")
1035 arguments.at(
"Source/Target group I"),
1036 arguments.at(
"Source/Target group II")
1039 if (sdfa_results[0].size() == 0)
1041 host->
ShowWarning(
"Singular matrix in within group scatter matrix!\n");
1048 sdfa_p_values.
SetName(
"Chi-squared P-Values");
1060 sdfa_wilks_lambda.
SetName(
"Wilks' Lambda");
1066 sdfa_wilks_lambda.
SetResult(wilks_lambda_vector);
1072 sdfa_f_test_p_value.
SetName(
"F-test P-Value");
1078 sdfa_f_test_p_value.
SetResult(f_test_p_value);
1091 bool exclude_samples = (arguments.at(
"Use only selected samples") ==
"true");
1092 bool exclude_elements = (arguments.at(
"Use only selected elements") ==
"true");
1096 if (arguments.at(
"OM and Size Correct based on target sample") !=
"")
1100 host->
ShowWarning(
"Perform Organic Matter and Size Correction first!\n");
1104 arguments.at(
"OM and Size Correct based on target sample"),
1106 Data()->GetElementInformation()
1121 if (arguments.at(
"Box-cox transformation") ==
"true")
1130 if (sdfa_results[0].size() == 0)
1132 host->
ShowWarning(
"Singular matrix in within group scatter matrix!\n");
1139 sdfa_p_values.
SetName(
"Chi-squared P-Values");
1150 sdfa_selected.
SetName(
"Elements to be Selected");
1160 if (arguments.at(
"Modify the included elements based on the results") ==
"true")
1165 for (
size_t i = 0; i < selected.size(); i++)
1167 p_vector_selected->
append(selected[i], p_vector->
valueAt(i));
1170 sdfa_selected.
SetResult(p_vector_selected);
1176 sdfa_wilks_lambda.
SetName(
"Wilks' Lambda");
1182 sdfa_wilks_lambda.
SetResult(wilks_lambda_vector);
1188 sdfa_f_test_p_value.
SetName(
"F-test P-Value");
1194 sdfa_f_test_p_value.
SetResult(f_test_p_value);
1205 results.
SetName(
"Stepwise DFA between " + arguments.at(
"Source group") +
"& the rest");
1207 bool exclude_samples = (arguments.at(
"Use only selected samples") ==
"true");
1208 bool exclude_elements = (arguments.at(
"Use only selected elements") ==
"true");
1212 if (arguments.at(
"OM and Size Correct based on target sample") !=
"")
1216 host->
ShowWarning(
"Perform Organic Matter and Size Correction first!\n");
1220 arguments.at(
"OM and Size Correct based on target sample"),
1222 Data()->GetElementInformation()
1237 if (arguments.at(
"Box-cox transformation") ==
"true")
1245 arguments.at(
"Source group")
1248 if (sdfa_results[0].size() == 0)
1250 host->
ShowWarning(
"Singular matrix in within group scatter matrix!\n");
1257 sdfa_p_values.
SetName(
"Chi-squared P-Values");
1269 sdfa_wilks_lambda.
SetName(
"Wilks' Lambda");
1275 sdfa_wilks_lambda.
SetResult(wilks_lambda_vector);
1281 sdfa_f_test_p_value.
SetName(
"F-test P-Value");
1287 sdfa_f_test_p_value.
SetResult(f_test_p_value);
1295 results.
SetName(
"Kolmogorov–Smirnov statististics for " + arguments.at(
"Source/Target group"));
1298 ks_item.
SetName(
"Kolmogorov–Smirnov statististics for " + arguments.at(
"Source/Target group"));
1303 if (arguments.at(
"Distribution") ==
"Normal")
1307 else if (arguments.at(
"Distribution") ==
"Lognormal")
1313 Data()->at(arguments.at(
"Source/Target group")).CalculateKolmogorovSmirnovStatistics(dist)
1325 results.
SetName(
"Kolmogorov–Smirnov statististics for constituent " +
1326 arguments.at(
"Constituent") +
" in group " +
1327 arguments.at(
"Source/Target group"));
1330 ks_item.
SetName(
"Kolmogorov–Smirnov statististics for constituent " +
1331 arguments.at(
"Constituent") +
" in group " +
1332 arguments.at(
"Source/Target group"));
1336 if (arguments.at(
"Distribution") ==
"Normal")
1340 else if (arguments.at(
"Distribution") ==
"Lognormal")
1346 Data()->at(arguments.at(
"Source/Target group"))
1360 if (arguments.at(
"Apply size and organic matter correction") ==
"true")
1362 if (
Data()->OMandSizeConstituents()[0] ==
"" &&
Data()->OMandSizeConstituents()[1] ==
"")
1364 host->
ShowWarning(
"Perform Organic Matter and Size Correction first!\n");
1370 MCMC = std::make_unique<CMCMC<SourceSinkData>>();
1374 rtw->SetTitle(
"Acceptance Rate", 0);
1375 rtw->SetTitle(
"Purturbation Factor", 1);
1376 rtw->SetTitle(
"Log posterior value", 2);
1377 rtw->SetYAxisTitle(
"Acceptance Rate", 0);
1378 rtw->SetYAxisTitle(
"Purturbation Factor", 1);
1379 rtw->SetYAxisTitle(
"Log posterior value", 2);
1383 std::vector<std::string> failed_writes;
1394 if (!failed_writes.empty())
1396 std::string message =
"Some per-sample result files could not be written:\n";
1397 for (
const std::string& failure : failed_writes)
1398 message += failure +
"\n";
1406 contribution_matrix_item.
SetName(
"Contribution Range Matrix");
1409 contribution_matrix_item.
SetResult(contributions);
1413 rtw->SetProgress(1);
1426 mcmc_samples.SetName(
"MCMC samples for testing MCMC'");
1433 mcmc_for_testing->
Model = &testing_model;
1437 rtw->
SetTitle(
"Acceptance Rate", 0);
1438 rtw->
SetTitle(
"Purturbation Factor", 1);
1439 rtw->
SetTitle(
"Log posterior value", 2);
1446 std::vector<double> mins;
1447 std::vector<double> maxs;
1448 mins.push_back(0.1);
1450 maxs.push_back(1.0);
1456 mcmc_for_testing->
SetProperty(
"number_of_samples", arguments.at(
"Number of samples"));
1457 mcmc_for_testing->
SetProperty(
"number_of_chains", arguments.at(
"Number of chains"));
1458 mcmc_for_testing->
SetProperty(
"number_of_burnout_samples", arguments.at(
"Samples to be discarded (burnout)"));
1463 std::string folder_path;
1464 if (!QString::fromStdString(arguments.at(
"samples_file_name")).contains(
"/"))
1470 mcmc_for_testing->
step(
1471 QString::fromStdString(arguments.at(
"Number of chains")).toInt(),
1472 QString::fromStdString(arguments.at(
"Number of samples")).toInt(),
1473 folder_path + arguments.at(
"samples_file_name"),
1484 *dists =
samples->distribution(
1486 QString::fromStdString(arguments.at(
"Samples to be discarded (burnout)")).toInt()
1489 distribution_result_item.
SetName(
"Posterior Distributions");
1492 distribution_result_item.
SetResult(dists);
1496 delete mcmc_for_testing;
1503 results.
SetName(
"Distribution fitting results for '" + arguments.at(
"Constituent") +
1504 "' in '" + arguments.at(
"Source/Target group"));
1508 distribution_item.
SetName(
"Fitted PDF for '" + arguments.at(
"Constituent") +
1509 "' in '" + arguments.at(
"Source/Target group"));
1517 cumulative_distribution_item.
SetName(
"Fitted CDF for '" + arguments.at(
"Constituent") +
1518 "' in '" + arguments.at(
"Source/Target group"));
1525 bool exclude_samples = (arguments.at(
"Use only selected samples") ==
"true");
1529 if (arguments.at(
"OM and Size Correct based on target sample") !=
"")
1533 host->
ShowWarning(
"Perform Organic Matter and Size Correction first!\n");
1537 arguments.at(
"OM and Size Correct based on target sample"),
1539 Data()->GetElementInformation()
1550 if (arguments.at(
"Box-cox transformation") ==
"true")
1556 CMBTimeSeriesSet fitted_normal = transformed_data.at(arguments.at(
"Source/Target group"))
1562 if (arguments.at(
"Box-cox transformation") !=
"true")
1564 fitted_lognormal = transformed_data.at(arguments.at(
"Source/Target group"))
1570 CMBTimeSeriesSet observed_fitted_normal_cdf = transformed_data.at(arguments.at(
"Source/Target group"))
1576 if (arguments.at(
"Box-cox transformation") !=
"true")
1578 observed_fitted_lognormal_cdf = transformed_data.at(arguments.at(
"Source/Target group"))
1585 pdf->append(fitted_normal[
"Observed"]);
1586 pdf->append(fitted_normal[
"Fitted"]);
1587 if (arguments.at(
"Box-cox transformation") !=
"true")
1589 pdf->append(fitted_lognormal[
"Fitted"]);
1591 pdf->setname(0,
"Samples");
1592 pdf->setname(1,
"Normal");
1593 if (arguments.at(
"Box-cox transformation") !=
"true")
1595 pdf->setname(2,
"Log-normal");
1600 cdf->append(observed_fitted_normal_cdf[
"Observed"]);
1601 cdf->append(observed_fitted_normal_cdf[
"Fitted"]);
1602 if (arguments.at(
"Box-cox transformation") !=
"true")
1604 cdf->append(observed_fitted_lognormal_cdf[
"Fitted"]);
1606 cdf->setname(0,
"Observed");
1607 cdf->setname(1,
"Normal");
1608 if (arguments.at(
"Box-cox transformation") !=
"true")
1610 cdf->setname(2,
"Log-normal");
1614 cumulative_distribution_item.
SetResult(cdf);
1624 results.
SetName(
"Bracketing analysis for sample '" + arguments.at(
"Sample") +
"'");
1627 bracketing_result_item.
SetName(
"Bracketing results");
1632 bool exclude_samples = (arguments.at(
"Use only selected samples") ==
"true");
1633 bool exclude_elements = (arguments.at(
"Use only selected elements") ==
"true");
1634 bool correct_based_on_size_and_organic_matter = (arguments.at(
"Correct based on size and organic matter") ==
"true");
1639 correct_based_on_size_and_organic_matter,
1640 arguments.at(
"Sample")
1647 transformed_data.
BracketTest(arguments.at(
"Sample"),
false)
1651 bracketing_result_item.
SetResult(bracketing_result);
1662 bracketing_result_item.
SetName(
"Bracketing results");
1668 bool exclude_samples = (arguments.at(
"Use only selected samples") ==
"true");
1669 bool exclude_elements = (arguments.at(
"Use only selected elements") ==
"true");
1670 bool correct_based_on_size_and_organic_matter = (arguments.at(
"Correct based on size and organic matter") ==
"true");
1675 if (correct_based_on_size_and_organic_matter)
1679 host->
ShowWarning(
"Perform Organic Matter and Size Correction first!\n");
1685 Data()->BracketTest(
1686 correct_based_on_size_and_organic_matter,
1693 bracketing_result_item.
SetResult(bracketing_result);
1701 results.
SetName(
"Box-Cox parameter for '" + arguments.at(
"Source/Target group") +
"'");
1704 boxcox_result_item.
SetName(
"Box-Cox parameters");
1711 Data()->at(arguments.at(
"Source/Target group")).CalculateBoxCoxParameters()
1714 boxcox_result_item.
SetResult(boxcox_params);
1722 bool exclude_samples = (arguments.at(
"Use only selected samples") ==
"true");
1723 bool exclude_elements = (arguments.at(
"Use only selected elements") ==
"true");
1734 results.
SetName(
"Outlier analysis for '" + arguments.at(
"Source/Target group") +
"'");
1737 outlier_result_item.
SetName(
"Outlier Analysis");
1743 double threshold = QString::fromStdString(arguments.at(
"Threshold")).toDouble();
1746 transformed_data.at(arguments.at(
"Source/Target group")).DetectOutliers(-threshold, threshold)
1752 outlier_result_item.
SetResult(outlier_matrix);
1761 arguments.at(
"Source/Target group I") +
"' and '" +
1762 arguments.at(
"Source/Target group II") +
"'");
1764 bool exclude_samples = (arguments.at(
"Use only selected samples") ==
"true");
1768 if (arguments.at(
"OM and Size Correct based on target sample") !=
"")
1772 host->
ShowWarning(
"Perform Organic Matter and Size Correction first!\n");
1776 arguments.at(
"OM and Size Correct based on target sample"),
1778 Data()->GetElementInformation()
1789 if (arguments.at(
"Box-cox transformation") ==
"true")
1796 edp_result_std.
SetName(
"Discreminant difference to standard deviation ratio");
1804 arguments.at(
"Source/Target group I"),
1805 arguments.at(
"Source/Target group II"),
1812 edp_result_std.
SetResult(edp_profile_set);
1814 edp_result_std.
setYAxisTitle(
"Standard deviation to mean ratio");
1819 edp_result_percent.
SetName(
"Discriminat fraction");
1822 edp_result_percent.
setYAxisTitle(
"Percentage discriminated");
1828 arguments.at(
"Source/Target group I"),
1829 arguments.at(
"Source/Target group II")
1835 edp_result_percent.
SetResult(edp_profile_set_percent);
1842 edp_result_p_value.
SetName(
"Discriminat p-value");
1851 arguments.at(
"Source/Target group I"),
1852 arguments.at(
"Source/Target group II"),
1859 edp_result_p_value.
SetResult(edp_profile_set_p_value);
1860 edp_profile_set_p_value->
SetLimit(
_range::high, aquiutils::atof(arguments.at(
"P-value threshold")));
1871 bool include_target = (arguments.at(
"Include target samples") ==
"true");
1872 bool exclude_samples = (arguments.at(
"Use only selected samples") ==
"true");
1876 if (arguments.at(
"OM and Size Correct based on target sample") !=
"")
1880 host->
ShowWarning(
"Perform Organic Matter and Size Correction first!\n");
1884 arguments.at(
"OM and Size Correct based on target sample"),
1886 Data()->GetElementInformation()
1897 if (arguments.at(
"Box-cox transformation") ==
"true")
1902 results.
SetName(
"Multi-way element discriminant power between '" +
1903 arguments.at(
"Source/Target group I") +
"' and '" +
1904 arguments.at(
"Source/Target group II") +
"'");
1908 edp_result_std.
SetName(
"Multi-way discreminant difference to standard deviation ratio");
1920 edp_result_std.
SetResult(edp_profile_set);
1925 edp_result_percent.
SetName(
"Multi-way discriminat fraction");
1928 edp_result_percent.
setYAxisTitle(
"Percentage discriminated");
1938 edp_result_percent.
SetResult(edp_profile_set_percent);
1943 edp_p_value.
SetName(
"Multi-way discriminat p-value");
1956 edp_p_value.
SetResult(edp_profile_set_p_value);
1957 edp_profile_set_p_value->
SetLimit(
_range::high, aquiutils::atof(arguments.at(
"P-value threshold")));
1966 bool log_transformation = (arguments.at(
"Log Transformation") ==
"true");
1967 bool exclude_samples = (arguments.at(
"Use only selected samples") ==
"true");
1968 bool exclude_elements = (arguments.at(
"Use only selected elements") ==
"true");
1972 if (arguments.at(
"OM and Size Correct based on target sample") !=
"")
1976 host->
ShowWarning(
"Perform Organic Matter and Size Correction first!\n");
1980 arguments.at(
"OM and Size Correct based on target sample"),
1982 Data()->GetElementInformation()
1993 if (arguments.at(
"Box-cox transformation") ==
"true")
1996 log_transformation =
false;
2002 anova_results.
SetName(
"ANOVA");
2018 if (arguments.at(
"Modify the included elements based on the results") ==
"true")
2022 aquiutils::atof(arguments.at(
"P-value threshold"))
2038 bool organic_size_correction;
2039 if (arguments.at(
"Apply size and organic matter correction") ==
"true")
2041 organic_size_correction =
true;
2042 if (
Data()->OMandSizeConstituents()[0] ==
"" &&
Data()->OMandSizeConstituents()[1] ==
"")
2044 host->
ShowWarning(
"Perform Organic Matter and Size Correction first!\n");
2050 organic_size_correction =
false;
2056 arguments.at(
"Sample"),
2057 organic_size_correction,
2058 Data()->GetElementInformation()
2066 bool softmax = (arguments.at(
"Softmax transformation") ==
"true");
2070 bool outcome = corrected_data.
BootStrap(
2072 aquiutils::atof(arguments.at(
"Pecentage eliminated")),
2073 aquiutils::atoi(arguments.at(
"Number of realizations")),
2074 arguments.at(
"Sample"),
2087 bool organic_size_correction;
2088 if (arguments.at(
"Apply size and organic matter correction") ==
"true")
2090 organic_size_correction =
true;
2091 if (
Data()->OMandSizeConstituents()[0] ==
"" &&
Data()->OMandSizeConstituents()[1] ==
"")
2093 host->
ShowWarning(
"Perform Organic Matter and Size Correction first!\n");
2099 organic_size_correction =
false;
2110 bool softmax = (arguments.at(
"Softmax transformation") ==
"true");
2114 arguments.at(
"Source Group"),
2116 organic_size_correction
2121 results.
SetName(
"Source verification for source'" + arguments.at(
"Source Group") +
"'");
2127 contributions_result_item.
SetName(
"Source Verification");
2128 contributions_result_item.
SetResult(contributions);
2152 if (arguments.at(
"OM and Size Correct based on target sample") !=
"")
2154 if (
Data()->OMandSizeConstituents()[0] ==
"" &&
Data()->OMandSizeConstituents()[1] ==
"")
2156 host->
ShowWarning(
"Perform Organic Matter and Size Correction first!\n");
2160 arguments.at(
"OM and Size Correct based on target sample"),
2162 Data()->GetElementInformation()
2173 bool isotopes = (arguments.at(
"Include Isotopes") ==
"true");
2179 edp_p_value.
SetName(
"Multi-way discriminat p-value");
2192 edp_p_value.
SetResult(edp_profile_set_p_value);
2198 aquiutils::atoi(arguments.at(
"Number of elements from each pair"))
2204 selected_elements.
SetName(
"Selected Elements");
2212 if (arguments.at(
"Modify the included elements based on the results") ==
"true")
2222 if (arguments.at(
"Apply size and organic matter correction") ==
"true")
2224 if (
Data()->OMandSizeConstituents()[0] ==
"" &&
Data()->OMandSizeConstituents()[1] ==
"")
2226 host->
ShowWarning(
"Perform Organic Matter and Size Correction first!\n");
2232 MCMC = std::make_unique<CMCMC<SourceSinkData>>();
2236 rtw->SetTitle(
"Acceptance Rate", 0);
2237 rtw->SetTitle(
"Purturbation Factor", 1);
2238 rtw->SetTitle(
"Log posterior value", 2);
2239 rtw->SetYAxisTitle(
"Acceptance Rate", 0);
2240 rtw->SetYAxisTitle(
"Purturbation Factor", 1);
2241 rtw->SetYAxisTitle(
"Log posterior value", 2);
2246 arguments.at(
"Sample"),
2260 rtw->SetProgress(1);
Abstract environment that an analysis runs inside.
virtual void ShowWarning(const std::string &message)=0
Reports a condition that prevented an analysis from running.
Matrix class with labeled rows and columns for Chemical Mass Balance analysis.
void SetBooleanValue(bool val)
Sets boolean display mode for table widget.
Collection of time series with labels and observed values.
Collection of named CMBVectorSet objects for hierarchical data organization.
Collection of named CMBVector objects for multi-variable analysis.
Vector class with string labels for Chemical Mass Balance analysis.
CMBVector ExtractWithinRange(const double &lowval, const double &highval) const
Extracts elements with values within specified range.
void SetBooleanValue(bool val)
Sets boolean display mode for table widget.
CMBVector ExtractUpToMinimum() const
Extracts elements up to first minimum value.
void append(const string &label, const double &val)
Appends a labeled element to the vector.
double valueAt(int i) const
Gets value at specified index.
vector< string > Labels() const
Gets all element labels.
Markov Chain Monte Carlo sampler for Bayesian parameter estimation.
bool SetProperty(const string &varname, const string &value)
Set MCMC properties from string key-value pairs.
bool step(int k, int chain_counter)
Perform single MCMC step for one chain.
T * Model
Pointer to the model object being calibrated.
void initialize(CMBTimeSeriesSet *results, bool random=false)
Initialize MCMC chains with starting parameter values.
CMBTimeSeriesSet CreateCDFComparison(distribution_type dist_type) const
Create comparison of empirical vs fitted CDF.
CMBTimeSeriesSet CreateFittedDistribution(distribution_type dist_type) const
Create fitted distribution visualization.
bool ExecuteOutlierAnalysis(const std::map< std::string, std::string > &arguments)
Executes outlier detection analysis for a source/target group.
bool ExecuteTestCMBBayesian(const std::map< std::string, std::string > &arguments)
Executes MCMC test with a simple analytical model.
bool ExecuteCMBBayesian(const std::map< std::string, std::string > &arguments)
Executes Bayesian Chemical Mass Balance using MCMC sampling.
bool ExecuteDFAM(const std::map< std::string, std::string > &arguments)
Executes multi-way Discriminant Function Analysis across all groups.
bool ExecuteDFA(const std::map< std::string, std::string > &arguments)
Executes Discriminant Function Analysis between two groups.
bool ExecuteSDFAM(const std::map< std::string, std::string > &arguments)
Executes multi-way Stepwise Discriminant Function Analysis across all groups.
bool ExecuteBoxCox(const std::map< std::string, std::string > &arguments)
Calculates optimal Box-Cox transformation parameters.
bool ExecuteKolmogorovSmirnovIndividual(const std::map< std::string, std::string > &arguments)
Executes Kolmogorov-Smirnov test for a single constituent in a group.
bool CheckNegativeElements(SourceSinkData *data=nullptr)
Validates that all element concentrations are non-negative.
bool ExecuteCMBBayesianBatch(const std::map< std::string, std::string > &arguments)
Executes Bayesian Chemical Mass Balance across all target samples.
bool ExecuteAutoSelect(const std::map< std::string, std::string > &arguments)
Executes automatic element selection based on discriminant power.
bool ExecuteSDFA(const std::map< std::string, std::string > &arguments)
Executes Stepwise Discriminant Function Analysis between two groups.
bool ExecuteBracketingAnalysisBatch(const std::map< std::string, std::string > &arguments)
Executes bracketing analysis across all target samples.
bool ExecuteANOVA(const std::map< std::string, std::string > &arguments)
Executes Analysis of Variance (ANOVA) for element discrimination.
AnalysisHost * host
Non-owning pointer to the running environment.
QString workingfolder
Output directory path.
std::unique_ptr< CGA< SourceSinkData > > GA
Genetic Algorithm optimizer (owned)
bool ExecuteGA_NoTargets(const std::map< std::string, std::string > &arguments)
Executes Genetic Algorithm disregarding target constraints.
bool ExecuteGA(const std::map< std::string, std::string > &arguments)
Executes Genetic Algorithm optimization.
bool ExecuteSourceVerify(const std::map< std::string, std::string > &arguments)
Executes source verification analysis.
bool ExecuteGA_FixedProfile(const std::map< std::string, std::string > &arguments)
Executes Genetic Algorithm with fixed elemental profiles.
bool ExecuteMLR(const std::map< std::string, std::string > &arguments)
Executes multiple linear regression versus organic matter and particle size.
Conductor(AnalysisHost *host)
Constructs a Conductor that reports through host.
bool ExecuteDistributionFitting(const std::map< std::string, std::string > &arguments)
Executes distribution fitting analysis for a constituent.
bool ExecuteLevenbergMarquardtBatch(const std::map< std::string, std::string > &arguments)
Executes Levenberg-Marquardt optimization across all target samples.
bool ExecuteKolmogorovSmirnov(const std::map< std::string, std::string > &arguments)
Executes Kolmogorov-Smirnov goodness-of-fit test for a source/target group.
bool ExecuteErrorAnalysis(const std::map< std::string, std::string > &arguments)
Executes bootstrap error analysis for uncertainty quantification.
SourceSinkData * Data()
Returns pointer to the current SourceSinkData.
SourceSinkData * data
Non-owning pointer to analysis data.
bool ExecuteSDFAOnevsRest(const std::map< std::string, std::string > &arguments)
Executes Stepwise Discriminant Function Analysis for one group versus all others.
bool Execute(const std::string &command, std::map< std::string, std::string > arguments)
Executes a specified analysis command with given parameters.
bool ExecuteBracketingAnalysis(const std::map< std::string, std::string > &arguments)
Executes bracketing analysis for a single target sample.
bool ExecuteDFAOnevsRest(const std::map< std::string, std::string > &arguments)
Executes Discriminant Function Analysis for one group versus all others.
bool ExecuteCovarianceMatrix(const std::map< std::string, std::string > &arguments)
Calculates covariance matrix for a source or target group.
Results results
Current analysis results (cleared each Execute)
bool ExecuteOMSizeCorrect(const std::map< std::string, std::string > &arguments)
Executes organic matter and particle size correction.
bool ExecuteLevenbergMarquardt(const std::map< std::string, std::string > &arguments)
Executes Levenberg-Marquardt nonlinear optimization.
bool ExecuteEDP(const std::map< std::string, std::string > &arguments)
Calculates two-way element discriminant power between two groups.
bool ExecuteEDPM(const std::map< std::string, std::string > &arguments)
Calculates multi-way element discriminant power across all groups.
bool ExecuteCorrelationMatrix(const std::map< std::string, std::string > &arguments)
Calculates correlation matrix for a source or target group.
std::unique_ptr< CMCMC< SourceSinkData > > MCMC
MCMC sampler (owned)
Manages a collection of elemental profiles (samples) for source fingerprinting analysis.
Elemental_Profile SelectTopElementsAggregate(int n) const
Select top N elements across all samples (aggregate minimum)
Container for elemental concentration data of a single sediment sample.
vector< string > GetElementNames() const
Get list of all element names.
options & GetOptions()
Get reference to the options structure.
void SetOption(options_key opt, bool val)
Set a configuration option.
void SetLimit(_range lowhigh, const double &value)
Set upper or lower limit for value highlighting.
virtual void Start()
Makes the reporter visible or otherwise begins reporting.
virtual void SetYAxisTitle(const QString &title, int chart=0)=0
Sets the vertical axis title of a chart.
virtual void SetProgress(const double &prog)=0
Sets the primary progress fraction.
virtual void SetTitle(const QString &title, int chart=0)=0
Sets the title of a chart.
void SetAbsoluteValue(bool val)
void SetShowGraph(bool state)
void setYAxisTitle(const string &title)
void SetXAxisMode(xaxis_mode mode)
void SetYLimit(_range highlow, const double &value)
void setTableTitle(const string &Title)
void SetName(const string &_name)
void SetResult(Interface *_result)
void SetShowTable(bool state)
void setXAxisTitle(const string &title)
void SetYAxisMode(yaxis_mode mode)
void SetShowAsString(bool value)
void SetType(const result_type &_type)
void Append(const ResultItem &)
void SetName(const string &_name)
Holds a progress reporter for the duration of one analysis.
bool InitializeParametersAndObservations(const string &targetsamplename, estimation_mode est_mode=estimation_mode::elemental_profile_and_contribution)
Initialize parameters and observations for MCMC optimization.
bool PerformRegressionVsOMAndSize(const string &om, const string &particle_size, regression_form form, const double &p_value_threshold=0.05)
Performs multiple linear regression of elements vs OM and particle size.
Elemental_Profile_Set DifferentiationPower_Percentage(bool include_target)
Computes rank-based differentiation percentage for all source pairs.
CMBTimeSeriesSet BootStrap(const double &percentage, unsigned int num_iterations, string target_sample, bool use_softmax)
Performs bootstrap uncertainty analysis on source contributions.
SourceSinkData ExtractChemicalElements(bool isotopes) const
Extract only chemical elements (and optionally isotopes)
CMBVector ANOVA(bool use_log)
Performs one-way ANOVA for all elements across source groups.
bool SolveLevenberg_Marquardt(transformation trans=transformation::linear)
Solves for optimal source contributions using the Levenberg-Marquardt algorithm.
vector< CMBVector > StepwiseDiscriminantFunctionAnalysis(const string &source1, const string &source2)
Performs stepwise discriminant analysis between two specific sources.
ConcentrationSet * GetElementDistribution(const string &element_name)
Retrieves pointer to element distribution at dataset level.
SourceSinkData BoxCoxTransformed(bool calculate_optimal_lambda=false)
Applies Box-Cox transformation to all source groups for normalization.
void SetParameterEstimationMode(estimation_mode est_mode)
Sets the estimation mode for parameter optimization.
Elemental_Profile t_TestPValue(const string &source1, const string &source2, bool use_log)
Computes t-test p-values for element-wise differences between two sources.
vector< ResultItem > GetMLRResults()
Retrieves multiple linear regression results for all sample groups.
CMBVector BracketTest(const string &target_sample, bool correct_based_on_om_n_size)
Performs bracket test to check if target concentrations fall within source ranges.
void IncludeExcludeElementsBasedOn(const vector< string > &elements)
Sets element inclusion based on a specified list.
ResultItem GetPredictedElementalProfile(parameter_mode param_mode=parameter_mode::based_on_fitted_distribution)
Generates predicted elemental concentrations for the target sample.
void SetOMandSizeConstituents(const string &_omconstituent, const string &_sizeconsituent)
Sets the names of OM and particle size constituents.
SourceSinkData CreateCorrectedAndFilteredDataset(bool exclude_samples, bool exclude_elements, bool omnsizecorrect, const string &target="") const
Create a corrected and filtered copy of the dataset.
vector< string > NegativeValueCheck()
Checks for zero or negative concentration values across all sources.
CMBTimeSeriesSet VerifySource(const string &source_group, bool use_softmax, bool apply_om_size_correction)
Performs leave-one-out validation on a source group.
bool SetSelectedTargetSample(const string &sample_name)
Sets the currently selected target sample for analysis.
void AddtoToolsUsed(const string &tool)
Adds a tool name to the list of tools used in analysis.
DFA_result DiscriminantFunctionAnalysis()
Performs discriminant function analysis for all source groups.
vector< ResultItem > GetSourceProfiles()
Retrieves elemental profiles for all source groups.
Results MCMC(const string &target_sample, map< string, string > arguments, CMCMC< SourceSinkData > *mcmc, ProgressReporter *progress_window, const string &working_folder)
Performs Markov Chain Monte Carlo analysis for Bayesian source apportionment.
Elemental_Profile_Set DifferentiationPower(bool use_log, bool include_target)
Computes differentiation power for all source pairs.
SourceSinkData CreateCorrectedDataset(const string &target, bool omnsizecorrect, map< string, element_information > *elementinfo)
Create a corrected copy of the dataset for a specific target sample.
ResultItem GetObservedvsModeledElementalProfile(parameter_mode param_mode=parameter_mode::based_on_fitted_distribution)
Creates a comparison of observed vs modeled elemental profiles.
string GetTargetGroup() const
Retrieves the name of the target group.
Elemental_Profile_Set DifferentiationPower_P_value(bool include_target)
Computes t-test p-values for all source pairs.
ResultItem GetContribution()
Packages source contributions into a ResultItem for output.
ResultItem GetObservedvsModeledElementalProfile_Isotope(parameter_mode param_mode=parameter_mode::based_on_fitted_distribution)
Creates a comparison of observed vs modeled isotope delta values.
vector< string > OMandSizeConstituents()
Retrieves the names of OM and particle size constituents.
void SetProgressReporter(ProgressReporter *_rtw)
Sets the progress window for displaying optimization progress.
void InitializeParametersObservations(const vector< double > &mins, const vector< double > &maxs)
@ direct
Use empirical statistics from data.
distribution_type
Enumeration of probability distribution types supported in SedSat3.
@ lognormal
Lognormal distribution: ln(x) ~ N(μ, σ²), for strictly positive variables.
@ normal
Normal (Gaussian) distribution: p(x) = N(μ, σ²)
@ single_column_x
Enable single-column mode for X-axis data representation.
@ low
Lower bound of the parameter range.
@ high
Upper bound of the parameter range.
@ predicted_concentration
@ timeseries_set_first_symbol
@ source_elemental_profiles_based_on_source_data
CMBVectorSet eigen_vectors
CMBVectorSetSet multi_projected
QString X_suffix
Suffix appended to X-axis field names in serialization.
QString Y_suffix
Suffix appended to Y-axis field names in serialization.