Two issues
1. createInterventions allows passing whatHappens with relative fitness
When using interventions, specifically "WhatHappens", the what should not be changes in relative frequencies. This is implicit, since all of the examples in the vignette (and all of the code) always specify whathappens using "n_", not "f_" and it is said in the vignette: "Note that, for now, the fitness must have frequencyDependentFitness as TRUE and frequencyTypeas “abs” (it can be )."
But createInterventions is defined as:
createInterventions
function (interventions, genotFitness, frequencyType = "auto")
{
if ((frequencyType == "abs") || (frequencyType == "auto")) {
return(adapt_interventions_to_cpp(verify_interventions(interventions),
frequencyType, genotFitness))
}
else if (frequencyType == "rel") {
stop("Frequency type as relative is not implemented... yet.")
}
else {
stop("You have specified the freqType wrong. Review it please.")
}
}
So we can easily define a genotFitness with "rel", and not pass an argument to "frequencyType" in createInterventions and it will go unnoticed and crash later.
Solution
At least we should check in createInterventions: verify genotFitness$frequencyType and stop if "rel".
Also: say this a few more times in the vignette and the help for createInterventions.
Example
fitness_df <- data.frame(
Genotype = c("WT", "S", "R"),
Fitness = c(
"1 * f_ + 0.5 * f_S + 0.2 * f_R",
"if (T < 50) 0.8; else 1.2",
"if (T < 50) 1.1; else 0.9"
),
stringsAsFactors = FALSE
)
model <- allFitnessEffects(
genotFitness = fitness_df,
frequencyDependentFitness = TRUE,
frequencyType = "rel"
)
i1 <- list(
list(ID = "resistantTreatment",
Trigger = "N > 100",
WhatHappens = "f_R = f_R * 0.7",
Periodicity = 10, Repetitions = Inf)
)
i1 <- createInterventions(i1, model)
simulation <- oncoSimulIndiv(
model,
model = "McFL",
mu = 1e-4,
initSize = 5000,
finalTime = 200,
keepEvery = 1,
interventions = i1
)
## Error:
## exprtk parser error:
## Error[00] Position: 00 Type: [ Syntax Error] Msg: ERR202 - Undefined symbol: 'f_R' Expression: f_R = f_R * 0.7
## Unrecoverable exception: The expression was imposible to parse.. Aborting.
Why not WhatHappens with relative numbers?
It is confusing and the outcome can depend on order of evaluation if an intervention change population sizes of several genotypes. Relative fitness can be trivially defined using things like n_A/N and similar (see section 10.5 of the vignette: https://rdiaz02.github.io/OncoSimul/OncoSimulR.html#105_Frequency-dependent_fitness:_can_I_mix_relative_and_absolute_frequencies), so one can define fitness using n_ and whatHappens with absolute number changes.
(This was reported by Sheila Santomé Latas, from PRSTR 2024-25).
2. createInterventions allows passing fitness specifications that are not frequency dependent
It should fail immediately
Solution
At least we should check in createInterventions: verify genotFitness$frequencyType and stop if not frequency-dependent.
Also: say this a few more times in the vignette and the help for createInterventions.
Example
rT <- data.frame(parent = c("Root", rep("TP53", 2)),
child = c("TP53", "MDM2", "ATM"),
s = 0.5,
sh = c(-Inf, 0, 0),
typeDep = "MN")
epvecx <- c("TP53:MDM2" = -0.4)
FitEff <- allFitnessEffects(rT = rT, epistasis = epvecx)
ex3 <- oncoSimulIndiv(
FitEff,
model = "McFLD",
mu = 1e-4,
sampleEvery = 0.01,
initSize = 5000,
finalTime = 500,
onlyCancer = FALSE
)
ix <- list(
list(ID = "i1",
Trigger = "T > 10",
WhatHappens = "n_TP53_ATM = n_TP53_ATM*0.8",
Periodicity = 1,
Repetitions = Inf
)
)
## This should have failed
ix <- createInterventions(ix, FitEff)
ex3ix <- oncoSimulIndiv(
FitEff,
model = "McFLD",
mu = 1e-4,
sampleEvery = 0.01,
initSize = 5000,
finalTime = 20,
onlyCancer = FALSE,
interventions = ix)
(This was reported by Sara Verde Camacho, from PRSTR 2024-25).
Two issues
1. createInterventions allows passing whatHappens with relative fitness
When using interventions, specifically "WhatHappens", the what should not be changes in relative frequencies. This is implicit, since all of the examples in the vignette (and all of the code) always specify whathappens using "n_", not "f_" and it is said in the vignette: "Note that, for now, the fitness must have frequencyDependentFitness as TRUE and frequencyTypeas “abs” (it can be )."
But
createInterventionsis defined as:So we can easily define a genotFitness with "rel", and not pass an argument to "frequencyType" in
createInterventionsand it will go unnoticed and crash later.Solution
At least we should check in
createInterventions: verifygenotFitness$frequencyTypeand stop if "rel".Also: say this a few more times in the vignette and the help for createInterventions.
Example
Why not WhatHappens with relative numbers?
It is confusing and the outcome can depend on order of evaluation if an intervention change population sizes of several genotypes. Relative fitness can be trivially defined using things like
n_A/Nand similar (see section 10.5 of the vignette: https://rdiaz02.github.io/OncoSimul/OncoSimulR.html#105_Frequency-dependent_fitness:_can_I_mix_relative_and_absolute_frequencies), so one can define fitness usingn_and whatHappens with absolute number changes.(This was reported by Sheila Santomé Latas, from PRSTR 2024-25).
2. createInterventions allows passing fitness specifications that are not frequency dependent
It should fail immediately
Solution
At least we should check in
createInterventions: verifygenotFitness$frequencyTypeand stop if not frequency-dependent.Also: say this a few more times in the vignette and the help for createInterventions.
Example
(This was reported by Sara Verde Camacho, from PRSTR 2024-25).