Last updated: 2022-05-20

Checks: 5 1

Knit directory: combiDLBCL/analysis/

This reproducible R Markdown analysis was created with workflowr (version 1.7.0). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20220425) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.

Tracking code development and connecting the code version to the results is critical for reproducibility. To start using Git, open the Terminal and type git init in your project directory.


This project is not being versioned with Git. To obtain the full reproducibility benefits of using workflowr, please see ?wflow_start.


Load libraries and datasets

Preprocess

Only use CHP_Pola plates

screenSub <- filter(screenData, Drug_B == "CHP_Pola")

Create input

allPair <- distinct(screenSub, Name, Drug_A) %>%
  filter(Drug_A != "DMSO")
allInput <- lapply(seq(nrow(allPair)), function(i) {
  n <- allPair[i,]$Name
  m <- allPair[i,]$Drug_A
  viabTab <- filter(screenSub, Name == n) %>%
    select(Drug_A, Drug_B, Drug_A.Conc, Drug_B.Conc, normVal)
  bTab <- filter(viabTab, Drug_A == "DMSO")
  aTab <- filter(viabTab, Drug_A == m)
  testViab <- bind_rows(aTab, bTab)
  y <- as.matrix(data.frame(viability=testViab$normVal))
  x = as.matrix(testViab[,c("Drug_A.Conc","Drug_B.Conc")])
  list(y=y, x=x, drug_names = c(m,n), experiment_ID = paste0(n,"_",m))
})

Fit bayesynergy model

fit <- synergyscreen(allInput, save_raw = F, save_plots = F, bayesynergy_params = list(method = "vb"))
save(fit, file = "../output/fit.RData")

Load previous results (fitting takes long time)

load("../output/fit.RData")

Get the result table

allRes <- fit$screenSummary
ciTabBayes <- tibble(Name = allRes$`Drug B`,
                 Drug_A = allRes$`Drug A`, 
                 syn = allRes$`Synergy (mean)`,
                 anta = allRes$`Antagonism (mean)`
                 #syn = allRes$`Synergy Score`,
                 #anta = allRes$`Antagonism Score`
                 )

Visualization of synergistic and antagoistic effect

Scatter plot

plotSynScatter(ciTabBayes, 0.05)

Matrix visualization

plotSynMatrix(ciTabBayes, 0.1, 0.2)

Correlate summarised CI to the single angent response of CHP_Pola

Add single agent CHP_Pola or CHOP response

polaTab <- screenData %>% filter(Drug_A == "DMSO", Drug_B == "CHP_Pola",!ifEdge) %>%
  group_by(Name) %>% summarise(viabPola = mean(normVal))

Test for correlation

testTab <- left_join(ciTabBayes, polaTab, by = "Name") %>%
  pivot_longer(c("viabPola"), names_to = "Drug_B", values_to = "viab") %>%
  pivot_longer(c("syn","anta"), names_to = "effect", values_to = "score")

resTab <- group_by(testTab, Drug_A, Drug_B, effect) %>% nest() %>%
  mutate(m=map(data, ~cor.test(~score+viab,.))) %>%
  mutate(res = map(m, broom::tidy)) %>%
  unnest(res) %>%
  select(Drug_A, Drug_B, estimate, p.value, effect) %>%
  ungroup() %>% group_by(effect) %>%
  mutate(p.adj = p.adjust(p.value, method = "BH")) %>%
  arrange(p.value)

Correlation with synergistic

resTab.syn <- filter(resTab, p.adj <0.1, effect == "syn")
pList <- lapply(seq(nrow(resTab.syn)), function(i) {
  rec <- resTab.syn[i,]
  plotTab <- filter(testTab, Drug_A == rec$Drug_A, Drug_B==rec$Drug_B, effect == rec$effect)
  ggplot(plotTab, aes(x=viab, y=score, label = Name)) +
    geom_point(aes(col=Name)) +
    geom_smooth(method = "lm",se=FALSE) +
    ggrepel::geom_text_repel() +
    theme(legend.position = "none") +
    xlab(rec$Drug_B) + ylab("average CI") +
    ggtitle(sprintf("%s\n(p=%s, coef=%s)",rec$Drug_A, formatC(rec$p.value, digits = 2),formatC(rec$estimate, digits = 1)))
})
cowplot::plot_grid(plotlist=pList)
`geom_smooth()` using formula 'y ~ x'
`geom_smooth()` using formula 'y ~ x'
`geom_smooth()` using formula 'y ~ x'
`geom_smooth()` using formula 'y ~ x'
`geom_smooth()` using formula 'y ~ x'
`geom_smooth()` using formula 'y ~ x'
`geom_smooth()` using formula 'y ~ x'
`geom_smooth()` using formula 'y ~ x'
Warning: ggrepel: 1 unlabeled data points (too many overlaps). Consider increasing max.overlaps
ggrepel: 1 unlabeled data points (too many overlaps). Consider increasing max.overlaps

Correlation with antagonistic

resTab.anta <- filter(resTab, p.adj <0.1, effect == "anta")
pList <- lapply(seq(nrow(resTab.anta)), function(i) {
  rec <- resTab.anta[i,]
  plotTab <- filter(testTab, Drug_A == rec$Drug_A, Drug_B==rec$Drug_B, effect == rec$effect)
  ggplot(plotTab, aes(x=viab, y=score, label = Name)) +
    geom_point(aes(col=Name)) +
    geom_smooth(method = "lm",se=FALSE) +
    ggrepel::geom_text_repel() +
    theme(legend.position = "none") +
    xlab(rec$Drug_B) + ylab("average CI") +
    ggtitle(sprintf("%s\n(p=%s, coef=%s)",rec$Drug_A, formatC(rec$p.value, digits = 2),formatC(rec$estimate, digits = 1)))
})
cowplot::plot_grid(plotlist=pList)
`geom_smooth()` using formula 'y ~ x'
`geom_smooth()` using formula 'y ~ x'
`geom_smooth()` using formula 'y ~ x'
`geom_smooth()` using formula 'y ~ x'
`geom_smooth()` using formula 'y ~ x'
`geom_smooth()` using formula 'y ~ x'
`geom_smooth()` using formula 'y ~ x'
`geom_smooth()` using formula 'y ~ x'
`geom_smooth()` using formula 'y ~ x'
`geom_smooth()` using formula 'y ~ x'
`geom_smooth()` using formula 'y ~ x'
`geom_smooth()` using formula 'y ~ x'
`geom_smooth()` using formula 'y ~ x'
`geom_smooth()` using formula 'y ~ x'
`geom_smooth()` using formula 'y ~ x'
Warning: ggrepel: 13 unlabeled data points (too many overlaps). Consider
increasing max.overlaps
Warning: ggrepel: 16 unlabeled data points (too many overlaps). Consider
increasing max.overlaps
Warning: ggrepel: 12 unlabeled data points (too many overlaps). Consider
increasing max.overlaps
Warning: ggrepel: 13 unlabeled data points (too many overlaps). Consider
increasing max.overlaps
Warning: ggrepel: 11 unlabeled data points (too many overlaps). Consider
increasing max.overlaps
Warning: ggrepel: 8 unlabeled data points (too many overlaps). Consider
increasing max.overlaps
Warning: ggrepel: 17 unlabeled data points (too many overlaps). Consider
increasing max.overlaps
Warning: ggrepel: 15 unlabeled data points (too many overlaps). Consider increasing max.overlaps
ggrepel: 15 unlabeled data points (too many overlaps). Consider increasing max.overlaps
Warning: ggrepel: 16 unlabeled data points (too many overlaps). Consider
increasing max.overlaps
Warning: ggrepel: 13 unlabeled data points (too many overlaps). Consider
increasing max.overlaps
Warning: ggrepel: 14 unlabeled data points (too many overlaps). Consider
increasing max.overlaps
Warning: ggrepel: 11 unlabeled data points (too many overlaps). Consider
increasing max.overlaps
Warning: ggrepel: 12 unlabeled data points (too many overlaps). Consider
increasing max.overlaps
Warning: ggrepel: 8 unlabeled data points (too many overlaps). Consider
increasing max.overlaps