-
Notifications
You must be signed in to change notification settings - Fork 29
Return fit info from half.life calculation #339
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
Conversation
|
@roninsightrx, thanks for providing the code. Can you please clarify the motivating example? Is the core need to get the residuals or the intercept, or something else? With I hesitate to add a fit object to the outputs by default because sometimes people use PKNCA for simulation results with 10,000+ individuals. The fit could be large in memory in such cases. It would be preferred to have an optional return rather than returning by default. |
|
The reason is that I need to be able to inspect the fits done within PKNCA, to possibly manual remove outliers based on fit plots, or potentially change the adjusted r-squared threshold. I was actually surprised that this was not included already in PKNCA. I don't do a lot of NCAs myself, but some folks mentioned this is a required step in the NCA process for filings. Also Phoenix and PKanalix have this option, see e.g. screenshot from this PKanalix tutorial. To create those same plots I mostly need the intercept and slope from the fit. The other data I put in the attribute is mostly for convenience, but I could see the impact on speed that would have. Would you be more open to the second option I mentioned: to (optionally) store just the 2 coefficients from the fit in the data.frame. This would avoid having to add attributes to the data.frame. It would just mean a little more data processing on the user-end afterwards, but I could live with that.
|
|
O wait, now I see that with the variables you mention I can reconstruct the curve as well. I didn't realize I did have all the information. Let me explore that. |
|
Yes, managed to do it with existing data. Thanks a bunch! Below is what I used to generate the plots, perhaps would be nice to include in one of the vignettes for other users that are looking for this? Could even imagine having something like an |
|
I'm glad that you were able to make it work for you! FYI, your code will work for parallel studies, but it won't work for crossover studies or studies with additional analytes (e.g. metabolites). You'll want to use grouping variables. A long time ago, I had a lot of visualizations, but most of the comments that PKNCA received related to minor formatting differences such as wanting to change colors. So, those were removed. Based on some upcoming work, I expect that visualizations will come back into PKNCA. As an aside, I would recommend some changes to future-proof your PKNCA-related code:
Both of those are long-term stable, while using the |
|
Thanks Bill for the context and pointers! |
|
I am planning to add plotting, table, and figure generation to a separate package. PKNCA will stay focused on the calculations; a related package will be created for reporting. |
|
I had to do something similar in my project. I couldn't see how to get the intercept from the output like @roninsightrx did and ended up re-doing the the lambda.z regression for each patient (I didn't have that many). I did this b/c I wanted to interpolate some data into the analysis (sponsor wanted AUC to a timepoint that wasn't actually collected) and better or worse this is what I did. Whether this is a good idea or not (or maybe there is some existing functionality that I don't know about) I think it would be nice have API available to do this. |
|
Here's a benefit of using GitHub. A feature that I didn't know people wanted or needed is helpful, and the community is coming together to talk about it. I'll open an issue and tag you both in it to work through the specifics. @kylebaron, FYI, the |
|
Thanks, @billdenney ; I suspected there was something in there (I expect this to be pretty tricked out since it's coming from you), but burned enough of your time asking super basic questions. With the deadline and inheriting some legacy code, it really was easier to roll my own on this one and figure out the power features another day. You can tell how much NCA I do (!) but will definitely take time to check into this for the next time around. Thanks for all of your work on PKNCA and interacting with users on GitHub. I agree ... I love having this platform for seeing what others are doing. I always learn something new! |


Hi @billdenney , this is a PR for allowing the return of individual fit info from the half-life fits in the NCA. This is something I absolutely need for a project I’m working on, but I think it’s very useful info to have in general for PKNCA users, both for checking/confirming correct lambda-z/half-life calculation manually, and e.g. for inclusion in reports. Let me know what you think.
Since the data that needs to be returned from the half-life calculation won’t fit in the current data units passed between the functions (data.frames) I instead attached it to the core data units as attribute. This seems to me the easiest option here, but let me know what you think. If you prefer not to use attributes, an alternative option is to just pass back the coefficients from the fit in the existing data.frame. Then at least the curve fits can be re-constructed afterwards, although it’s not as convenient to the user.
FYI, this PR is a work-in-progress, just wanted to see if this aligns with your ideas for the package. Will do some more testing and add unit tests if you agree with the overall approach.
Below is a minimal example. Thanks