Sensitivity
Run sensitivity analyses on a model.
Public API
PhysiCellModelManager.MOAT
— TypeMOAT
Store the information necessary to run a Morris One-At-A-Time (MOAT) global sensitivity analysis.
Fields
lhs_variation::LHSVariation
: the Latin Hypercube Sampling (LHS) variation to use for the MOAT. SeeLHSVariation
.
Examples
Note: any keyword arguments in the MOAT
constructor are passed to LHSVariation
.
MOAT() # default to 15 base points
MOAT(10) # 10 base points
MOAT(10; add_noise=true) # do not restrict the base points to the center of their cells
PhysiCellModelManager.RBD
— TypeRBD
Store the information necessary to run a Random Balance Design (RBD) global sensitivity analysis.
By default, RBD
will use the Sobol' sequence to sample the parameter space. See below for how to turn this off. Currently, users cannot control the Sobolʼ sequence used in RBD to the same degree it can be controlled in Sobolʼ. Open an Issue if you would like this feature.
Fields
rbd_variation::RBDVariation
: the RBD variation to use for the RBD analysis. SeeRBDVariation
.num_harmonics::Int
: the number of harmonics to use from the Fourier transform for the RBD analysis.
Examples
Note: any keyword arguments in the RBD
constructor are passed to RBDVariation
, except for the num_harmonics
keyword argument. If num_harmonics
is not specified, it defaults to 6.
RBD(15) # 15 points from the Sobol' sequence
RBD(15; num_harmonics=10) # use 10 harmonics
RBD(15; use_sobol=false) # opt out of using the Sobol' sequence, instead using a random sequence in each dimension
PhysiCellModelManager.Sobolʼ
— TypeSobolʼ
Store the information necessary to run a Sobol' global sensitivity analysis as well as how to extract the first and total order indices.
The rasp symbol is used to avoid conflict with the Sobol module. To type it in VS Code, use \rasp
and then press tab
. The methods available for the first order indices are :Sobol1993
, :Jansen1999
, and :Saltelli2010
. Default is :Jansen1999
. The methods available for the total order indices are :Homma1996
, :Jansen1999
, and :Sobol2007
. Default is :Jansen1999
.
Fields
sobol_variation::SobolVariation
: the Sobol' variation to use for the Sobol' analysis. SeeSobolVariation
.sobol_index_methods::NamedTuple{(:first_order, :total_order), Tuple{Symbol, Symbol}}
: the methods to use for calculating the first and total order indices.
Examples
Note: any keyword arguments in the Sobolʼ
constructor are passed to SobolVariation
, except for the sobol_index_methods
keyword argument. Do not use the n_matrices
keyword argument in the SobolVariation
constructor as it is set to 2 as required for Sobol' analysis.
Sobolʼ(15) # 15 points from the Sobol' sequence
Sobolʼ(15; sobol_index_methods=(first_order=:Jansen1999, total_order=:Jansen1999)) # use Jansen, 1999 for both first and total order indices
Sobolʼ(15; randomization=NoRand())` # use the default Sobol' sequence with no randomization. See GlobalSensitivity.jl for more options.
Sobolʼ(15; skip_start=true) # force the Sobol' sequence to skip to the lowest denominator in the sequence that can hold 15 points, i.e., choose from [1/32, 3/32, 5/32, ..., 31/32]
Sobolʼ(15; skip_start=false) # force the Sobol' sequence to start at the beginning, i.e. [0, 0.5, 0.25, 0.75, ...]
Sobolʼ(15; include_one=true) # force the Sobol' sequence to include 1 in the sequence
Base.run
— Methodrun(method::GSAMethod, args...; functions::AbstractVector{<:Function}=Function[], kwargs...)
Run a global sensitivity analysis method on the given arguments.
Arguments
method::GSAMethod
: the method to run. Options areMOAT
,Sobolʼ
, andRBD
.inputs::InputFolders
: the input folders shared across all simuations to run.avs::AbstractVector{<:AbstractVariation}
: the elementary variations to sample. These can be eitherDiscreteVariation
's orDistributedVariation
's.
Alternatively, the third argument, inputs
, can be replaced with a reference::AbstractMonad
, i.e., a simulation or monad to be the reference. This should be preferred to setting reference variation IDs manually, i.e., if not using the base files in the input folders.
Keyword Arguments
The reference_variation_id
keyword argument is only compatible when the third argument is of type InputFolders
. Otherwise, the reference
simulation/monad will set the reference variation values.
reference_variation_id::VariationID
: the reference variation IDs as aVariationID
ignore_indices::AbstractVector{<:Integer}=[]
: indices intoavs
to ignore when perturbing the parameters. Only used for Sobolʼ. SeeSobolʼ
for a use case.force_recompile::Bool=false
: whether to force recompilation of the simulation codeprune_options::PruneOptions=PruneOptions()
: the options for pruning the simulation resultsn_replicates::Integer=1
: the number of replicates to run for each monad, i.e., at each sampled parameter vector.use_previous::Bool=true
: whether to use previous simulation results if they existfunctions::AbstractVector{<:Function}=Function[]
: the functions to calculate the sensitivity indices for. Each function must take a simulation ID as the singular input and return a real number.
PhysiCellModelManager.simulationIDs
— MethodsimulationIDs(gsa_sampling::GSASampling)
Get the simulation IDs that were run in the sensitivity analysis.
Private API
PhysiCellModelManager.GSAMethod
— TypePhysiCellModelManager.GSASampling
— TypeGSASampling
Store the information that comes out of a global sensitivity analysis method.
Subtypes
Methods
calculateGSA!
, evaluateFunctionOnSampling
, getMonadIDDataFrame
, simulationIDs
, methodString
, sensitivityResults!
, recordSensitivityScheme
PhysiCellModelManager.MOATSampling
— TypeMOATSampling
Store the information that comes out of a Morris One-At-A-Time (MOAT) global sensitivity analysis.
Fields
sampling::Sampling
: the sampling used in the sensitivity analysis.monad_ids_df::DataFrame
: the DataFrame of monad IDs that define the scheme of the sensitivity analysis.results::Dict{Function, GlobalSensitivity.MorrisResult}
: the results of the sensitivity analysis for each function.
PhysiCellModelManager.RBDSampling
— TypeRBDSampling
Store the information that comes out of a Random Balance Design (RBD) global sensitivity analysis.
Fields
sampling::Sampling
: the sampling used in the sensitivity analysis.monad_ids_df::DataFrame
: the DataFrame of monad IDs that define the scheme of the sensitivity analysis.results::Dict{Function, GlobalSensitivity.SobolResult}
: the results of the sensitivity analysis for each function.num_harmonics::Int
: the number of harmonics used in the Fourier transform.num_cycles::Union{Int, Rational}
: the number of cycles used for each parameter.
PhysiCellModelManager.SobolSampling
— TypeSobolSampling
Store the information that comes out of a Sobol' global sensitivity analysis.
Fields
sampling::Sampling
: the sampling used in the sensitivity analysis.monad_ids_df::DataFrame
: the DataFrame of monad IDs that define the scheme of the sensitivity analysis.results::Dict{Function, GlobalSensitivity.SobolResult}
: the results of the sensitivity analysis for each function.sobol_index_methods::NamedTuple{(:first_order, :total_order), Tuple{Symbol, Symbol}}
: the methods used for calculating the first and total order indices.
PhysiCellModelManager.calculateGSA!
— MethodcalculateGSA!(gsa_sampling::GSASampling, functions::AbstractVector{<:Function})
Calculate the sensitivity indices for the given functions.
This function is also used to compute the sensitivity indices for a single function:
calculateGSA!(gsa_sampling, f)
Arguments
gsa_sampling::GSASampling
: the sensitivity analysis to calculate the indices for.functions::AbstractVector{<:Function}
: the functions to calculate the sensitivity indices for. Each function must take a simulation ID as the singular input and return a real number.
PhysiCellModelManager.evaluateFunctionOnSampling
— MethodevaluateFunctionOnSampling(gsa_sampling::GSASampling, f::Function)
Evaluate the given function on the sampling scheme of the global sensitivity analysis, avoiding duplicate evaluations.
PhysiCellModelManager.getMonadIDDataFrame
— MethodgetMonadIDDataFrame(gsa_sampling::GSASampling)
Get the DataFrame of monad IDs that define the scheme of the sensitivity analysis.
PhysiCellModelManager.methodString
— MethodmethodString(gsa_sampling::GSASampling)
Get the string representation of the method used in the sensitivity analysis.
PhysiCellModelManager.perturbVariation
— MethodperturbVariation(location::Symbol, pv::ParsedVariations, folder::String, reference_variation_id::Int, d::Int)
Perturb the variation at the given location and dimension for MOAT
global sensitivity analysis.
PhysiCellModelManager.recordSensitivityScheme
— MethodrecordSensitivityScheme(gsa_sampling::GSASampling)
Record the sampling scheme of the global sensitivity analysis to a CSV file.
PhysiCellModelManager.runSensitivitySampling
— FunctionrunSensitivitySampling(method::GSAMethod, args...; kwargs...)
Run a global sensitivity analysis method on the given arguments.
Arguments
method::GSAMethod
: the method to run. Options areMOAT
,Sobolʼ
, andRBD
.inputs::InputFolders
: the input folders shared across all simuations to run.pv::ParsedVariations
: theParsedVariations
object that contains the variations to sample.
Keyword Arguments
reference_variation_id::VariationID
: the reference variation IDs as aVariationID
ignore_indices::AbstractVector{<:Integer}=[]
: indices intopv.variations
to ignore when perturbing the parameters. Only used for Sobolʼ.force_recompile::Bool=false
: whether to force recompilation of the simulation codeprune_options::PruneOptions=PruneOptions()
: the options for pruning the simulation resultsn_replicates::Int=1
: the number of replicates to run for each monad, i.e., at each sampled parameter vector.use_previous::Bool=true
: whether to use previous simulation results if they exist
PhysiCellModelManager.sensitivityResults!
— MethodsensitivityResults!(gsa_sampling::GSASampling, functions::AbstractVector{<:Function})
Calculate the global sensitivity analysis for the given functions and record the sampling scheme.
PhysiCellModelManager.variationValue
— MethodvariationValue(ev::ElementaryVariation, variation_id::Int, folder::String)
Get the value of the variation at the given variation ID for MOAT
global sensitivity analysis.
PhysiCellModelManager.variationsToMonads
— MethodvariationsToMonads(inputs::InputFolders, variation_ids::Dict{Symbol,Matrix{Int}}, use_previous::Bool)
Return a dictionary of monads and a matrix of monad IDs based on the given variation IDs.
The five matrix inputs together define a single matrix of variation IDs. This information, together with the inputs
, identifies the monads to be used. The use_previous
flag determines whether to use previous simulations, if they exist.
Returns
monad_dict::Dict{VariationID, Monad}
: a dictionary of the monads to be used without duplicates.monad_ids::Matrix{Int}
: a matrix of the monad IDs to be used. Matches the shape of the input IDs matrices.