#____________________________________________________________________________# # R-code provided for the research article: # # # Title: #Environmental-DNA primer-probe systems for detection of three species of crayfish (Decapoda -Astacidea) in Scandinavia #Authors: #Sune Agersnap, William B. Larsen, Steen Wilhelm Knudsen, David Strand, Philip Francis Thomsen, Martin Hesselsøe, Peter B. Mortensen, Trude Vrålstad, Peter Rask Møller # #################################################################################### # # #READ THE SECTION BELOW FIRST, BEFORE EXECUTING THE R-CODE # # #################################################################################### # Change the working directory to a path on your own computer , and run # the individual parts below to reproduce the diagrams presented in the paper # # All input data required is supplied within this R-code. # # Occassionally the code will have difficulties producing the correct diagrams, # if the packages and libraries are not installed. # Make sure the packages are installed, and libraries are loaded, if the R-code # fails in producing the diagrams. # #This R-code can be executed in R-studio : Version 0.98.994 – © 2009-2013 RStudio, Inc. # #____________________________________________________________________________# # set working directory (change this to a different directory on your own computer) setwd ("/Users/steenknudsen/r_test_eDNA") getwd() krebse_drenge_qpcr_02 <- read.table(header=T, sep=",", text=" ct_dRn_zero,quantitity_zero,Sample_type,Species,spec_Sampl_type,spec_no,sampl_no 11.76,500000000,STD,Lepto_III,Lepto_III_STD,1,1 11.96,500000000,STD,Lepto_III,Lepto_III_STD,1,1 9.11,500000000,STD,Lepto_III,Lepto_III_STD,1,1 10.84,500000000,STD,Lepto_III,Lepto_III_STD,1,1 13.97,50000000,STD,Lepto_III,Lepto_III_STD,1,1 13.96,50000000,STD,Lepto_III,Lepto_III_STD,1,1 13.59,50000000,STD,Lepto_III,Lepto_III_STD,1,1 11.93,50000000,STD,Lepto_III,Lepto_III_STD,1,1 18.85,5000000,STD,Lepto_III,Lepto_III_STD,1,1 17.18,5000000,STD,Lepto_III,Lepto_III_STD,1,1 17.42,5000000,STD,Lepto_III,Lepto_III_STD,1,1 21.68,500000,STD,Lepto_III,Lepto_III_STD,1,1 21.46,500000,STD,Lepto_III,Lepto_III_STD,1,1 20.12,500000,STD,Lepto_III,Lepto_III_STD,1,1 24.31,50000,STD,Lepto_III,Lepto_III_STD,1,1 24.98,50000,STD,Lepto_III,Lepto_III_STD,1,1 26.09,50000,STD,Lepto_III,Lepto_III_STD,1,1 28.22,5000,STD,Lepto_III,Lepto_III_STD,1,1 29.37,5000,STD,Lepto_III,Lepto_III_STD,1,1 28.4,5000,STD,Lepto_III,Lepto_III_STD,1,1 32.3,500,STD,Lepto_III,Lepto_III_STD,1,1 31.87,500,STD,Lepto_III,Lepto_III_STD,1,1 32.33,500,STD,Lepto_III,Lepto_III_STD,1,1 36.05,50,STD,Lepto_III,Lepto_III_STD,1,1 36.35,50,STD,Lepto_III,Lepto_III_STD,1,1 35.86,50,STD,Lepto_III,Lepto_III_STD,1,1 0,0,STD,Lepto_III,Lepto_III_STD,1,1 36.26,5,STD,Lepto_III,Lepto_III_STD,1,1 38.11,5,STD,Lepto_III,Lepto_III_STD,1,1 0,0,STD,Lepto_III,Lepto_III_STD,1,1 45.96,0.5,STD,Lepto_III,Lepto_III_STD,1,1 0,0,STD,Lepto_III,Lepto_III_STD,1,1 0,0,blank,Lepto_III,Lepto_III_blank,1,2 0,0,blank,Lepto_III,Lepto_III_blank,1,2 23.63,112000,tissue,Lepto_III,Lepto_III_tissue,1,3 23.42,127500,tissue,Lepto_III,Lepto_III_tissue,1,3 0,0,AGE,Lepto_III,Lepto_III_AGE,1,4 0,0,AGE,Lepto_III,Lepto_III_AGE,1,4 34.15,139.9,AGE,Lepto_III,Lepto_III_AGE,1,4 34.92,85.58,AGE,Lepto_III,Lepto_III_AGE,1,4 0,0,LOJ,Lepto_III,Lepto_III_LOJ,1,5 0,0,LOJ,Lepto_III,Lepto_III_LOJ,1,5 0,0,LOJ,Lepto_III,Lepto_III_LOJ,1,5 0,0,LOJ,Lepto_III,Lepto_III_LOJ,1,5 29.41,2847,DAM,Lepto_III,Lepto_III_DAM,1,6 29.34,2971,DAM,Lepto_III,Lepto_III_DAM,1,6 27.84,7703,DAM,Lepto_III,Lepto_III_DAM,1,6 27.71,8367,DAM,Lepto_III,Lepto_III_DAM,1,6 0,0,SKT,Lepto_III,Lepto_III_SKT,1,7 0,0,SKT,Lepto_III,Lepto_III_SKT,1,7 0,0,SKT,Lepto_III,Lepto_III_SKT,1,7 0,0,SKT,Lepto_III,Lepto_III_SKT,1,7 0,0,NYD,Lepto_III,Lepto_III_NYD,1,8 0,0,NYD,Lepto_III,Lepto_III_NYD,1,8 0,0,NYD,Lepto_III,Lepto_III_NYD,1,8 0,0,NYD,Lepto_III,Lepto_III_NYD,1,8 0,0,LER,Lepto_III,Lepto_III_LER,1,9 41.01,1.79,LER,Lepto_III,Lepto_III_LER,1,9 0,0,LER,Lepto_III,Lepto_III_LER,1,9 0,0,LER,Lepto_III,Lepto_III_LER,1,9 0,0,FUR,Lepto_III,Lepto_III_FUR,1,10 0,0,FUR,Lepto_III,Lepto_III_FUR,1,10 0,0,FUR,Lepto_III,Lepto_III_FUR,1,10 0,0,FUR,Lepto_III,Lepto_III_FUR,1,10 33.66,190.6,FUG,Lepto_III,Lepto_III_FUG,1,11 33.99,154.2,FUG,Lepto_III,Lepto_III_FUG,1,11 33.05,280,FUG,Lepto_III,Lepto_III_FUG,1,11 32.98,292.7,FUG,Lepto_III,Lepto_III_FUG,1,11 33.43,221.1,DAMG,Lepto_III,Lepto_III_DAMG,1,12 33.13,266.8,DAMG,Lepto_III,Lepto_III_DAMG,1,12 36.06,41.39,DAMG,Lepto_III,Lepto_III_DAMG,1,12 34.21,134.3,DAMG,Lepto_III,Lepto_III_DAMG,1,12 0,0,NYDG,Lepto_III,Lepto_III_NYDG,1,13 38.01,12.02,NYDG,Lepto_III,Lepto_III_NYDG,1,13 0,0,NYDG,Lepto_III,Lepto_III_NYDG,1,13 0,0,NYDG,Lepto_III,Lepto_III_NYDG,1,13 0,0,exbl,Lepto_III,Lepto_III_exbl,1,14 0,0,exbl,Lepto_III,Lepto_III_exbl,1,14 0,0,exbl,Lepto_III,Lepto_III_exbl,1,14 0,0,exbl,Lepto_III,Lepto_III_exbl,1,14 32.84,319.9,exbl,Lepto_III,Lepto_III_exbl,1,14 0,0,exbl,Lepto_III,Lepto_III_exbl,1,14 0,0,none,Astast,Astast_none,2,0 10.34,500000000,STD,Astast,Astast_STD,2,1 9.84,500000000,STD,Astast,Astast_STD,2,1 10.54,500000000,STD,Astast,Astast_STD,2,1 10.4,500000000,STD,Astast,Astast_STD,2,1 13.96,50000000,STD,Astast,Astast_STD,2,1 14.22,50000000,STD,Astast,Astast_STD,2,1 14.18,50000000,STD,Astast,Astast_STD,2,1 14.07,50000000,STD,Astast,Astast_STD,2,1 17.36,5000000,STD,Astast,Astast_STD,2,1 17.29,5000000,STD,Astast,Astast_STD,2,1 17.31,5000000,STD,Astast,Astast_STD,2,1 20.4,500000,STD,Astast,Astast_STD,2,1 21.36,500000,STD,Astast,Astast_STD,2,1 20.94,500000,STD,Astast,Astast_STD,2,1 24.7,50000,STD,Astast,Astast_STD,2,1 24.68,50000,STD,Astast,Astast_STD,2,1 24.48,50000,STD,Astast,Astast_STD,2,1 27.86,5000,STD,Astast,Astast_STD,2,1 27.96,5000,STD,Astast,Astast_STD,2,1 27.82,5000,STD,Astast,Astast_STD,2,1 31.88,500,STD,Astast,Astast_STD,2,1 31.45,500,STD,Astast,Astast_STD,2,1 31.59,500,STD,Astast,Astast_STD,2,1 35.55,50,STD,Astast,Astast_STD,2,1 35.22,50,STD,Astast,Astast_STD,2,1 33.28,50,STD,Astast,Astast_STD,2,1 37.43,5,STD,Astast,Astast_STD,2,1 38,5,STD,Astast,Astast_STD,2,1 0,0,STD,Astast,Astast_STD,2,1 0,0,STD,Astast,Astast_STD,2,1 0,0,STD,Astast,Astast_STD,2,1 38.47,0.5,STD,Astast,Astast_STD,2,1 0,0,blank,Astast,Astast_blank,2,2 0,0,blank,Astast,Astast_blank,2,2 25.03,29130,tissue,Astast,Astast_tissue,2,3 25.24,25340,tissue,Astast,Astast_tissue,2,3 35.07,31.59,AGE,Astast,Astast_AGE,2,4 0,0,AGE,Astast,Astast_AGE,2,4 0,0,AGE,Astast,Astast_AGE,2,4 0,0,AGE,Astast,Astast_AGE,2,4 36.23,14.39,LOJ,Astast,Astast_LOJ,2,5 36.89,9.19,LOJ,Astast,Astast_LOJ,2,5 36.44,12.43,LOJ,Astast,Astast_LOJ,2,5 36.78,9.86,LOJ,Astast,Astast_LOJ,2,5 0,0,DAM,Astast,Astast_DAM,2,6 0,0,DAM,Astast,Astast_DAM,2,6 0,0,DAM,Astast,Astast_DAM,2,6 0,0,DAM,Astast,Astast_DAM,2,6 39.85,1.23,SKT,Astast,Astast_SKT,2,7 35.78,19.46,SKT,Astast,Astast_SKT,2,7 38.81,2.49,SKT,Astast,Astast_SKT,2,7 38.72,2.64,SKT,Astast,Astast_SKT,2,7 0,0,NYD,Astast,Astast_NYD,2,8 0,0,NYD,Astast,Astast_NYD,2,8 0,0,NYD,Astast,Astast_NYD,2,8 0,0,NYD,Astast,Astast_NYD,2,8 0,0,LER,Astast,Astast_LER,2,9 0,0,LER,Astast,Astast_LER,2,9 0,0,LER,Astast,Astast_LER,2,9 0,0,LER,Astast,Astast_LER,2,9 0,0,FUR,Astast,Astast_FUR,2,10 0,0,FUR,Astast,Astast_FUR,2,10 0,0,FUR,Astast,Astast_FUR,2,10 0,0,FUR,Astast,Astast_FUR,2,10 40.51,0.7829,FUG,Astast,Astast_FUG,2,11 0,0,FUG,Astast,Astast_FUG,2,11 0,0,FUG,Astast,Astast_FUG,2,11 0,0,FUG,Astast,Astast_FUG,2,11 0,0,DAMG,Astast,Astast_DAMG,2,12 38.11,3.99,DAMG,Astast,Astast_DAMG,2,12 0,0,DAMG,Astast,Astast_DAMG,2,12 0,0,DAMG,Astast,Astast_DAMG,2,12 0,0,NYDG,Astast,Astast_NYDG,2,13 0,0,NYDG,Astast,Astast_NYDG,2,13 0,0,NYDG,Astast,Astast_NYDG,2,13 0,0,NYDG,Astast,Astast_NYDG,2,13 0,0,exbl,Astast,Astast_exbl,2,14 0,0,exbl,Astast,Astast_exbl,2,14 0,0,exbl,Astast,Astast_exbl,2,14 0,0,exbl,Astast,Astast_exbl,2,14 0,0,exbl,Astast,Astast_exbl,2,14 0,0,exbl,Astast,Astast_exbl,2,14 0,3.64E+11,blank,Astast,Astast_blank,2,2 0,3.64E+11,blank,Astast,Astast_blank,2,2 0,3.64E+11,blank,Astast,Astast_blank,2,2 0,3.64E+11,blank,Astast,Astast_blank,2,2 0,3.64E+11,blank,Astast,Astast_blank,2,2 0,3.64E+11,blank,Astast,Astast_blank,2,2 0,0,none,Paclen,Paclen_none,3,0 9.81,500000000,STD,Paclen,Paclen_STD,3,1 9.69,500000000,STD,Paclen,Paclen_STD,3,1 9.82,500000000,STD,Paclen,Paclen_STD,3,1 9.89,500000000,STD,Paclen,Paclen_STD,3,1 13.18,50000000,STD,Paclen,Paclen_STD,3,1 13.54,50000000,STD,Paclen,Paclen_STD,3,1 12.93,50000000,STD,Paclen,Paclen_STD,3,1 13.04,50000000,STD,Paclen,Paclen_STD,3,1 15.94,5000000,STD,Paclen,Paclen_STD,3,1 15.77,5000000,STD,Paclen,Paclen_STD,3,1 16.22,5000000,STD,Paclen,Paclen_STD,3,1 19.95,500000,STD,Paclen,Paclen_STD,3,1 19.91,500000,STD,Paclen,Paclen_STD,3,1 19.36,500000,STD,Paclen,Paclen_STD,3,1 22.9,50000,STD,Paclen,Paclen_STD,3,1 22.98,50000,STD,Paclen,Paclen_STD,3,1 22.97,50000,STD,Paclen,Paclen_STD,3,1 26.62,5000,STD,Paclen,Paclen_STD,3,1 26.15,5000,STD,Paclen,Paclen_STD,3,1 25.9,5000,STD,Paclen,Paclen_STD,3,1 30.07,500,STD,Paclen,Paclen_STD,3,1 30.05,500,STD,Paclen,Paclen_STD,3,1 30.02,500,STD,Paclen,Paclen_STD,3,1 33.77,50,STD,Paclen,Paclen_STD,3,1 33.46,50,STD,Paclen,Paclen_STD,3,1 34.15,50,STD,Paclen,Paclen_STD,3,1 37.85,5,STD,Paclen,Paclen_STD,3,1 0,0,STD,Paclen,Paclen_STD,3,1 36.91,5,STD,Paclen,Paclen_STD,3,1 0,0,STD,Paclen,Paclen_STD,3,1 0,0,STD,Paclen,Paclen_STD,3,1 0,0,STD,Paclen,Paclen_STD,3,1 0,0,blank,Paclen,Paclen_blank,3,2 0,0,blank,Paclen,Paclen_blank,3,2 22.32,92460,tissue,Paclen,Paclen_tissue,3,3 22.15,103400,tissue,Paclen,Paclen_tissue,3,3 0,0,AGE,Paclen,Paclen_AGE,3,4 0,0,AGE,Paclen,Paclen_AGE,3,4 0,0,AGE,Paclen,Paclen_AGE,3,4 0,0,AGE,Paclen,Paclen_AGE,3,4 0,0,LOJ,Paclen,Paclen_LOJ,3,5 0,0,LOJ,Paclen,Paclen_LOJ,3,5 0,0,LOJ,Paclen,Paclen_LOJ,3,5 0,0,LOJ,Paclen,Paclen_LOJ,3,5 0,0,DAM,Paclen,Paclen_DAM,3,6 0,0,DAM,Paclen,Paclen_DAM,3,6 0,0,DAM,Paclen,Paclen_DAM,3,6 0,0,DAM,Paclen,Paclen_DAM,3,6 0,0,SKT,Paclen,Paclen_SKT,3,7 0,0,SKT,Paclen,Paclen_SKT,3,7 0,0,SKT,Paclen,Paclen_SKT,3,7 0,0,SKT,Paclen,Paclen_SKT,3,7 0,0,NYD,Paclen,Paclen_NYD,3,8 0,0,NYD,Paclen,Paclen_NYD,3,8 0,0,NYD,Paclen,Paclen_NYD,3,8 0,0,NYD,Paclen,Paclen_NYD,3,8 35.2,16.14,LER,Paclen,Paclen_LER,3,9 36.44,7.01,LER,Paclen,Paclen_LER,3,9 34.35,28.62,LER,Paclen,Paclen_LER,3,9 35.78,10.94,LER,Paclen,Paclen_LER,3,9 0,0,FUR,Paclen,Paclen_FUR,3,10 0,0,FUR,Paclen,Paclen_FUR,3,10 0,0,FUR,Paclen,Paclen_FUR,3,10 0,0,FUR,Paclen,Paclen_FUR,3,10 0,0,FUG,Paclen,Paclen_FUG,3,11 0,0,FUG,Paclen,Paclen_FUG,3,11 0,0,FUG,Paclen,Paclen_FUG,3,11 0,0,FUG,Paclen,Paclen_FUG,3,11 0,0,DAMG,Paclen,Paclen_DAMG,3,12 39.15,1.14,DAMG,Paclen,Paclen_DAMG,3,12 0,0,DAMG,Paclen,Paclen_DAMG,3,12 37.78,2.85,DAMG,Paclen,Paclen_DAMG,3,12 38.63,1.61,NYDG,Paclen,Paclen_NYDG,3,13 38.63,1.61,NYDG,Paclen,Paclen_NYDG,3,13 37.51,3.42,NYDG,Paclen,Paclen_NYDG,3,13 37.69,3.02,NYDG,Paclen,Paclen_NYDG,3,13 0,0,exbl,Paclen,Paclen_exbl,3,14 0,0,exbl,Paclen,Paclen_exbl,3,14 0,0,exbl,Paclen,Paclen_exbl,3,14 0,0,exbl,Paclen,Paclen_exbl,3,14 0,0,exbl,Paclen,Paclen_exbl,3,14 0,0,exbl,Paclen,Paclen_exbl,3,14 0,1.536E+11,none,Paclen,Paclen_none,3,0 0,1.536E+11,none,Paclen,Paclen_none,3,0 0,1.536E+11,none,Paclen,Paclen_none,3,0 0,1.536E+11,none,Paclen,Paclen_none,3,0 0,1.536E+11,none,Paclen,Paclen_none,3,0 0,1.536E+11,none,Paclen,Paclen_none,3,0 ") # make a transparent color transp_col <- rgb(0, 0, 0, 0) #make a dataframe from two lists to use for later picking a color col2<-c(transp_col,"black","red","#ff1a1a","#00008B","#FFD700","#A52A2A","#FF4040","#76EE00","#8B008B","#FF8C00","#9932CC","#97FFFF","blue") col_no<-c(1:14) col_df1 <- cbind.data.frame(col_no,col2) #match the colors in the main-dataframe with the colors in the color-data-frame col_df3 <- col_df1$col2[match(krebse_drenge_qpcr_02$sampl_no,col_df1$col_no)] col_df3 #bind the new column with colors to the main dataframe krebse_drenge_qpcr_04 <- cbind.data.frame(krebse_drenge_qpcr_02,col_df3) krebse_drenge_qpcr_04 #remove invalid values - i.e. values matching certain criteria in the dataframe krebse_drenge_qpcr_05 <- krebse_drenge_qpcr_04[!krebse_drenge_qpcr_02$Sample_type == "none", ] krebse_drenge_qpcr_05 <- krebse_drenge_qpcr_05[!krebse_drenge_qpcr_05$Sample_type == "exbl", ] krebse_drenge_qpcr_05 <- krebse_drenge_qpcr_05[!krebse_drenge_qpcr_05$quantitity_zero == 0, ] krebse_drenge_qpcr_05 <- krebse_drenge_qpcr_05[!krebse_drenge_qpcr_05$ct_dRn_zero == 0, ] krebse_drenge_qpcr_05 <- krebse_drenge_qpcr_05[!krebse_drenge_qpcr_05$Sample_type == "tissue", ] # draw variables pertaining to krebse_drenge_qpcr_02 y <- krebse_drenge_qpcr_05$ct_dRn_zero x <- krebse_drenge_qpcr_05$quantitity_zero textlb <- krebse_drenge_qpcr_05$Sample_type # website for help on colors: https://sites.google.com/site/manabusakamoto/home/r-tutorials/r-tutorial-3 #sdev_y <- krebse_drenge_qpcr_05$ct_dRn_zero #sdev_x <- krebse_drenge_qpcr_05$quantitity_zero # save plot as pdf file # set to save plot as pdf file with dimensions 8.26 to 2.9 # 8.26 inches and 2.9 inhes equals 210 mm and 74.25 mm # and 210 mm and 74.25 mm matches 1/4 of a A4 page #pdf("plot_crayfish_edna.pdf",width=(1.6*8.2677),height=(2*1.6*2.9232)) # save plot as svg file #devSVG("plot_edna_vs_catch_all4species.svg",width=(1.6*8.2677),height=(2*1.6*2.9232)) #Package ‘RSvgDevice’ to prepare svg-files with editable text install.packages("RSvgDevice") library(RSvgDevice) # install package for embedding fonts into the EPS file # see this website for more on EPS exporting: http://www.fromthebottomoftheheap.net/2013/09/09/preparing-figures-for-plos-one-with-r/ install.packages("extrafont") library("extrafont") font_import() #load fonts for EPS loadfonts(device = "postscript") # Exporting EPS files via postscript() postscript("plot_crayfish_edna.eps", width=(1.6*8.2677),height=(2*1.6*2.9232), #family = "Arial", paper = "special", onefile = FALSE, horizontal = FALSE) #log-log plot with grid from this webpage: http://sphaerula.com/legacy/R/logLogPlots.html #op <- par(mar = c(5, 4, 0.05, 0.05) + 0.1) op <- par(mfrow=c(2,2), oma=c(3,3,0,0), # set outer margin (the margin around the combined plot area) - higher numbers increase the number of lines mar=c(3,3,3,3) # set the margin around each individual plot ) ## Create a data frame with eDNA-crayfish-data. y <- krebse_drenge_qpcr_05$ct_dRn_zero x <- krebse_drenge_qpcr_05$quantitity_zero d.f <- data.frame( x = x, y = y ) ## Open a new default device. #get( getOption( "device" ) )() ## Plot the data, hiding the points for now to prevent the calls to ## abline() from drawing over the points. plot( y ~ x, data = d.f, type = "n", log = "x", las=1, # arrange all labels horizontal xaxt='n', #surpress tick labels on x-axis yaxt='n', #surpress tick labels on y-axis main="qPCR standard curve - 3 species", #offset = 2, #sub="sub-title", #xlab="target-eDNA in extract. (copy/qPCR-reaction)", #ylab="Ct", #xlim = c( 0.1, 1000000000 ), #ylim = c( 10, 50 ) xlim = c( 0.234, 0.428*1000000000 ), ylim = c( 9.55, 48.446 ) ) ## Put grid lines on the plot, using a light blue color ("lightsteelblue2"). # add horizontal lines in grid abline( h = c( seq( 8, 48, 2 )), lty = 1, lwd =0.6, col = colors()[ 225 ] ) # add vertical lines in grid abline( v = c( seq( 0.1, 1, 0.1 ), seq( 1, 10, 1 ), seq( 10, 100, 10 ), seq( 100, 1000, 100 ), seq( 1000, 10000, 1000 ), seq( 10000, 100000, 10000 ), seq( 100000, 1000000, 100000 ), seq( 1000000, 10000000, 1000000 ), seq( 10000000, 100000000, 10000000 ), seq( 100000000, 1000000000, 100000000 )), lty = 1, lwd =0.6, col = colors()[ 225 ] ) # add line for LOD and LOQ abline(v=seq(5,100,1000000), lty=2, lwd=1) text(7,15,"LOQ and LOD",col="black",srt=90,pos=1, font=1) # add line for Ct-cut-off abline(h=seq(41,100,1000), lty=1, lwd=3, col="darkgray") text(10,40.6,"cut-off",col="darkgray",srt=0,pos=3, font=2, cex=1.2) #prepare three subsets from the main dataframe, one subset for each species krebse_drenge_qpcr_05_Lepto_III_STD <- krebse_drenge_qpcr_05[krebse_drenge_qpcr_05$spec_Sampl_type == "Lepto_III_STD", ] krebse_drenge_qpcr_05_Astast_STD <- krebse_drenge_qpcr_05[krebse_drenge_qpcr_05$spec_Sampl_type == "Astast_STD", ] krebse_drenge_qpcr_05_Paclen_STD <- krebse_drenge_qpcr_05[krebse_drenge_qpcr_05$spec_Sampl_type == "Paclen_STD", ] #estimate a model for each STD subset logEstimate_Lepto_III_STD <- lm(ct_dRn_zero~log(quantitity_zero),krebse_drenge_qpcr_05_Lepto_III_STD) logEstimate_Astast_STD <- lm(ct_dRn_zero~log(quantitity_zero),krebse_drenge_qpcr_05_Astast_STD) logEstimate_Paclen_STD <- lm(ct_dRn_zero~log(quantitity_zero),krebse_drenge_qpcr_05_Paclen_STD) #add log regresion lines to the plot with(as.list(coef(logEstimate_Lepto_III_STD)), curve(`(Intercept)`+`log(quantitity_zero)`*log(x),add=TRUE, # col="blue", lty=1)) with(as.list(coef(logEstimate_Astast_STD)), curve(`(Intercept)`+`log(quantitity_zero)`*log(x),add=TRUE, # col="red", lty=2)) with(as.list(coef(logEstimate_Paclen_STD)), curve(`(Intercept)`+`log(quantitity_zero)`*log(x),add=TRUE, # col="green", lty=3)) ## Draw the points over the grid lines. points( y ~ x, data = d.f, pch=c(21,22,24)[as.numeric(krebse_drenge_qpcr_05$Species)], lwd=1, cex=1.8, # col=c("red","blue","green")[as.numeric(krebse_drenge_qpcr_05$Species)], bg=c(as.character(krebse_drenge_qpcr_05$col_df3)) ) ticks <- seq(-1, 9, by=1) labels <- sapply(ticks, function(i) as.expression(bquote(10^ .(i)))) axis(1, at=c(0.1, 1, 10, 1e+2, 1e+3, 1e+4, 1e+5, 1e+6, 1e+7, 1e+8, 1e+9), pos=8, labels=labels) axis(side=2, at=seq(8, 50, by = 2), las=1, pos=0.1) ## Redraw the plot box over the grid lines. #box() # add a legend legend(3000000,49, unique(krebse_drenge_qpcr_05$Sample_type), pch=c(21), bg="white", pt.bg = unique(as.character(krebse_drenge_qpcr_05$col_df3)), y.intersp= 0.7, cex=1.8) # add a second legend legend(1000,49, unique(krebse_drenge_qpcr_02$Species), pch=c(21,22,24)[(unique(krebse_drenge_qpcr_05$Species))], cex=1.8, bg="white", # col=c("red","blue","green")[unique(krebse_drenge_qpcr_05$Species)], lty=c(1,2,3), # [unique(krebse_drenge_qpcr_05$Species)], y.intersp= 0.7) #prepare subsets from main datafram for each species krebs_edna_paclen <- krebse_drenge_qpcr_05[krebse_drenge_qpcr_05$Species == "Paclen", ] krebs_edna_astast <- krebse_drenge_qpcr_05[krebse_drenge_qpcr_05$Species == "Astast", ] krebs_edna_lepto1 <- krebse_drenge_qpcr_05[krebse_drenge_qpcr_05$Species == "Lepto_I", ] krebs_edna_lepto3 <- krebse_drenge_qpcr_05[krebse_drenge_qpcr_05$Species == "Lepto_III", ] #__________3 log plots # plot1 for paclen - triangles ## Create a data frame with eDNA-crayfish-data. ypaclen <- krebs_edna_paclen$ct_dRn_zero xpaclen <- krebs_edna_paclen$quantitity_zero d.fpaclen <- data.frame( xpaclen = xpaclen, ypaclen = ypaclen ) ## Open a new default device. #get( getOption( "device" ) )() plot( ypaclen ~ xpaclen, data = d.fpaclen, type = "n", log = "x", las=1, # arrange all labels horizontal xaxt='n', #surpress tick labels on x-axis yaxt='n', #surpress tick labels on y-axis main="qPCR standard curve - Paclen (signal crayfish)", #offset = 2, #sub="sub-title", #xlab="target-eDNA in extract. (copy/qPCR-reaction)", #ylab="Ct", #xlim = c( 0.1, 1000000000 ), #ylim = c( 10, 50 ) xlim = c( 0.234, 0.428*1000000000 ), ylim = c( 9.55, 48.446 ) ) ## Put grid lines on the plot, using a light blue color ("lightsteelblue2"). # add horizontal lines in grid abline( h = c( seq( 8, 48, 2 )), lty = 1, lwd =0.6, col = colors()[ 225 ] ) # add vertical lines in grid abline( v = c( seq( 0.1, 1, 0.1 ), seq( 1, 10, 1 ), seq( 10, 100, 10 ), seq( 100, 1000, 100 ), seq( 1000, 10000, 1000 ), seq( 10000, 100000, 10000 ), seq( 100000, 1000000, 100000 ), seq( 1000000, 10000000, 1000000 ), seq( 10000000, 100000000, 10000000 ), seq( 100000000, 1000000000, 100000000 )), lty = 1, lwd =0.6, col = colors()[ 225 ] ) # add line for LOD and LOQ abline(v=seq(5,100,1000000), lty=2, lwd=1) text(7,15,"LOQ and LOD",col="black",srt=90,pos=1, font=1) # add line for Ct-cut-off abline(h=seq(41,100,1000), lty=1, lwd=3, col="darkgray") text(10,40.6,"cut-off",col="darkgray",srt=0,pos=3, font=2, cex=1.2) ## Draw the points over the grid lines. points( ypaclen ~ xpaclen, data = d.fpaclen, pch=c(24), lwd=1, cex=1.8, # col=c("red","blue","green")[as.numeric(krebse_drenge_qpcr_05$Species)], bg=c(as.character(krebs_edna_paclen$col_df3)) ) ticks <- seq(-1, 9, by=1) labels <- sapply(ticks, function(i) as.expression(bquote(10^ .(i)))) axis(1, at=c(0.1, 1, 10, 1e+2, 1e+3, 1e+4, 1e+5, 1e+6, 1e+7, 1e+8, 1e+9), pos=8, labels=labels) axis(side=2, at=seq(8, 50, by = 2), las=1, pos=0.1) #add log regresion lines to the plot with(as.list(coef(logEstimate_Paclen_STD)), curve(`(Intercept)`+`log(quantitity_zero)`*log(x),add=TRUE, # col="green", lty=3)) ## Redraw the plot box over the grid lines. #box() # plot2 for astast - triangles ## Create a data frame with eDNA-crayfish-data. yastast <- krebs_edna_astast$ct_dRn_zero xastast <- krebs_edna_astast$quantitity_zero d.fastast <- data.frame( xastast = xastast, yastast = yastast ) ## Open a new default device. #get( getOption( "device" ) )() plot( yastast ~ xastast, data = d.fastast, type = "n", log = "x", las=1, # arrange all labels horizontal xaxt='n', #surpress tick labels on x-axis yaxt='n', #surpress tick labels on y-axis main="qPCR standard curve - Astast (noble crayfish)", #offset = 2, #sub="sub-title", #xlab="target-eDNA in extract. (copy/qPCR-reaction)", #ylab="Ct", #xlim = c( 0.1, 1000000000 ), #ylim = c( 10, 50 ) xlim = c( 0.234, 0.428*1000000000 ), ylim = c( 9.55, 48.446 ) ) ## Put grid lines on the plot, using a light blue color ("lightsteelblue2"). # add horizontal lines in grid abline( h = c( seq( 8, 48, 2 )), lty = 1, lwd =0.6, col = colors()[ 225 ] ) # add vertical lines in grid abline( v = c( seq( 0.1, 1, 0.1 ), seq( 1, 10, 1 ), seq( 10, 100, 10 ), seq( 100, 1000, 100 ), seq( 1000, 10000, 1000 ), seq( 10000, 100000, 10000 ), seq( 100000, 1000000, 100000 ), seq( 1000000, 10000000, 1000000 ), seq( 10000000, 100000000, 10000000 ), seq( 100000000, 1000000000, 100000000 )), lty = 1, lwd =0.6, col = colors()[ 225 ] ) # add line for LOD and LOQ abline(v=seq(5,100,1000000), lty=2, lwd=1) text(7,15,"LOQ and LOD",col="black",srt=90,pos=1, font=1) # add line for Ct-cut-off abline(h=seq(41,100,1000), lty=1, lwd=3, col="darkgray") text(10,40.6,"cut-off",col="darkgray",srt=0,pos=3, font=2, cex=1.2) ## Draw the points over the grid lines. points( yastast ~ xastast, data = d.fastast, pch=c(21), lwd=1, cex=1.8, # col=c("red","blue","green")[as.numeric(krebse_drenge_qpcr_05$Species)], bg=c(as.character(krebs_edna_astast$col_df3)) ) ticks <- seq(-1, 9, by=1) labels <- sapply(ticks, function(i) as.expression(bquote(10^ .(i)))) axis(1, side=1, at=c(0.1, 1, 10, 1e+2, 1e+3, 1e+4, 1e+5, 1e+6, 1e+7, 1e+8, 1e+9), pos=8, labels=labels) axis(side=2, at=seq(8, 50, by = 2), las=1, pos=0.1) ## Redraw the plot box over the grid lines. #add log regresion lines to the plot with(as.list(coef(logEstimate_Astast_STD)), curve(`(Intercept)`+`log(quantitity_zero)`*log(x),add=TRUE, # col="red", lty=2)) #box() # plot3 for lepto3 - triangles ## Create a data frame with eDNA-crayfish-data. ylepto3 <- krebs_edna_lepto3$ct_dRn_zero xlepto3 <- krebs_edna_lepto3$quantitity_zero d.flepto3 <- data.frame( xlepto3 = xlepto3, ylepto3 = ylepto3 ) ## Open a new default device. #get( getOption( "device" ) )() plot( ylepto3 ~ xlepto3, data = d.flepto3, type = "n", log = "x", las=1, # arrange all labels horizontal xaxt='n', #surpress tick labels on x-axis yaxt='n', #surpress tick labels on y-axis #axes=FALSE, # surpress axis labels main="qPCR standard curve - PonlepIII (narrow-clawed crayfish)", #offset = 2, #sub="sub-title", #xlab="target-eDNA in extract. (copy/qPCR-reaction)", #ylab="Ct", #xlim = c( 0.1, 1000000000 ), #ylim = c( 10, 50 ) xlim = c( 0.234, 0.428*1000000000 ), ylim = c( 9.55, 48.446 ) ) ## Put grid lines on the plot, using a light blue color ("lightsteelblue2"). # add horizontal lines in grid abline( h = c( seq( 8, 48, 2 )), lty = 1, lwd =0.6, col = colors()[ 225 ] ) # add vertical lines in grid abline( v = c( seq( 0.1, 1, 0.1 ), seq( 1, 10, 1 ), seq( 10, 100, 10 ), seq( 100, 1000, 100 ), seq( 1000, 10000, 1000 ), seq( 10000, 100000, 10000 ), seq( 100000, 1000000, 100000 ), seq( 1000000, 10000000, 1000000 ), seq( 10000000, 100000000, 10000000 ), seq( 100000000, 1000000000, 100000000 )), lty = 1, lwd =0.6, col = colors()[ 225 ] ) # add line for LOD and LOQ abline(v=seq(5,100,1000000), lty=2, lwd=1) text(7,15,"LOQ and LOD",col="black",srt=90,pos=1, font=1) # add line for Ct-cut-off abline(h=seq(41,100,1000), lty=1, lwd=3, col="darkgray") text(10,40.6,"cut-off",col="darkgray",srt=0,pos=3, font=2, cex=1.2) ## Draw the points over the grid lines. points( ylepto3 ~ xlepto3, data = d.flepto3, pch=c(22), lwd=1, cex=1.8, # col=c("red","blue","green")[as.numeric(krebse_drenge_qpcr_05$Species)], bg=c(as.character(krebs_edna_lepto3$col_df3)) ) ticks <- seq(-1, 9, by=1) labels <- sapply(ticks, function(i) as.expression(bquote(10^ .(i)))) axis(1, at=c(0.1, 1, 10, 1e+2, 1e+3, 1e+4, 1e+5, 1e+6, 1e+7, 1e+8, 1e+9), pos=8, labels=labels) axis(side=2, at=seq(8, 50, by = 2), las=1, pos=0.1) ## Redraw the plot box over the grid lines. #add log regresion lines to the plot with(as.list(coef(logEstimate_Lepto_III_STD)), curve(`(Intercept)`+`log(quantitity_zero)`*log(x),add=TRUE, # col="blue", lty=1)) #box() #add overall labels for x-axis and y-axis mtext('target-eDNA in extract. (copy/qPCR-reaction)', side = 1, outer = TRUE, line = 1) mtext('Ct', side = 2, outer = TRUE, line = 1) par(op) # end file to save as file dev.off()