From f39a10c9c9b29448979c6ee95760da2d95f96c47 Mon Sep 17 00:00:00 2001 From: Edward Wallace Date: Fri, 11 Oct 2019 21:49:47 +0100 Subject: [PATCH] calibration colkeys and vignette fixes --- NAMESPACE | 2 + R/plate_functions.R | 37 ++++++++++ ...ward_qPCR_Nrd1_calibration_2019-02-02.txt} | 0 ...d_qPCR_Nrd1_calibration_2019-02-02_Ct.txt} | 0 vignettes/calibration_vignette.Rmd | 67 ++++++++++--------- 5 files changed, 73 insertions(+), 33 deletions(-) rename inst/extdata/{Edward qPCR Nrd1 calibration 2019-02-02.txt => Edward_qPCR_Nrd1_calibration_2019-02-02.txt} (100%) rename inst/extdata/{Edward qPCR Nrd1 calibration 2019-02-02 Ct.txt => Edward_qPCR_Nrd1_calibration_2019-02-02_Ct.txt} (100%) diff --git a/NAMESPACE b/NAMESPACE index e053a8a..cb5aa46 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -6,6 +6,8 @@ export(scale_y_log10nice) export(create_blank_plate) export(create_colkey_6in24) +export(create_colkey_4dilutions_mRTNT_in24) +export(create_colkey_6dilutions_mRTNT_in24) export(create_rowkey_4in16) export(create_rowkey_8in16_plain) export(label_plate_rowcol) diff --git a/R/plate_functions.R b/R/plate_functions.R index 4491bad..02e4251 100644 --- a/R/plate_functions.R +++ b/R/plate_functions.R @@ -27,6 +27,43 @@ create_colkey_6in24 <- function(...) { return(colkey) } +create_colkey_4dilutions_mRTNT_in24 <- function( + Dilution=c(1,1/5,1/25,1/125,1,1), + DilutionNice=c("1x","5x","25x","125x","-RT","NT"), + Type=c(rep("+RT",4),"-RT","NT"), + BioRep=rep(c("A","B"),each=12,length.out=24), + TechRep = rep(1:2,each=6,length.out=24)) { + ## creates a 24-column key for primer calibration + ## With 2x BioReps and 2x TechReps + ## 5-fold dilution until 5^4 of +RT; then -RT, NT controls + colkey <- tibble(WellC=1:24, + Dilution=rep(Dilution,4), + DilutionNice=rep(DilutionNice,4), + Type=rep(Type,4) %>% + factor(levels=c("+RT","-RT","NT")), + BioRep=factor(BioRep), + TechRep=factor(TechRep)) + return(colkey) +} + +create_colkey_6dilutions_mRTNT_in24 <- function( + Dilution=c(5^{0:-5},1,1), + DilutionNice=c("1x","5x","25x","125x", + "625x","3125x","-RT","NT"), + Type=c(rep("+RT",6),"-RT","NT"), + TechRep = rep(1:3,each=8,length.out=24)) { + ## creates a 24-column key for primer calibration + ## With 3x TechReps + ## 5-fold dilution until 5^6 of +RT; then -RT, NT controls + colkey <- tibble(WellC=1:24, + Dilution=rep(Dilution,3), + DilutionNice=rep(DilutionNice,3), + Type=rep(Type,3) %>% + factor(levels=c("+RT","-RT","NT")), + TechRep=factor(TechRep)) + return(colkey) +} + create_rowkey_4in16 <- function(...) { ## creates a 16-row key suitable for 4 pieces (samples or target/probe sets) ## example: create_rowkey_4in16(Sample=c("me","you","them","him","her","dog","cat","monkey")) diff --git a/inst/extdata/Edward qPCR Nrd1 calibration 2019-02-02.txt b/inst/extdata/Edward_qPCR_Nrd1_calibration_2019-02-02.txt similarity index 100% rename from inst/extdata/Edward qPCR Nrd1 calibration 2019-02-02.txt rename to inst/extdata/Edward_qPCR_Nrd1_calibration_2019-02-02.txt diff --git a/inst/extdata/Edward qPCR Nrd1 calibration 2019-02-02 Ct.txt b/inst/extdata/Edward_qPCR_Nrd1_calibration_2019-02-02_Ct.txt similarity index 100% rename from inst/extdata/Edward qPCR Nrd1 calibration 2019-02-02 Ct.txt rename to inst/extdata/Edward_qPCR_Nrd1_calibration_2019-02-02_Ct.txt diff --git a/vignettes/calibration_vignette.Rmd b/vignettes/calibration_vignette.Rmd index bb5e55c..b3da9d4 100755 --- a/vignettes/calibration_vignette.Rmd +++ b/vignettes/calibration_vignette.Rmd @@ -64,34 +64,30 @@ theme_set(theme_cowplot(font_size=11) %+replace% ```{r label_plates,dependson="plate_functions"} -Names <- c("ECM38","FET5","GPT2","ILV5","NRD1","RDL1","TFS1") +# Names of target genes +Names <- c("ECM38","FET5","GPT2","ILV5","NRD1","RDL1","TFS1") +# ORF ids of target genes Targets <- c("YLR299W","YFL041W","YKR067W","YLR355C","YNL251C","YOR285W","YLR178C") +# Repeats of gene names to account for resting multiple probesets Namesrep <- c(rep(Names[1:2],each=3),rep(Names[3:7],each=2)) +# id numbers of multiple probesets (reflecting IDs as ordered) Probes <- paste(Namesrep, c(1,2,3,1,3,4,1,4,1,4,1,2,4,5,1,5),sep="_") -Probelevels <- Probes - rowkey <- data.frame(WellR=LETTERS[1:16], Names=Namesrep, # Targets=rep(Targets,each=2), - Probe=Probes + Probe=factor(Probes, levels=Probes) ) -colkey <- data.frame(WellC=1:24, - Dilution=rep(c(1,1/5,1/25,1/125,1,1)), - DilutionNice=rep(c("1x","5x","25x","125x","-RT","NT")), - Type=c(rep("+RT",4),"-RT","NT"), - BioRep=rep(c("A","B"),each=12), - TechRep = rep(c("A","B"),each=6), - RT="SSIV") plate1plan <- label_plate_rowcol( create_blank_plate(), - rowkey,colkey) %>% - mutate(Sample=paste(BioRep,str_sub(RT,end=1L),DilutionNice,sep="_")) + rowkey, + create_colkey_4dilutions_mRTNT_in24()) %>% + mutate(Sample=paste(BioRep,DilutionNice,sep="_")) ``` @@ -110,7 +106,7 @@ display_plate(plate1plan) # read my plates -plates <- read_tsv("../inst/extdata/Edward qPCR Nrd1 calibration 2019-02-02 Ct.txt", +plates <- read_tsv("../inst/extdata/Edward_qPCR_Nrd1_calibration_2019-02-02_Ct.txt", skip=1) %>% mutate(Well=Pos,Ct=Cp) %>% right_join(plate1plan) @@ -136,7 +132,7 @@ ggplot(data=plates) + position=position_jitter(width = 0.2,height=0)) + labs(y="Cycle count to threshold", title="All reps, unnormalized") + - facet_grid(RT~BioRep) + + facet_wrap(~BioRep) + panel_border() + theme(axis.text.x=element_text(angle=90,vjust=0.5)) ``` @@ -189,7 +185,7 @@ ggplot(data=filter(plates,Type=="+RT",Probe %in% Probesnice), ```{r load_amp,dependson="label_plates",results="show"} -plate1curve <- read_tsv("../inst/extdata/Edward qPCR Nrd1 calibration 2019-02-02.txt", +plate1curve <- read_tsv("../inst/extdata/Edward_qPCR_Nrd1_calibration_2019-02-02.txt", skip=2, col_names=c("Well","SID","Program","Segment", "Cycle","Time","Temperature","Fluor") @@ -197,10 +193,15 @@ plate1curve <- read_tsv("../inst/extdata/Edward qPCR Nrd1 calibration 2019-02-02 debaseline() %>% left_join(plate1plan) +# amplification curve is program 2 +platesamp <- plate1curve %>% + filter(Program == 2) -platesamp <- plate1curve %>% filter(Program == 2) - -platesmelt <- plate1curve %>% filter(Program > 2) %>% demelt() %>% filter(Temperature >= 61) +# melt curve is program 3 or 4, depending on cycle +platesmelt <- plate1curve %>% + filter(Program > 2) %>% + demelt() %>% + filter(Temperature >= 61) ``` @@ -218,27 +219,27 @@ ggplot(data=platesamp %>% filter(Well=="A1"), ```{r print_techreps,results="show",echo=TRUE,cache=FALSE,eval="FALSE"} plate1plan %>% - filter(TechRep=="A",Probe==Probes[1],DilutionNice=="1x") + filter(TechRep=="1",Probe==Probes[1],DilutionNice=="1x") plate1plan %>% - filter(TechRep=="B",Probe==Probes[1],DilutionNice=="1x") + filter(TechRep=="2",Probe==Probes[1],DilutionNice=="1x") ``` ```{r plotamp_all,dependson="load_amp",fig.height=11,fig.width=7} ggplot(data=platesamp %>% - filter(TechRep=="A"), + filter(TechRep=="1"), aes(x=Cycle,y=Signal,colour=factor(Dilution),linetype=Type)) + - facet_grid(Probe~RT+BioRep,scales="free_y") + + facet_grid(Probe~BioRep,scales="free_y") + scale_linetype_manual(values=c("+RT"="solid","-RT"="dashed","NT"="dotted")) + geom_line() + scale_x_continuous(breaks=seq(60,100,10),minor_breaks=seq(60,100,5)) + labs(title="All Amp Curves, TechRep A") ggplot(data=platesamp %>% - filter(TechRep=="B"), + filter(TechRep=="2"), aes(x=Cycle,y=Signal,colour=factor(Dilution),linetype=Type)) + - facet_grid(Probe~RT+BioRep,scales="free_y") + + facet_grid(Probe~BioRep,scales="free_y") + scale_linetype_manual(values=c("+RT"="solid","-RT"="dashed","NT"="dotted")) + geom_line() + scale_x_continuous(breaks=seq(60,100,10),minor_breaks=seq(60,100,5)) + @@ -266,16 +267,16 @@ ggplot(data=platesmelt %>% ```{r plotmelt_all,dependson="load_amp",fig.height=11,fig.width=7} ggplot(data=platesmelt %>% - filter(TechRep=="A"), + filter(TechRep=="1"), aes(x=Temperature,y=dRdT,colour=factor(Dilution),linetype=Type)) + - facet_grid(Probe~RT+BioRep,scales="free_y") + + facet_grid(Probe~BioRep,scales="free_y") + scale_linetype_manual(values=c("+RT"="solid","-RT"="dashed","NT"="dotted")) + geom_line() + scale_x_continuous(breaks=seq(60,100,10),minor_breaks=seq(60,100,5)) + labs(title="All Melt Curves, TechRep A") ggplot(data=platesmelt %>% - filter(TechRep=="B"), + filter(TechRep=="2"), aes(x=Temperature,y=dRdT,colour=factor(Dilution),linetype=Type)) + facet_grid(Probe~BioRep,scales="free_y") + scale_linetype_manual(values=c("+RT"="solid","-RT"="dashed","NT"="dotted")) + @@ -290,7 +291,7 @@ ggplot(data=platesmelt %>% ```{r plotmelt_SS_zoomed,dependson="load_amp",fig.height=11,fig.width=7} ggplot(data=platesmelt %>% - filter(TechRep=="A",Type=="+RT"), + filter(TechRep=="1",Type=="+RT"), aes(x=Temperature,y=dRdT,colour=factor(Dilution))) + facet_grid(Probe~BioRep,scales="free_y") + geom_line() + @@ -301,9 +302,9 @@ ggplot(data=platesmelt %>% panel.grid.minor.x=element_line(colour="grey70",size=0.1)) ggplot(data=platesmelt %>% - filter(TechRep=="B",Type=="+RT",RT=="SSIV"), + filter(TechRep=="2",Type=="+RT"), aes(x=Temperature,y=dRdT,colour=factor(Dilution))) + - facet_grid(Probe~RT+BioRep,scales="free_y") + + facet_grid(Probe~BioRep,scales="free_y") + geom_line() + scale_x_continuous(breaks=seq(60,100,5),minor_breaks=seq(60,100,1), limits=c(73,87)) + @@ -319,14 +320,14 @@ ggplot(data=platesmelt %>% ```{r plotmelt_SS_zoomed_nice,dependson="load_amp",fig.height=6,fig.width=4} Probesnice <- c("ECM38_3","FET5_1","GPT2_4","ILV5_4","NRD1_1","RDL1_4","TFS1_1") ggplot(data=platesmelt %>% - filter(TechRep=="A",Type=="+RT",DilutionNice=="1x", + filter(TechRep=="1",Type=="+RT",DilutionNice=="1x", Probe %in% Probesnice), aes(x=Temperature,y=dRdT,colour=BioRep)) + facet_grid(Probe~.,scales="free_y") + geom_line() + scale_x_continuous(breaks=seq(60,100,5),minor_breaks=seq(60,100,1), limits=c(73,87)) + - labs(title="Melt curves, zoomed, Nice probes, TechRep A") + + labs(title="Nice probes, TechRep A") + theme(panel.grid.major.x=element_line(colour="grey50",size=0.4), panel.grid.minor.x=element_line(colour="grey70",size=0.1)) ```