float PhaseEstimator::EvaluateParameters(vector<BasecallerRead *>& useful_reads, DPTreephaser& treephaser, const float *parameters, const bool usePIDNorm) { float try_cf = parameters[0]; float try_ie = parameters[1]; float try_dr = parameters[2]; if (try_cf < 0 or try_ie < 0 or try_dr < 0 or try_cf > 0.04 or try_ie > 0.04 or try_dr > 0.01) return 1e10; treephaser.SetModelParameters(try_cf, try_ie, try_dr); float metric = 0; for (vector<BasecallerRead *>::iterator read = useful_reads.begin(); read != useful_reads.end(); ++read) { treephaser.Simulate(**read, 120); float normalizer = (usePIDNorm ? treephaser.PIDNormalize(**read, 8, 100) : treephaser.Normalize(**read, 20, 100)); for (unsigned int flow = 20; flow < 100 and flow < (*read)->raw_measurements.size(); flow++) { if ((*read)->raw_measurements[flow] > 1.2) continue; float delta = (*read)->raw_measurements[flow] - (*read)->prediction[flow] * normalizer; metric += delta * delta; } } return isnan(metric) ? 1e10 : metric; }
float PhaseEstimator::EvaluateParameters(vector<BasecallerRead *>& useful_reads, DPTreephaser& treephaser, const float *parameters) { float try_cf = parameters[0]; float try_ie = parameters[1]; float try_dr = parameters[2]; if (try_cf < 0 or try_ie < 0 or try_dr < 0 or try_cf > 0.04 or try_ie > 0.04 or try_dr > 0.01) return 1e10; treephaser.SetModelParameters(try_cf, try_ie, try_dr); float metric = 0; for (vector<BasecallerRead *>::iterator read = useful_reads.begin(); read != useful_reads.end(); ++read) { // Simulate phasing parameter treephaser.Simulate(**read, phasing_end_flow_+20); // Optionally determine optimal normalization for this parameter set? if (norm_during_param_eval_) NormalizeBasecallerRead(treephaser, **read, phasing_start_flow_, phasing_end_flow_); // Determine squared distance penalty for this parameter set for (int flow = phasing_start_flow_; flow < phasing_end_flow_ and flow < (int)(*read)->raw_measurements.size(); ++flow) { if ((*read)->raw_measurements[flow] > inclusion_threshold_) continue; // Keep key normalized raw measurements as a constant and normalize predictions towards key normalized values float delta = ((*read)->normalized_measurements[flow] - (*read)->prediction[flow]) * (*read)->multiplicative_correction[flow]; metric += delta * delta; } } return isnan(metric) ? 1e10 : metric; }
float RegionAnalysis::evaluateParameters(std::vector<BasecallerRead> &dataAll, DPTreephaser& treephaser, float *parameters) { float metric = 0; if (clo->cfe_control.libPhaseEstimator == "nel-mead-treephaser") { if (parameters[0] < 0) // cf metric = 1e10; if (parameters[1] < 0) // ie metric = 1e10; if (parameters[2] < 0) // dr metric = 1e10; if (parameters[0] > 0.04) // cf metric = 1e10; if (parameters[1] > 0.04) // ie metric = 1e10; if (parameters[2] > 0.01) // dr metric = 1e10; if (metric == 0) { treephaser.SetModelParameters(parameters[0], parameters[1], parameters[2]); for (std::vector<BasecallerRead>::iterator data = dataAll.begin(); data != dataAll.end(); data++) { treephaser.Simulate3(*data, 120); data->Normalize(20, 100); for (int iFlow = 20; iFlow < std::min(100, data->numFlows); iFlow++) { if (data->measurements[iFlow] > 1.2) continue; float delta = data->measurements[iFlow] - data->prediction[iFlow] * data->miscNormalizer; metric += delta * delta; } } } } else if (clo->cfe_control.libPhaseEstimator == "nel-mead-adaptive-treephaser") { if (parameters[0] < 0) // cf metric = 1e10; if (parameters[1] < 0) // ie metric = 1e10; if (parameters[0] > 0.04) // cf metric = 1e10; if (parameters[1] > 0.04) // ie metric = 1e10; if (metric == 0) { treephaser.SetModelParameters(parameters[0], parameters[1], 0); for (std::vector<BasecallerRead>::iterator data = dataAll.begin(); data != dataAll.end(); data++) { // treephaser.Simulate3(*data, 150); // data->AdaptiveNormalizationOfPredictions(3, 50); treephaser.Simulate3(*data, 200); data->AdaptiveNormalizationOfPredictions(4, 50); for (int iFlow = 25; iFlow < std::min(175, data->numFlows); iFlow++) { if (data->measurements[iFlow] > 1.2) continue; float delta = data->measurements[iFlow] - data->prediction[iFlow]; metric += delta * delta; } } } } // printf("CF = %1.2f%% IE = %1.2f%% DR = %1.2f%% V = %1.6f\n", // 100*parameters[0], 100*parameters[1], 100*parameters[2], metric); if (isnan(metric)) metric = 1e10; return metric; }