-
Notifications
You must be signed in to change notification settings - Fork 50
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
Fixes #2260 - including "Global" PK-Parameters into the box-plot/scatter plot #2359
Changes from 1 commit
616752e
20a1032
1c2172b
ae0166d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,6 @@ | |
using OSPSuite.Core.Extensions; | ||
using OSPSuite.Core.Maths.Random; | ||
using OSPSuite.Utility.Extensions; | ||
using PKSim.Core.Extensions; | ||
using PKSim.Core.Repositories; | ||
|
||
namespace PKSim.Core.Model | ||
|
@@ -280,27 +279,37 @@ private DataColumn medianAggregateDataColumns(IReadOnlyList<DataColumn> columns) | |
return new DataColumn(column.Id, column.Dimension, column.BaseGrid) | ||
{ | ||
Values = Enumerable.Range(0, column.Values.Count).Select(i => | ||
IndexedValuesFromColumns(columns, i).Median() | ||
indexedValuesFromColumns(columns, i).Median() | ||
).ToList() | ||
}; | ||
} | ||
|
||
private static IReadOnlyList<float> IndexedValuesFromColumns(IReadOnlyList<DataColumn> columns, int i) | ||
private static IReadOnlyList<float> indexedValuesFromColumns(IReadOnlyList<DataColumn> columns, int i) | ||
{ | ||
return columns.Select(x => x.Values[i]).ToList(); | ||
} | ||
|
||
public override DataColumn PeripheralVenousBloodColumn(string compoundName) | ||
{ | ||
return medianAggregateDataColumns(drugColumnFor(CoreConstants.Organ.PERIPHERAL_VENOUS_BLOOD, CoreConstants.Observer.PLASMA_PERIPHERAL_VENOUS_BLOOD, CoreConstants.Observer.PLASMA_PERIPHERAL_VENOUS_BLOOD, compoundName)); | ||
return medianAggregateDataColumns(PeripheralVenousBloodColumns(compoundName)); | ||
} | ||
|
||
public IReadOnlyList<DataColumn> PeripheralVenousBloodColumns(string compoundName) | ||
{ | ||
return drugColumnFor(CoreConstants.Organ.PERIPHERAL_VENOUS_BLOOD, CoreConstants.Observer.PLASMA_PERIPHERAL_VENOUS_BLOOD, CoreConstants.Observer.PLASMA_PERIPHERAL_VENOUS_BLOOD, compoundName); | ||
} | ||
|
||
/// <summary> | ||
/// tries to find venous blood plasma if defined in the repository. returns null otherwise | ||
/// </summary> | ||
public override DataColumn VenousBloodColumn(string compoundName) | ||
{ | ||
return medianAggregateDataColumns(drugColumnFor(CoreConstants.Organ.VENOUS_BLOOD, CoreConstants.Compartment.PLASMA, CoreConstants.Observer.CONCENTRATION_IN_CONTAINER, compoundName)); | ||
return medianAggregateDataColumns(VenousBloodColumns(compoundName)); | ||
} | ||
|
||
public IReadOnlyList<DataColumn> VenousBloodColumns(string compoundName) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is this public? |
||
{ | ||
return drugColumnFor(CoreConstants.Organ.VENOUS_BLOOD, CoreConstants.Compartment.PLASMA, CoreConstants.Observer.CONCENTRATION_IN_CONTAINER, compoundName); | ||
} | ||
|
||
public override DataColumn FabsOral(string compoundName) | ||
|
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using OSPSuite.Core.Domain; | ||
using OSPSuite.Core.Domain.Services; | ||
using PKSim.Core.Model; | ||
|
||
namespace PKSim.Core.Services | ||
{ | ||
public interface IPopulationSimulationBodyWeightUpdater | ||
{ | ||
void UpdateBodyWeightForIndividual(PopulationSimulation populationSimulation, int individualId); | ||
void ResetBodyWeightParameter(PopulationSimulation populationSimulation); | ||
} | ||
|
||
public class PopulationSimulationBodyWeightUpdater : IPopulationSimulationBodyWeightUpdater | ||
{ | ||
private readonly IEntityPathResolver _entityPathResolver; | ||
|
||
public PopulationSimulationBodyWeightUpdater(IEntityPathResolver entityPathResolver) | ||
{ | ||
_entityPathResolver = entityPathResolver; | ||
} | ||
|
||
public void UpdateBodyWeightForIndividual(PopulationSimulation populationSimulation, int individualId) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason why this was moved out of the PK Stuff? Because you are doing line 24 to 26 now for EAch individual as opposed to one time. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The only reason for it was that originally I was reproducing the scaling logic in a second location. I think it makes sense to put it back now. |
||
{ | ||
var bodyWeightParameter = populationSimulation.BodyWeight; | ||
var bodyWeightParameterPath = bodyWeightParameterPathFrom(bodyWeightParameter); | ||
var allBodyWeights = populationSimulation.AllValuesFor(bodyWeightParameterPath); | ||
|
||
if (bodyWeightParameter == null) | ||
return; | ||
|
||
bodyWeightParameter.Value = allBodyWeights.Count > individualId ? allBodyWeights[individualId] : double.NaN; | ||
} | ||
|
||
public void ResetBodyWeightParameter(PopulationSimulation populationSimulation) | ||
{ | ||
populationSimulation.BodyWeight?.ResetToDefault(); | ||
} | ||
|
||
private string bodyWeightParameterPathFrom(IParameter bodyWeightParameter) | ||
{ | ||
return bodyWeightParameter != null ? _entityPathResolver.PathFor(bodyWeightParameter) : string.Empty; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,6 @@ | |
using System.Linq; | ||
using PKSim.Core.Model; | ||
using PKSim.Core.Services; | ||
using PKSim.Presentation.DTO.Mappers; | ||
using PKSim.Presentation.DTO.PopulationAnalyses; | ||
|
||
using PKSim.Presentation.Presenters.Populations; | ||
|
@@ -13,6 +12,7 @@ | |
using OSPSuite.Core.Domain.PKAnalyses; | ||
using OSPSuite.Presentation.Mappers; | ||
using OSPSuite.Presentation.Presenters; | ||
using OSPSuite.Utility.Extensions; | ||
|
||
namespace PKSim.Presentation.Presenters.PopulationAnalyses | ||
{ | ||
|
@@ -69,6 +69,16 @@ private void createAvailableQuantitiesListBasedOn(IPopulationDataCollector popul | |
{ | ||
_allPKParameters.Clear(); | ||
_allPKParameters.AddRange(_entitiesInContainerRetriever.OutputsFrom(populationDataCollector).SelectMany(availablePKParametersFor)); | ||
|
||
populationDataCollector.Compounds.Select(x => x.Name).Each(compoundName => | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Extension method AllNames |
||
{ | ||
_allPKParameters.AddRange(populationDataCollector.AllPKParametersFor(compoundName).Select(globalPKParameters)); | ||
}); | ||
} | ||
|
||
private QuantityPKParameterDTO globalPKParameters(QuantityPKParameter globalPKParameter) | ||
{ | ||
return mapFrom(globalPKParameter, globalPKParameter.QuantityPath); | ||
} | ||
|
||
public IEnumerable<QuantityPKParameter> SelectedPKParameters | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,7 +59,7 @@ private PopulationAnalysisPKParameterField createFieldFrom(QuantityPKParameter p | |
{ | ||
var quantity = _allQuantities[pkParameter.QuantityPath]; | ||
if (quantity == null) | ||
return null; | ||
return _populationAnalysisFieldFactory.CreateFor(pkParameter, QuantityType.Drug | QuantityType.Observer, quantityDisplayPath); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure here. Clearly the quantity is not going to be found in the _allQuantities cache. But I'm not sure how get around this. Should there be additional values added int _allQuantities? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is ok but this requires a comment explaining that this parameter is not found because it is a global PK Parameter (can we actually check if this is one?). It cil;d also be the the quantity was removed somehow (thinking about mobi models imported etc..) |
||
|
||
return _populationAnalysisFieldFactory.CreateFor(pkParameter, quantity.QuantityType, quantityDisplayPath); | ||
} | ||
|
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 is this public?
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.
GlobalPKAnalysisTask needs to get access to all the columns for PeripheralVenousBlood and VenousBlood