Skip to content

Commit

Permalink
Merge pull request #106 from FertigLab/104-refactor-add-comments
Browse files Browse the repository at this point in the history
commenting GAPSRunner.cpp
  • Loading branch information
dimalvovs committed May 24, 2024
2 parents cc8c42c + e8ee54b commit 007432d
Showing 1 changed file with 19 additions and 2 deletions.
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

0 comments on commit 007432d

Please sign in to comment.