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

More MSCombo tweaks #23

Merged
merged 13 commits into from
Nov 2, 2023
10 changes: 7 additions & 3 deletions src/code_base/bmds_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -542,12 +542,14 @@ double getclmt(python_multitumor_analysis *pyAnal, python_multitumor_result *pyR

lb[0] = lminbmd; //BMD lower limit
for (int i=1; i<x.size(); i++){
lb[i] = pyAnal->prB[3]; //beta min value
//lb[i] = pyAnal->prB[3]; //beta min value
lb[i] = 0.0; //beta min value
}

ub[0] = log(maxDose);
for (int i=1; i<x.size(); i++){
ub[i] = pyAnal->prB[4]; //beta max value
//ub[i] = pyAnal->prB[4]; //beta max value
ub[i] = 1e4; //beta max value
}

local_opt.set_lower_bounds(lb);
Expand Down Expand Up @@ -4010,7 +4012,9 @@ void BMDS_ENTRY_API __stdcall runMultitumorModel(struct python_multitumor_analys
for (int j=0; j<pyAnal->nmodels[i]; j++){
double bmr = pyAnal->models[i][j].BMR;
double bmdl = pyRes->models[i][j].bmdsRes.BMDL;
pyRes->models[i][j].bmdsRes.slopeFactor = bmr/bmdl;
if (bmdl > 0.0){
pyRes->models[i][j].bmdsRes.slopeFactor = bmr/bmdl;
}
}
}

Expand Down
4 changes: 1 addition & 3 deletions src/code_base/bmds_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,6 @@ struct python_multitumor_analysis{
double alpha; // alpha of the analysis
int prior_cols; // colunns in the prior
std::vector<int> degree; // degree of selected polynomial used for each ind multistage (size ndatasets)
std::vector<double> prG; //background prior
std::vector<double> prB; //beta prior
};

struct python_multitumor_result{
Expand Down Expand Up @@ -407,7 +405,7 @@ void convertFromPythonDichoRes(struct dichotomous_model_result *res, struct pyth

void selectMultitumorModel();

void runMultitumorModel(struct python_multitumor_analysis *pyAnal, struct python_multitumor_result *pyRes);
void BMDS_ENTRY_API __stdcall runMultitumorModel(struct python_multitumor_analysis *pyAnal, struct python_multitumor_result *pyRes);

double DLgamma(double x);
double LogLik_Constant(std::vector<double> Y, std::vector<double> n_group);
Expand Down
5 changes: 1 addition & 4 deletions src/pybmdscpp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,7 @@ PYBIND11_MODULE(bmdscore, m) {
.def_readwrite("BMR", &python_multitumor_analysis::BMR)
.def_readwrite("alpha", &python_multitumor_analysis::alpha)
.def_readwrite("prior_cols", &python_multitumor_analysis::prior_cols)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cwsimmon can we delete prior_cols too - is that no longer needed as well?

.def_readwrite("degree", &python_multitumor_analysis::degree)
.def_readwrite("prG", &python_multitumor_analysis::prG)
.def_readwrite("prB", &python_multitumor_analysis::prB);
// .def_readwrite("prior", &python_multitumor_analysis::prior);
.def_readwrite("degree", &python_multitumor_analysis::degree);
py::class_<python_multitumor_result>(m, "python_multitumor_result")
.def(py::init<>())
.def_readwrite("ndatasets", &python_multitumor_result::ndatasets)
Expand Down
14 changes: 5 additions & 9 deletions src/tests/src/test_cpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4252,9 +4252,6 @@ void runMultitumorModel(){
anal.alpha = alpha;
anal.prior_cols = prCols;

anal.prG.insert(anal.prG.begin(), prRFreqMultistageCancerG, prRFreqMultistageCancerG + anal.prior_cols);
anal.prB.insert(anal.prB.begin(), prRFreqMultistageCancerB, prRFreqMultistageCancerB + anal.prior_cols);

struct python_multitumor_result res;
res.ndatasets = numDatasets;

Expand Down Expand Up @@ -4293,7 +4290,6 @@ void runMultitumorModel(){
modAnal.doses = doses[dataset];
modAnal.n = numDataRows;

std::cout<<"b4 if"<<std::endl;
//needs to be changed based on model degree
if (degree[dataset] == 0){
//handle autoselect degree
Expand All @@ -4316,7 +4312,6 @@ void runMultitumorModel(){
count = 1;
}

std::cout<<"after if"<<std::endl;
anal.nmodels.push_back(count);
anal.models.push_back(modGroup);
res.nmodels.push_back(count);
Expand All @@ -4328,10 +4323,11 @@ void runMultitumorModel(){
res.selectedModelIndex.push_back(0);
res.selectedModelIndex.push_back(0);
std::cout<<"Selected model Indexes: ";
for (auto elem : res.selectedModelIndex) {
std::cout << elem << ", ";
}
std::cout<<std::endl;
//for (auto elem : res.selectedModelIndex) {
// std::cout << elem << ", ";
//}
//std::cout<<std::endl;

res.validResult.push_back(true);
res.validResult.push_back(true);
res.validResult.push_back(true);
Expand Down