TangSoftwareLab / SynergyFinderR

SynergyFinder R package development
https://www.bioconductor.org/packages/release/bioc/html/synergyfinder.html
Mozilla Public License 2.0
1 stars 1 forks source link

PredictResponse error #3

Closed jonkatz2 closed 1 year ago

jonkatz2 commented 2 years ago

Excellent package! I have been using the package for about a year, but last week I updated and this function no longer works. Try this example:

resp <- as.data.frame(matrix(c(
1e-04, -28.77,
1e-03, -11.37,
1e-02, -25.73,
1e-01, -0.73,
1e+00, 7.99,
1e+01, 32.89,
1e-04, -10.99,
1e-03, 10.17,
1e-02, 1.71,
1e-01, 9.46,
1e+00, 12.84,
1e+01, 31.92,
1e-04, -7.45,
1e-03, -4.29,
1e-02, -17.11,
1e-01, 2.69,
1e+00, 13.90,
1e+01, 52.33,
1e-04, 2.81,
1e-03, 9.37,
1e-02, 16.24,
1e-01, 20.75,
1e+00, 25.97,
1e+01, 49.88,
1e-05, 12.28,
1e-05, 2.15,
1e-05, -2.01,
1e-05, 3.11,
1e-05, -3.56,
1e-05, -7.40,
1e-05, -0.38,
1e-05, -4.19
), ncol=2, byrow=TRUE, dimnames=list(NULL, c('dose', 'response'))))

PredictResponse(df=resp, dose=unique(resp$dose))
## Error in if (pred > 100) { : the condition has length > 1

Maybe it should be if(length(pred) > 100)? For now I am just calling drc::drm() directly, so not an emergency.

shuyuzheng commented 2 years ago

Thanks @jonkatz2 for reporting this error! The fuction PredictResponse was designed as an auxiliary function in R package and we only considered about the situation where one values is assigned to parameter dose. That's why there was an error while a vector of dosages was given.

I think it's resonable to allowing for predicting response values for multiple dosages at one calling, so I have modified the source code for the package. It is ok to run the codes PredictResponse(df=resp, dose=unique(resp$dose)) with the package version > 3.4.1.

NOTE: The output from this function would be a little bit different from the prediction function from drc::drm(), when the predicted response value for the given dosage is larger than 100. PredictResponse function adjusts all the response values (which are larger than 100) to 100 + stats::runif(1, -0.01, 0). All of the response values less than or equal to 100 will not be adjusted.