library(tidyverse)
library(ggplot2)
library(ggpubr)#Read in sequencing count data
LRIIIReads <- read.table("/Volumes/Macintosh HD/Users/gregg/Downloads/LRIII.txt",
header=FALSE, stringsAsFactors = FALSE, na.strings = "")
#adjust names back to simple sample names
LRIIIReads <- separate(LRIIIReads, 2, sep="[.]", into = c(NA, "samplename", NA, NA, NA, NA, NA, NA, NA))
#remove the total line and rename columns
LRIIIReads <- LRIIIReads[(1:144),]
colnames(LRIIIReads) <- c("readsx4", "samplename")
#Divide read count by 4 to get the proper number
LRIIIReads$readsk <- LRIIIReads$readsx4 / 4
#Add the replicates together
LRIIIReads <- LRIIIReads %>%
group_by(samplename) %>%
summarise(reads = sum(readsk))
#read in the qPCR data, subset columns to sample name, mean qty, and standard deviation
DGqPCR <- read.csv("/Volumes/Macintosh HD/Users/gregg/Downloads/5DG5_COL456.csv",
header=TRUE, stringsAsFactors = FALSE, na.strings = "", skip =14 )
DGqPCR <- DGqPCR[ , c(2, 8, 9)]
DGqPCR$plate <- "5DG5"
LVDqPCR <- read.csv("/Volumes/Macintosh HD/Users/gregg/Downloads/5LVD5_Col123.csv",
header=TRUE, stringsAsFactors = FALSE, na.strings = "", skip =14 )
LVDqPCR <- LVDqPCR[ , c(2, 8, 9)]
LVDqPCR$plate <- "5LVD5"
MCqPCR <- read.csv("/Volumes/Macintosh HD/Users/gregg/Downloads/MC_MB_Comparison.csv",
header=TRUE, stringsAsFactors = FALSE, na.strings = "", skip =14 )
MCqPCR <- MCqPCR[ , c(2, 8, 9)]
MCqPCR$plate <- "MC"
#adjust to match naming conventionsbetween files
MCqPCR[,1] <- gsub("MC_A", "MCA_", MCqPCR[,1])
MCqPCR[,1] <- gsub("MC_B", "MCB_", MCqPCR[,1])
MCqPCR[,1] <- gsub("MC_C", "MCC_", MCqPCR[,1])
MCqPCR[,1] <- gsub("MC_D", "MCD_", MCqPCR[,1])
#combine data
qPCR <- rbind(DGqPCR, LVDqPCR, MCqPCR)
#reduce to one incidence of each sample
qPCR <- qPCR %>%
group_by(Sample.Name) %>%
slice(1)
colnames(qPCR) <- c("samplename", "mean", "stddev", "plate")
#combine qPCR and read data together
LRIIIReads <- left_join(LRIIIReads, qPCR, by = "samplename")
#plot reads vs qPCR qty mean
ggplot(LRIIIReads, aes(readsmean, meanreads, color=plate, shape=plate))+
geom_point(show.legend = TRUE)+
geom_errorbar(aes(yminxmin=mean-stddev, ymaxxmax=mean+stddev), width=.2)+
geom_smooth(method='lm', formula= y~x)+
stat_regline_equation(label.y = 250200000, aes(label = ..eq.label..)) +
stat_regline_equation(label.y = 150150000, aes(label = ..rr.label..))+
facet_wrap(~plate) |