# Template for pre_GCA plots
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(tidyr)
library(ggplot2)
library(readr)
source('C:/Users/kmaciag/Desktop/IRF3 Paper - Local/GCA/ggThemeLPinfection.R')
d0 <- read_csv("C:/Users/kmaciag/Desktop/IRF3 Paper - Local/GCA/2013-11-13 WT vs MAVS STING pre-GCA.csv")
## Parsed with column specification:
## cols(
## Timept = col_double(),
## IFNgTiming = col_character(),
## IFNgStim = col_character(),
## Genotype = col_character(),
## BiolRepl = col_double(),
## TechRep1 = col_double(),
## TechRep2 = col_double(),
## TechRep3 = col_double(),
## TechRep4 = col_double(),
## TechRep5 = col_double(),
## TechRep6 = col_double(),
## TechRep7 = col_double(),
## TechRep8 = col_double(),
## TechRep9 = col_double(),
## TechRep10 = col_double()
## )
d <- d0 %>% gather(TechRep, lumi, -Timept, -Genotype, -IFNgTiming, -IFNgStim, -BiolRepl) # melt data
d$Timept <- as.numeric(gsub("[^0-9.]", "", d$Timept)) # delete "hpi" text if present in data table
d <- d[d$Timept!=60,] # exclude selected timepoints
d$log10bact <- log(d$lumi,10) # log transform base 10
noIFNg_rows <- which(d$IFNgStim=="0U") # Save the no-IFNg data
# Factorize. Note that assigning "labels" actually changes values
d$Genotype <- factor(d$Genotype, c("WT","MAVS", "STING"))
d$IFNgTiming<- factor(d$IFNgTiming, c("pre","post", "both"), labels=c(bquote(atop(IFN*gamma*phantom(0)*stim,'prior to infection')), bquote(atop(IFN*gamma*phantom(0)*stim,'during infection')), "both")) #, bquote(atop(IFN*gamm*phantom(0)*stim,'both prior to and during infection'))))
d$IFNgStim <- factor(d$IFNgStim, c("0U","3U", "10U", "100U"), labels=c(expression(paste("No IFN",gamma)),expression(paste("3 U/ml IFN",gamma)),expression(paste("10 U/ml IFN", gamma)),expression(paste("100 U/ml IFN", gamma))))
# other graphic settings
theme_set(ggThemeLPinfection())
##
## Attaching package: 'scales'
## The following object is masked from 'package:readr':
##
## col_factor
##
## Attaching package: 'reshape2'
## The following object is masked from 'package:tidyr':
##
## smiths
## ------------------------------------------------------------------------------
## You have loaded plyr after dplyr - this is likely to cause problems.
## If you need functions from both plyr and dplyr, please load plyr first, then dplyr:
## library(plyr); library(dplyr)
## ------------------------------------------------------------------------------
##
## Attaching package: 'plyr'
## The following objects are masked from 'package:dplyr':
##
## arrange, count, desc, failwith, id, mutate, rename, summarise,
## summarize
## Warning: package 'Cairo' was built under R version 4.0.3
## Warning: `panel.margin` is deprecated. Please use `panel.spacing` property
## instead
MAVS_STINGPalette <- c("#000000", "#E69F00", "#56B4E9") # MAVS/STING KO stay orange and light blue
palette <- MAVS_STINGPalette
GenotypeLegend <- c("C57BL/6J", expression(paste(italic("MAVS"^"-/-"))), expression(paste(italic("STING"^"-/-"))))
# Plot log luminescence data facetted by IFNg stim
ggplot(d, aes(Timept, log10bact, color=Genotype)) +
geom_point(aes(), size=1, position=position_dodge(width = 0.5)) +
scale_color_manual(values=palette, labels=GenotypeLegend) +
labs(x="Time after infection (hours)", y=paste("Bacterial growth","(log10 bioluminescence)", sep='\n'), linetype="Blocking Ab") +
annotate("segment", x=-Inf, xend=Inf, y=-Inf, yend=-Inf)+annotate("segment", x=-Inf, xend=-Inf, y=-Inf, yend=Inf) +
scale_y_continuous(breaks=pretty_breaks(),expand=c(0,1)) +
guides(color = guide_legend(order = 1), linetype = guide_legend(order = 2)) +
coord_cartesian(clip = "off") +
facet_grid(IFNgTiming ~ IFNgStim, labeller=label_parsed)
## Warning: Removed 1083 rows containing missing values (geom_point).

# Plot No IFNg facet only combining pre+post
ggplot(d[noIFNg_rows,], aes(Timept, log10bact, color=Genotype)) +
geom_point(aes(), size=1, position=position_dodge(width = 0.5)) +
scale_color_manual(values=palette, labels=GenotypeLegend) +
labs(x="Time after infection (hours)", y=paste("Bacterial growth","(log10 bioluminescence)", sep='\n'), linetype="Blocking Ab") +
annotate("segment", x=-Inf, xend=Inf, y=-Inf, yend=-Inf)+annotate("segment", x=-Inf, xend=-Inf, y=-Inf, yend=Inf) +
scale_y_continuous(breaks=pretty_breaks(),expand=c(0,1)) +
ggtitle(expression(paste("No IFN",gamma)))
## Warning: Removed 1 rows containing missing values (geom_point).
