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

Specifying "Arb" but having any genotype with a death of 0 gives error (removed from spec) #29

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

Comments

@rdiaz02
Copy link
Owner

rdiaz02 commented Jan 2, 2025

Summary:

Any entry with a death (also birth?) of 0 is removed from FDF specification and oncoSimulIndiv fails if other entries depend on this one.

Example:

## Original
fe1 <- allFitnessEffects(
    deathSpec = TRUE,  # Enable explicit death rate specification
    genotFitness = data.frame(
        Genotype = c("WT", "A", "B", "A, B"), # Use "A, B" for combined genotypes
        Birth = c(
            "1 + 1 * f_A_B",   # WT: Birth rate increases with SASP frequency
            "1 + 1 * f_A_B",   # A: Birth rate increases with SASP frequency
            "1",               # B: Constant birth rate
            "0.01"             # A, B: Low proliferation (birth rate)
        ),
        Death = c(
            "0.1",             # WT: Constant death rate
            "0.1",             # A: Constant death rate
            "0.1",             # B: Constant death rate
            "0"                # A, B: No death for SASP cells
        )
    ),
    frequencyDependentBirth = TRUE,  # Enable dynamic birth rates
    frequencyType = "rel"            # Use relative frequencies
)

sim <- oncoSimulIndiv(
  model = "Arb",         # Use the Arb model
  fe1,        # Fitness effects with birth and death rates
  initSize = 10000,      # Initial population size
  mu = 1e-4,             # Base mutation rate
  finalTime = 3000,      # Simulation duration
  detectionSize = 1e6    # Maximum population size
)


## A genotype on which other specifications depend is missing!! ## AB is missing
fe1[c("fitnessLandscape", "fitnessLandscape_df", "full_FDF_spec")]

## We can try writing 0 as 0.0 or passing, as Death,
## a numeric (not string) column. As expected,
## tt does not solve it

## The problem is that any row with a value of 0 is removed
## probably in some processing step. This is often what
## we want, but here other genotypes's specifications
## depend on AB.

These three options solve it. The first two are the same except for using a column of strings or floats.

fe4 <- allFitnessEffects(
    deathSpec = TRUE,  # Enable explicit death rate specification
    genotFitness = data.frame(
        Genotype = c("WT", "A", "B", "A, B"), # Use "A, B" for combined genotypes
        Birth = c(
            "1 + 1 * f_A_B",   # WT: Birth rate increases with SASP frequency
            "1 + 1 * f_A_B",   # A: Birth rate increases with SASP frequency
            "1",               # B: Constant birth rate
            "0.01"             # A, B: Low proliferation (birth rate)
        ),
        Death = c(0.1, 0.1, 0.1, 1.000000001e-9)
    ),
    frequencyDependentBirth = TRUE,  # Enable dynamic birth rates
    frequencyType = "rel"            # Use relative frequencies
)
## AB genotype is back
fe4[c("fitnessLandscape", "fitnessLandscape_df", "full_FDF_spec")]

fe5 <- allFitnessEffects(
    deathSpec = TRUE,  # Enable explicit death rate specification
    genotFitness = data.frame(
        Genotype = c("WT", "A", "B", "A, B"), # Use "A, B" for combined genotypes
        Birth = c(
            "1 + 1 * f_A_B",   # WT: Birth rate increases with SASP frequency
            "1 + 1 * f_A_B",   # A: Birth rate increases with SASP frequency
            "1",               # B: Constant birth rate
            "0.01"             # A, B: Low proliferation (birth rate)
        ),
        Death = c(
            "0.1",             # WT: Constant death rate
            "0.1",             # A: Constant death rate
            "0.1",             # B: Constant death rate
            "0.000000001000000001"                # A, B: (almost) No death for SASP cells
        )
    ),
    frequencyDependentBirth = TRUE,  # Enable dynamic birth rates
    frequencyType = "rel"            # Use relative frequencies
)
##  AB genotype is back
fe5[c("fitnessLandscape", "fitnessLandscape_df", "full_FDF_spec")]



fe6 <- allFitnessEffects(
    deathSpec = TRUE,  # Enable explicit death rate specification
    genotFitness = data.frame(
        Genotype = c("WT", "A", "B", "A, B"), # Use "A, B" for combined genotypes
        Birth = c(
            "1 + 1 * f_A_B",   # WT: Birth rate increases with SASP frequency
            "1 + 1 * f_A_B",   # A: Birth rate increases with SASP frequency
            "1",               # B: Constant birth rate
            "0.01"             # A, B: Low proliferation (birth rate)
        ),
        Death = c(
            "0.1" ,             # WT: Constant death rate
            "0.1",             # A: Constant death rate
            "0.1",             # B: Constant death rate
            "0.0 + 0 * f_A"              # A, B: No death for SASP cells
        )
    ),
    frequencyDependentDeath = TRUE,  ## Force using fdf for death
    frequencyDependentBirth = TRUE,  # Enable dynamic birth rates
    frequencyType = "rel"            # Use relative frequencies
)
##  AB genotype is back
fe6[c("fitnessLandscape", "fitnessLandscape_df", "full_FDF_spec")]

Now, fe4 and fe5 are equivalent and work via introducing a death that is not 0 (though very similar to 0). fe6 works by setting a death of 0 by using an expression that always returns 0, but will work via the frequency dependent fitness.

So fe6 works.

What should be fixed

Either or both of:

a) Give a warning that a value is 0
b) Do not remove the entry if other entries depend on it, or give a message saying how to circumvent it.

Additional notes to fix it and add tests

Testing code in OncoSimul/OncoSimulR/tests/testthat/test.Z-oncoSimulIndivDeath.R
(e.g., lines 210, 282, 312:

)

This problem was detected by Gonzalo García Girón, from class PRSTR 2024-25, on 2024-12-31.

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