Open-Systems-Pharmacology / R-Toolbox

Other
4 stars 7 forks source link

new function request: createPKSimIndividual() #38

Closed StephanSchaller closed 4 years ago

StephanSchaller commented 6 years ago

... as we already have for the Matlab Toolbox, but extended, so we can "substitute" species as well ;-)

Yuri05 commented 6 years ago

what do you mean by "substitute" species?

StephanSchaller commented 6 years ago

@Yuri05 today is Sunday!!

what do you mean by "substitute" species?

I mean to exchange a human PBPK model with a dog model ( see discussions in #378)

msevestre commented 6 years ago

Apparently it's possible to call .NET from R using the following package https://cran.r-project.org/web/packages/rDotNet/rDotNet.pdf

Another great task for the community

PavelBal commented 6 years ago

Will look at it.

PavelBal commented 5 years ago

I looked into the rDotNet-package referenced by @msevestre and it should be possible to implement an R-version of PKSimCreateIndividual. However, the functionality of rDotNet is somehow limited compared to the native .NET-support provided in MatLab.

1) It is not possible to acces to access constants of static class, as is performed in MatLab:

    %set gestational age to default if not passed as parameter
    if ~exist('gestational_age', 'var')
        gestational_age = PKSim.Core.CoreConstants.NOT_PRETERM_GESTATIONAL_AGE_IN_WEEKS;
    end

2) It is not possible to create empty arrays of certain type, as is required in PKSim.Matlab.MatlabIndividualFactory.CreateIndividual(OriginData matlabOriginData, IEnumerable<MoleculeOntogeny> moleculeOntogenies) https://github.com/Open-Systems-Pharmacology/PK-Sim/blob/a251df2e061b2a58f786dcedcaa09e955db8be95/src/PKSim.Matlab/MatlabIndividualFactory.cs#L58 if no ontogenies are provided (Matlab-code:

    else
        ontogenies=NET.createArray('PKSim.Matlab.MoleculeOntogeny', 0);
    end

    if useDistribution
        %---- create new individual
        result=IndividualFactory.DistributionsFor(originData, ontogenies);

A proposed solution would be to write a wrapper with getter-functions for the constanst of PKSim.Core.CoreConstants and the method CreateIndividual(OriginData matlabOriginData) that would not require IEnumerable<MoleculeOntogeny> moleculeOntogenies as an argument (that would simply call the original method with an empty array).

Should be doable in a short time. The drawback is still that we have to rely on an extern package.

Yuri05 commented 5 years ago

another library for .NET<==R : https://rclr.codeplex.com (however seems it's was not further developed since 2015)