-
Notifications
You must be signed in to change notification settings - Fork 51
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
include pk properties for population simulations #2227
include pk properties for population simulations #2227
Conversation
@PavelBal: Just created a PR for easier revision but still in progress. Currently, it uses the mean for the population global PK. It also expects the user to select the [peripheral] venous blood plasma as an output. Still missing the second option for the normal PK. |
FYI @Open-Systems-Pharmacology/suite-core-developers This should not be merged before we release v11 |
I do not think it will be ready before we release. Still pending some logic plus tests |
Well.. who knows 😉 |
Well, I hope the release does not get that much delayed lol |
@msevestre, @Yuri05 and @georgeDaskalakis: Tests are green now but there are missing tests on the new logic. You could though start taking a look on the PR if you like so we do not end up with a huge set of changes. If at some point you do review the PR then I will start to add new incremental features by new PR on these branch instead of committing directly to it so it will be easier to review. For now, the new tests I will commit directly unless you tell me me not to do it since you are reviewing so I start already with the new PRs policy. |
@@ -37,7 +37,7 @@ private void addAnalysisToTable(PopulationPKAnalysis analysis, DataTable dataTab | |||
|
|||
private string getCurveName(PopulationPKAnalysis analysis) | |||
{ | |||
return analysis.CurveData.Caption; | |||
return analysis.CurveData.Caption + analysis.ExtraDescription; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use string interpolation instead of concatenating strings. Not a big deal here but just something to simply do all the time so that strings are not allocated for nothing
return true; | ||
|
||
return simulation.IsAnImplementationOf<PopulationSimulation>(); | ||
return individualSimulationContainsColumn(dataColumn, simulation); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't quite understand this change. Seems to be equivalent to me?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For what I have seen in the code, when we receive a population simulation the DataInfo.Origin is not properly set. My thought was that for the case of populations it is not meaningful (or at least in this case) but as we discussed, it makes sense to see why it has not been set. So the change is indeed very similar but the only difference is that for population simulations it will not check the origin at all. Before it would return false always. I will still check why the origin is not been set.
|
||
public IndividualSimulation() | ||
public IndividualSimulation() : base() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
calling base() is not required. Remove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not? There is some code in the base constructor that needs to be executed still. More specifically
_compoundPKCache = new Cache<string, CompoundPK>(x => x.CompoundName, x => new CompoundPK());
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the base() constructor is always called....or am I missing something?
@@ -113,5 +70,23 @@ public override void AcceptVisitor(IVisitor visitor) | |||
if(HasResults) | |||
DataRepository.AcceptVisitor(visitor); | |||
} | |||
|
|||
public override DataColumn PeripheralVenousBloodColumn(string compoundName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inline all of this for readability. They are just forward
methods
} | ||
|
||
public virtual IEnumerable<SimulationTimeProfileChart> TimeProfileAnalyses => Analyses.OfType<SimulationTimeProfileChart>(); | ||
|
||
public void ClearPKCache() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@abdelr It would be good to comment a bit on PR. I have no idea why this is removed. This has nothing to do with pk properties for simulations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was moved to the base class so population simulation can also use it.
@@ -24,7 +24,7 @@ public class PopulationSimulation : Simulation, IPopulationDataCollector, IAdvan | |||
|
|||
public virtual AgingData AgingData { get; } | |||
|
|||
public PopulationSimulation() | |||
public PopulationSimulation() : base() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove base. This is always called
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough
@@ -279,5 +279,65 @@ public override void UpdateFromOriginalSimulation(Simulation originalSimulation) | |||
var sourcePopSimulation = originalSimulation as PopulationSimulation; | |||
sourcePopSimulation?.AdvancedParameters.Each(x => AddAdvancedParameter(x, generateRandomValues: true)); | |||
} | |||
|
|||
private DataColumn aggregateDataColumns(IEnumerable<DataColumn> columns) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this outside of the simulation. This is clearly some kind of an extension methods. We have quite a few to calculate "aggregates" stuff already
|
||
private DataColumn aggregateDataColumns(IEnumerable<DataColumn> columns) | ||
{ | ||
var column = columns.First(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will crash if there is no items. Clearly you are suspecting that this might be null see line below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does first mean? We need to comment this type of code BTW.
Do not comment the obvious, but if it is not obvious, comment
return aggregateDataColumns(drugColumnFor(CoreConstants.Organ.LUMEN, CoreConstants.Observer.FABS_ORAL, CoreConstants.Observer.FABS_ORAL, compoundName)); | ||
} | ||
|
||
private IEnumerable<DataColumn> drugColumnFor(string organ, string compartment, string columnName, string compoundName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is columnName? Also compoundName is not used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch... compoundName should be used
src/PKSim.Core/Model/Simulation.cs
Outdated
@@ -19,6 +20,25 @@ public abstract class Simulation : PKSimBuildingBlock, ISimulation, IWithChartTe | |||
private readonly List<ISimulationAnalysis> _allSimulationAnalyses = new List<ISimulationAnalysis>(); | |||
private SimulationProperties _properties; | |||
private SimulationResults _results; | |||
private readonly ICache<string, CompoundPK> _compoundPKCache; | |||
|
|||
public virtual DataColumn PeripheralVenousBloodColumn(string compoundName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be abstract. But I am actually not sure that this belongs here at all. Why are we implementing something specific for just a few outputs? Does not make much sense to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was already defined at IndividualSimulation and although you are right, it makes some sense since we are using this specific combination ([peripheral] blood plasma) a lot. It could be on a service though but keep in mind that it is extracted differently at Population/Individual Simulation. Also, it was not abstract since there are more implementations of Simulation and there it is not required but again, makes sense that it is abstract here and only on the concrete implementations we decide whether it returns something or not.
} | ||
|
||
private double? compoundPKValue(string compoundName, Func<CompoundPK, double?> pkValueFunc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this moved to the base class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So it is used by both Individual/Population Simulation. There could be one class between Simulation and Population/Individual Simulation but it sounds like an overshooting to me.
var allColumns = timeProfileChartData.Panes.SelectMany(x => x.Curves).Select(x => | ||
new {curveData = x, column = columnFor(x, populationDataCollector)}) | ||
.Where(c => c.column != null) | ||
var allColumns = timeProfileChartData.Panes.SelectMany(x => x.Curves).SelectMany(x => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It refers to range results. Before range results only contained a single result by now it is calculated at both ends so the 5 and 95 % for example instead of 5% only.
|
||
public PopulationPKAnalysis(CurveData<TimeProfileXValue, TimeProfileYValue> curveData, PKAnalysis pkAnalysis) | ||
public PopulationPKAnalysis(CurveData<TimeProfileXValue, TimeProfileYValue> curveData, PKAnalysis pkAnalysis, string extraDescription = "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
string,empty
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compiler complains, it needs to be a compile time constant
|
||
return new[] | ||
{ | ||
new DataColumn("", curveData.YAxis.Dimension, baseGrid) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
string,empty
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to understand what is going on here. I do not see in the #2021 issue some of the stuff matching the implementation and therefore I have no idea why this was changed
oK i see where the request to move stuff comes from
|
All in all, I think this goes in the right direction. I am hesitant of putting specific curves selections just for the sake of being used in one service somewhere. Maybe this belongs to the service instead. The aggregate methods implementation looks like we have it somewhere already. If not, we have code that manipulates array so this probably belongs here. (just to follow the overall implementation) |
35513c8
to
9fc74f9
Compare
* Filter body weight dependent rows from population PK values * Using values instead of names to filter * rewriting for easier reading * rephrasing for better reading * No need for the two methods anymore
e1e5c3e
to
fc64d08
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No remarks from user perspective any more.
Plase create a feature request for including "Global" PK-Parameters into the box-plot/scatter plot.
* UI changes * Without aggregation * Working with loooots of code duplication :( * Logic implemented using stored PKValues per individual * Removing last code duplication and unused error variable * Using real actual administration mode * simplifying names * Misc changes * Testing float matrix * Testing aggregate function * Revert "simplifying names" This reverts commit f3158d5. * Making names the same for individual and populations * Binding to an unique DTO * Fixing test * Making sure data is sorted * Refactoring upper/lower suffixes * Renaming pks * Some code beautifying and a more robust cast to PopulationSimulation * Adding tooltips * Changes from code review * partial commit before rebasing * Show message when no pk values * Toogle components depending on data * Using built in function * Bind on tab changed to refresh to current data * Refactoring logic from ChartsDataCreator * Calculate bioavailability * some misc changes * Moving logic from presenter * refactoring * missing file from last commit * Renaming xtraTabPages * Adding icons & undoing a bug from last commit * Rephrasing label a bit. * Showing label "Values calculated for the mean population curve" * Adding comment to explain why the need for rebinding
@abdelr I thought this was merged already? |
Let me check this one last time |
There was a bunch of comments that were not addressed and for some reason, the documentation file is being reverted. I'll have to spend some time on this. Also the build is failing so some tests are not ok.... |
@PavelBal The tests are failing in this PR ... I'll need to investigate why |
@PavelBal |
I guess it's only for old simulation where F_Abs was not available. But still..this is really ugly |
Yes this will only be shown when having an older simulation... all new simulations will show the parameters right away. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PavelBal @Yuri05 @StephanSchaller
The new behavior at the presenter level is absolutely not tested. I could move the whole code without having any issue with tests not working. I do not have time to add tests but in the future, we need to ensure that we test the behavior that we are adding,. This is our only way of survival with such a small team
@@ -2629,6 +2631,10 @@ public static class PKAnalysis | |||
public static readonly string Unit = UI.Unit; | |||
public static readonly string Description = "Description"; | |||
public static readonly string Warning = "Warning"; | |||
public static readonly string OnCurves = "On Curves"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// <returns></returns> | ||
PKAnalysis CreatePKAnalysisFromValues(PKValues pkValues, Simulation simulation, Compound compound); | ||
|
||
IReadOnlyList<PopulationPKAnalysis> AggregatePKAnalysis(Simulation populationDataCollector, IEnumerable<QuantityPKParameter> pkParameters, IEnumerable<StatisticalAggregation> selectedStatistics, string captionPrefix); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea what this captionPrefix means. But I did not have time to investigate. Probably the name of the output but hard to tell
@@ -183,7 +183,7 @@ private void showAnalysis() | |||
private void calculatePKAnalysis() | |||
{ | |||
var chartData = CreateChartData(); | |||
_pkAnalysisPresenter.CalculatePKAnalysis(PopulationDataCollector, chartData); | |||
_pkAnalysisPresenter.CalculatePKAnalyses(PopulationDataCollector, chartData, PopulationAnalysisChart.PopulationAnalysis); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have rewritten this completely so that the PKCalculation was done ion pkAnalysisPresenter and not in this presenter.
TELL DON'T ASK.
I will merge as soon as the build is running |
Fixes #2021 (include pk properties for population simulations)