Skip to content
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

Documentation should show turning non-freq-dep to freq-dep for interventions and the "trick" of the dummy fitness #33

Open
rdiaz02 opened this issue Jan 9, 2025 · 0 comments

Comments

@rdiaz02
Copy link
Owner

rdiaz02 commented Jan 9, 2025

Example:

### Non-freq-dep-fitness
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)

set.seed(1)
ex3 <- oncoSimulIndiv(
    FitEff,
    model = "McFLD",
    mu = 1e-4,
    sampleEvery = 0.01,
    initSize = 5000,
    finalTime = 100,
    onlyCancer = FALSE
)


### Turning the first example into something you can intervene

#### What are the fitnesses?

(allgf <- evalAllGenotypes(FitEff, addwt = TRUE))

#### Write as freq-dep-fitess

rTfdf <- allgf
rTfdf[, 2] <- as.character(rTfdf[, 2])
colnames(rTfdf)[2] <- "Fitness"

## Add a dummy expression so fdf works
rTfdf[1, 2] <- "1 + 0 * n_"

rTF <- allFitnessEffects(genotFitness = rTfdf,
                         frequencyDependentFitness = TRUE,
                         frequencyType = "abs")

## Of course, much slower than the non-fdf, but identical
set.seed(1)
ex3F <- oncoSimulIndiv(
    rTF,
    model = "McFLD",
    mu = 1e-4,
    sampleEvery = 0.01,
    initSize = 5000,
    finalTime = 100,
    onlyCancer = FALSE
)

par(mfrow = c(2, 1))
plot(ex3, show = "genotypes")
plot(ex3F, show = "genotypes")

#### Create intervention

## To make effects more visible, a stronger effect
ix <- list(
    list(ID = "i1",
         Trigger = "T > 10",
         WhatHappens = "n_TP53_ATM = n_TP53_ATM*0.5",
         Periodicity = 1,
         Repetitions = Inf
         )
)

ixF <- createInterventions(ix, rTF)

set.seed(1)
ex3ixF <- oncoSimulIndiv(
    rTF,
    model = "McFLD",
    mu = 1e-4,
    sampleEvery = 0.01,
    initSize = 5000,
    finalTime = 100,
    onlyCancer = FALSE,
    interventions = ixF)

par(mfrow = c(2, 1))
plot(ex3F, show = "genotypes")
plot(ex3ixF, show = "genotypes")

(This is example is an answer to a question from Sara Verde Camacho, student of PRSTR, 2024-25)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant