Skip to content

Commit

Permalink
Updated to rRACES 0.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
albertocasagrande committed Apr 30, 2024
1 parent c257800 commit e0ffd00
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 38 deletions.
20 changes: 10 additions & 10 deletions CopyNumber/CopyNumber.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -131,22 +131,22 @@ To observe the different nature of the two events will make the deletion span a
m_engine$add_mutant(
mutant_name = "A",
passenger_rates = c(SNV = 1e-7, CNA = 0),
driver_SNVs = c(SNV("22", 10510210, "C"))
#driver_CNAs = c(CNA(type = "A", "22", pos_in_chr = 10303470,len = 1e7))
drivers = list(SNV("22", 10510210, "C"))
#driver_CNAs = c(CNA(type = "A", "22", chr_pos = 10303470,len = 1e7))
)
m_engine$add_mutant("B",
passenger_rates = c(SNV=1e-7, CNA=1e-9),
driver_SNVs = c(SNV("22", 10510210, "C")),
driver_CNAs = c(CNA(type = "A", "22", pos_in_chr = 20303470,len = 2e7),
CNA(type = "D", "22", pos_in_chr = 20303470,len = 1e7))
drivers = list(SNV("22", 10510210, "C"),
CNA(type = "A", chr = "22", chr_pos = 20303470, len = 2e7),
CNA(type = "D", chr = "22", chr_pos = 20303470, len = 1e7))
)
m_engine$add_mutant(
mutant_name = "C",
passenger_rates = c(SNV=1e-7, CNA = 1e-9),
driver_SNVs = c(SNV("22", 10510210, "C"))
#driver_CNAs = c(CNA(type = "A", "22", pos_in_chr = 10303470,len = 1e7))
drivers = list(SNV("22", 10510210, "C"))
#driver_CNAs = c(CNA(type = "A", chr = "22", chr_pos = 10303470, len = 1e7))
)
m_engine$add_exposure(coefficients = c(SBS13 = 0.4, SBS1 = 0.6))
Expand All @@ -169,15 +169,15 @@ seq_to_long <- function(seq_results) {
sn <- sample_names[1]
seq_df <- lapply(sample_names, function(sn) {
cc <- c("chromosome", "chr_pos", "ref", "alt", colnames(seq_results)[grepl(sn, colnames(seq_results), fixed = T)])
cc <- c("chr", "chr_pos", "ref", "alt", colnames(seq_results)[grepl(sn, colnames(seq_results), fixed = T)])
seq_results[, cc] %>%
`colnames<-`(c("chromosome", "chr_pos", "ref", "alt", "occurences", "coverage", "VAF")) %>%
`colnames<-`(c("chr", "chr_pos", "ref", "alt", "occurences", "coverage", "VAF")) %>%
dplyr::mutate(sample_name = sn)
}) %>% do.call("bind_rows", .)
seq_df %>%
dplyr::rename(chr = chromosome, from = chr_pos, DP = coverage, NV = occurences, ALT = alt) %>%
dplyr::rename(from = chr_pos, DP = coverage, NV = occurences, ALT = alt) %>%
dplyr::mutate(to = from) %>%
dplyr::select(chr, from, to, ALT, NV, DP, VAF, sample_name)
}
Expand Down
14 changes: 5 additions & 9 deletions SPN01/02_mutations.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,20 @@ mu_CNA = 1e-11

m_engine$add_mutant(mutant_name = "Clone 1",
passenger_rates = c(SNV = mu_SNV),
driver_SNVs = c(SNV_Clone1),
driver_CNAs = c())
drivers = list(SNV_Clone1))

m_engine$add_mutant(mutant_name = "Clone 2",
passenger_rates = c(CNA = mu_CNA),
driver_SNVs = c(),
driver_CNAs = c(CNA_Clone2))
drivers = list(CNA_Clone2))

m_engine$add_mutant(mutant_name = "Clone 3",
passenger_rates = c(SNV = mu_SNV),
driver_SNVs = c(SNV_Clone3),
driver_CNAs = c())
drivers = list(SNV_Clone3))

m_engine$add_mutant(mutant_name = "Clone 4",
passenger_rates = c(SNV = mu_SNV),
driver_SNVs = c(SNV_Clone4),
driver_CNAs = c())
drivers = list(SNV_Clone4))

# Mutational signatures
m_engine$add_exposure(
time = 0,
Expand All @@ -56,7 +53,6 @@ phylo_forest$save("data/phylo_forest.sff")

chromosomes <- c("1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","X","Y")


seq_results <- parallel::mclapply(chromosomes, function(c) {
simulate_seq(phylo_forest, coverage = 80, chromosomes = c, write_SAM = FALSE)
}, mc.cores = parallel::detectCores()) %>% do.call("bind_rows", .)
Expand Down
2 changes: 1 addition & 1 deletion SPN02/SPN02.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,5 @@ plot_forest(sampled_phylogeny) %>%
```{r}
# m_engine$add_mutant(mutant_name = "Clone 1",
# passenger_rates = c(SNV = 3e-8, CNA = 1e-11),
# driver_SNVs = SNV("7", 10510210, "A"))
# drivers = list(SNV("7", 10510210, "A")))
```
6 changes: 3 additions & 3 deletions SPN02/mutations.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ m_engine <- build_mutation_engine(setup_code = "GRCh38")

m_engine$add_mutant(mutant_name = "Clone 1",
passenger_rates = c(SNV = 3e-8, CNA = 1e-11),
driver_SNVs = SNV("7", 10510210, "A"))
drivers = list(SNV("7", 10510210, "A")))

m_engine$add_mutant(mutant_name = "Clone 2",
passenger_rates = c(SNV = 3e-8, CNA = 1e-11),
driver_SNVs = SNV("3", 179218303, "A"))
drivers = list(SNV("3", 179218303, "A")))

m_engine$add_mutant(mutant_name = "Clone 3",
passenger_rates = c(SNV = 3e-5, CNA = 1e-11), # modelled as an hypermutant, so with higher passenger_rates
driver_SNVs = SNV("2", 47799065, "A"))
drivers = list(SNV("2", 47799065, "A")))

m_engine$add_exposure(c(SBS1 = 0.5,SBS5 = 0.5))
m_engine$add_exposure(clone3_born, c(SBS1 = 0.3,SBS5 = 0.3, SBS6 = 0.4))
6 changes: 3 additions & 3 deletions SPN03/1_place_muts.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ plot_forest <- F
m_engine$add_mutant(mutant_name = "Clone 1",
passenger_rates = c(SNV = 3e-8,
CNA = 1e-10),
driver_SNVs = c(SNV("9", 136496197, "C"))
drivers = list(SNV("9", 136496197, "C"))
)

# Clone 2
Expand All @@ -23,15 +23,15 @@ m_engine$add_mutant(mutant_name = "Clone 1",
m_engine$add_mutant(mutant_name = "Clone 2",
passenger_rates = c(SNV = 3e-8,
CNA = 1e-10),
driver_SNVs = c(SNV("12", 25398284, "T"))
drivers = list(SNV("12", 25398284, "T"))
)

# Clone 3
# Unknown
m_engine$add_mutant(mutant_name = "Clone 3",
passenger_rates = c(SNV = 3e-8,
CNA = 1e-10),
driver_SNVs = c(SNV("1", 59550210, "A"))
drivers = list(SNV("1", 59550210, "A"))
)

# Signatures
Expand Down
9 changes: 4 additions & 5 deletions SPN04/02_mutations.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,17 @@ m_engine <- build_mutation_engine(setup_code = "GRCh37", context_sampling = 20)

m_engine$add_mutant(mutant_name = "Clone 1",
passenger_rates = c(SNV = 2e-8, CNA = 1e-11),
driver_SNVs = c(SNV("2", 209113113, "A")))
drivers = list(SNV("2", 209113113, "A")))


m_engine$add_mutant("Clone 2",
passenger_rates = c(SNV=2e-8, CNA=1e-11),
driver_SNVs = c(),
driver_CNAs = c(CNA(type = "A", "6", pos_in_chr = 25100000,len = 1e7)))
drivers = list(CNA(type = "A", chr = "6",
chr_pos = 25100000, len = 1e7)))

m_engine$add_mutant("Clone 3",
passenger_rates = c(SNV=2e-8, CNA=1e-11),
driver_SNVs = c(SNV("1", 115256530, "T")),
driver_CNAs = c())
drivers = list(SNV("1", 115256530, "T")))

# Mutational exposures ####
treatment_info <- readRDS("data/treatment_info.rds")
Expand Down
21 changes: 17 additions & 4 deletions SPN04/SPN04.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
title: 'rRACES: SPN04'
author: "Giovanni Santacatterina"
date: "`r Sys.Date()`"
output:
output:
pdf_document:
toc: true
html_document:
theme: united
highlight: tango
Expand Down Expand Up @@ -37,6 +39,9 @@ Set up the tissue sample and allow for internal duplication.

```{r tissue_preparation}
sim <- new(Simulation, seed = seed, save_snapshot = F)
sim$history_delta <- 0.1
sim$update_tissue(1e3, 1e3)
sim$duplicate_internal_cells <- TRUE
sim$death_activation_level <- 50
Expand Down Expand Up @@ -64,7 +69,8 @@ We add the final mutant, i.e. the one that will sweep out the other two complete
sim$add_mutant("Clone 3",growth_rates = 2, death_rates = 0.01)
sim$mutate_progeny(sim$choose_cell_in("Clone 2"), "Clone 3")
sim <- sweep_population(sim, "Clone 2", "Clone 3", .75, first_reduction = 10, delta_time = dt)
sim <- run_up_to_size_by_steps(sim, "Clone 3", .75e5, dt)
#sim <- run_up_to_size_by_steps(sim, "Clone 3", .75e5, dt)
sim$run_until(sim$var("Clone 3")>=.75e5)
plot_tissue(sim) | plot_muller(sim)
```

Expand All @@ -89,7 +95,12 @@ treatment_start <- sim$get_clock()
sim$update_rates("Clone 1",rates = c(growth = 0, death=5))
sim$update_rates("Clone 2",rates = c(growth = 0, death=5))
sim$update_rates("Clone 3",rates = c(growth = 0, death=5))
sim <- run_down_to_size_by_steps(sim, "Clone 3", 1e3, delta_time = .1)
sim$history_delta <- 0.1
#sim <- run_down_to_size_by_steps(sim, "Clone 3", 1e3, delta_time = .1)
sim$run_until(sim$var("Clone 3")<=1e3)
treatment_end <- sim$get_clock()
plot_tissue(sim) | plot_muller(sim)
```
Expand All @@ -100,7 +111,9 @@ The effect of the treatment ends and the population can grow back.

```{r relapse, results='hide', message=FALSE, warning=FALSE}
sim$update_rates("Clone 3",rates = c(growth = 2, death=0.01))
sim <- run_up_to_size_by_steps(sim, "Clone 3", .75e5, delta_time = .1)
#sim <- run_up_to_size_by_steps(sim, "Clone 3", .75e5, delta_time = .1)
sim$run_until(sim$var("Clone 3")>=.75e5)
plot_tissue(sim, num_of_bins = 300) | plot_muller(sim) + xlim(20, NA)
```

Expand Down
6 changes: 3 additions & 3 deletions forest_annotation/forest_annotation.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ m_engine = build_mutation_engine(setup_code = "demo")
m_engine$add_mutant(mutant_name = "A",
passenger_rates = c(SNV = 1e-9),
driver_SNVs = c(SNV("22", 10510210, "C")),
driver_CNAs = c(CNA(type = "A", "22", pos_in_chr = 10303470,
len = 200000)))
drivers = list(SNV("22", 10510210, "C"),
CNA(type = "A", chr = "22",
chr_pos = 10303470, len = 200000)))
m_engine
```
Expand Down

0 comments on commit e0ffd00

Please sign in to comment.