This notebook attempts to compile all the information from the Pseudomonas mouse lung infection experiment.

library(pacman)

p_load(data.table, tidyverse, edgeR, poolr, scales, pheatmap, viridis, ggallin)
source("cleanup_analysis.R")
Joining with `by = join_by(sequence)`Joining with `by = join_by(guide_name)`Adding missing grouping variables: `type`Joining with `by = join_by(locus_tag)`Joining with `by = join_by(locus_tag, gene, type)`Joining with `by = join_by(condition)`Joining with `by = join_by(sequence)``summarise()` has grouped output by 'condition'. You can override using the `.groups` argument.Joining with `by = join_by(condition)`Joining with `by = join_by(condition, media, gDNA_source, reads, match_prop)`Joining with `by = join_by(sequence)`Joining with `by = join_by(condition)`
[1] "Processing results for plated_6_generations_LB - plated_t0_inoculum ..."
[1] "Processing results for plated_10x_inoculum_dilution_mouse - plated_t0_inoculum ..."
[1] "Processing results for plated_10x_inoculum_dilution_mouse - plated_6_generations_LB ..."

melted_results %>%
  mutate(condition = case_when(
    condition == "plated_10x_inoculum_dilution_mouse - plated_t0_inoculum" ~ "In vivo",
    condition == "plated_10x_inoculum_dilution_mouse - plated_6_generations_LB" ~ "In vivo v. in vitro",
    condition == "plated_6_generations_LB - plated_t0_inoculum" ~ "In vitro"
  )) %>%
  ggplot(aes(x = LFC, y = FDR)) +
  geom_point(alpha = 0.25) +
  facet_grid(type ~ condition) +
  theme(legend.position = "bottom") +
  scale_y_continuous(trans = scales::reverse_trans() %of% scales::log10_trans()) +
    theme_minimal()

melted_results %>%
  filter(FDR <= 0.05) %>%
  mutate(condition = case_when(
    condition == "plated_10x_inoculum_dilution_mouse - plated_t0_inoculum" ~ "In vivo",
    condition == "plated_10x_inoculum_dilution_mouse - plated_6_generations_LB" ~ "In vivo v. in vitro",
    condition == "plated_6_generations_LB - plated_t0_inoculum" ~ "In vitro"
  )) %>%
  ggplot(aes(x = LFC)) +
  geom_density() +
  geom_vline(xintercept = c(-1, 1), linetype = "dashed") +
  facet_grid(type ~ condition) +
  ggtitle("Density of log2 fold changes for GUIDES with FDR <= 0.05") +
    theme_minimal()

LS0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