Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

commenting GAPSRunner.cpp #106

Merged
merged 1 commit into from
May 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 19 additions & 2 deletions src/GapsRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#pragma GCC diagnostic pop
#endif

// library allowing for message passing in distributed mode
#ifdef __GAPS_OPENMP__
#include <omp.h>
#endif
Expand Down Expand Up @@ -53,7 +54,8 @@ struct GapsTime
}
};

// forward declaration
// forward declaration for running the CoGAPS algorithm across that can be
// defined for different classes of input data to be defined
template <class Sampler, class DataType>
static GapsResult runCoGAPSAlgorithm(const DataType &data, GapsParameters &params,
const DataType &uncertainty, GapsRandomState *randState);
Expand Down Expand Up @@ -105,7 +107,8 @@ const DataType &uncertainty, GapsRandomState *randState)
}

// these two functions are the top-level functions exposed to the C++
// code that is being wrapped by any given language
// code that is being wrapped by any given language for the
// interface (e.g., R, python, etc)

GapsResult gaps::run(const Matrix &data, GapsParameters &params,
const Matrix &uncertainty, GapsRandomState *randState)
Expand All @@ -131,6 +134,8 @@ static double estimatedNumUpdates(double current, double total, float nAtoms)
total * coef * std::log(total) - total * coef;
}

// function to return status update and number of iterations for
// the sampler as CoGAPS runs
template <class Sampler>
static double estimatedPercentComplete(const GapsParameters &params,
const Sampler &ASampler, const Sampler &PSampler, GapsAlgorithmPhase phase, unsigned iter)
Expand All @@ -152,6 +157,7 @@ const Sampler &ASampler, const Sampler &PSampler, GapsAlgorithmPhase phase, unsi
return estimatedCompleted / estimatedTotal;
}

// function to display status update during the CoGAPS run
template <class Sampler>
static void displayStatus(const GapsParameters &params,
const Sampler &ASampler, const Sampler &PSampler, bpt::ptime startTime,
Expand All @@ -162,10 +168,16 @@ GapsAlgorithmPhase phase, unsigned iter, GapsStatistics &stats)
float cs = PSampler.chiSq();
unsigned nA = ASampler.nAtoms();
unsigned nP = PSampler.nAtoms();

// chi^2 fit to data
stats.addChiSq(cs);

// number of atoms
stats.addAtomCount(nA, nP);

if (params.printMessages)
{
// estimate run time to output
bpt::time_duration diff = bpt_now() - startTime;
double perComplete = estimatedPercentComplete(params, ASampler,
PSampler, phase, iter);
Expand Down Expand Up @@ -282,7 +294,12 @@ GapsRng &rng, bpt::ptime startTime, GapsAlgorithmPhase phase, unsigned &currentI

if (phase == GAPS_SAMPLING_PHASE)
{
// update the statistics based on the A and P matrices
stats.update(ASampler, PSampler);

// flag to implement developmental statistic called PUMP
// which computes pattern markers for prioritizing gene markers
// computed along the chain as part of the MCMC sampling
if (params.takePumpSamples)
{
stats.updatePump(ASampler);
Expand Down