<jupyter_start><jupyter_text>Allele frequency distribution plot for filtered variants<jupyter_code># Housekeeping

require(ggplot2)
source("source.R")
# Read in data

variants = read.table("../../data/deep_seq/filtered_variant_data.txt", 
                      sep = "\t", 
                      header = T)
# Code to make plot prettier

variants$SPECIES = gsub("_", " ", variants$SPECIES)

variants$TREAT = paste(variants$ANTIBIOTIC, variants$IMMIGRATION, variants$TIME, variants$REPLICATE, sep = "_")
a = as.factor(unique(variants$TREAT))
variants$TREAT = factor(variants$TREAT, levels = a)
variants$ABIM = paste(variants$ANTIBIOTIC, variants$IMMIGRATION, sep = "_")
variants$ABIM = factor(variants$ABIM, levels = c("0_0",
                                                 "0_1",
                                                 "4_0",
                                                 "4_1",
                                                 "16_0",
                                                 "16_1",
                                                 "128_0",
                                                 "128_1"),
                       labels = c(expression(atop(paste(0~mu*g*' mL'^-1," Sm"), "No immigration")),
                                  expression(atop(paste(0~mu*g*' mL'^-1," Sm"), "Immigration")),
                                  expression(atop(paste(4~mu*g*' mL'^-1," Sm"), "No immigration")),
                                  expression(atop(paste(4~mu*g*' mL'^-1," Sm"), "Immigration")),
                                  expression(atop(paste(16~mu*g*' mL'^-1," Sm"), "No immigration")),
                                  expression(atop(paste(16~mu*g*' mL'^-1," Sm"), "Immigration")),
                                  expression(atop(paste(128~mu*g*' mL'^-1," Sm"), "No immigration")),
                                  expression(atop(paste(128~mu*g*' mL'^-1," Sm"), "Immigration"))))
# Plot code

p1 = ggplot(variants[variants$VARIANT_FREQUENCY > 0,], aes(x = VARIANT_FREQUENCY, fill = SPECIES)) + 
    geom_histogram(bins = 10) +
    facet_grid(SPECIES~ABIM, scales = "free_y",  labeller = label_parsed)+
    scale_fill_manual(values = mycolors) +
    guides(fill = guide_legend(title = "Species")) +
    scale_x_continuous(breaks = seq(0, 1, len = 11)) +
    ylab("Count") +
    xlab("Variant frequency") +
    theme(axis.text.x = element_text(angle = 90, hjust = 1),
          strip.text.y = element_blank())
p1
# Write out

ggsave("../../manuscript/figures/variant_frequency_distribution.pdf", width = 12, height = 9)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14849187935034802, 'fraction_numerical': 0.02320185614849188, 'mean_word_length': 1.824235807860262, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 21, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '260089', 'license': 'MIT', 'n_tokens_mistral': 852, 'n_tokens_neox': 781, 'n_words': 135, 'path': 'src/notebooks/.ipynb_checkpoints/allele_frequency_distribution_plot-checkpoint.ipynb', 'repo_name': 'johannescairns/repeatable_dynamics', 'size': '2586'}