diff options
-rw-r--r-- | DESCRIPTION | 4 | ||||
-rw-r--r-- | R/drfit.R | 46 | ||||
-rw-r--r-- | inst/doc/README.txt | 14 | ||||
-rw-r--r-- | inst/doc/sampledata.xls | bin | 19456 -> 16896 bytes | |||
-rw-r--r-- | inst/doc/sampledata2.csv | 33 | ||||
-rw-r--r-- | man/drplot.Rd | 8 |
6 files changed, 92 insertions, 13 deletions
diff --git a/DESCRIPTION b/DESCRIPTION index 2ff9517..1f7becb 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: drfit -Version: 0.04-52 -Date: 2005-12-22 +Version: 0.04-54 +Date: 2006-01-02 Title: Dose-response data evaluation Author: Johannes Ranke <jranke@uni-bremen.de> Maintainer: Johannes Ranke <jranke@uni-bremen.de> @@ -287,7 +287,8 @@ drfit <- function(data, startlogED50 = NA, chooseone=TRUE, return(results) } -drplot <- function(drresults, data, dtype = "std", alpha = 0.95, +drplot <- function(drresults, data, + dtype = "std", alpha = 0.95, ctype = "none", path = "./", fileprefix = "drplot", overlay = FALSE, postscript = FALSE, png = FALSE, bw = TRUE, pointsize = 12, @@ -301,16 +302,30 @@ drplot <- function(drresults, data, dtype = "std", alpha = 0.95, unit <- "different units" } - # Get the plot limits on the x-axis (log of the dose) + # Get the plot limits on the x-axis (log of the dose) and y axis if(is.data.frame(data)) { - if (min(data$dose) == 0) { - cat("At least one of the dose levels is 0 - this is not a valid dose.") - } else { - lld <- log10(min(data$dose)) + nonzerodata <- subset(data,dose!=0) + nonzerodata$substance <- factor(nonzerodata$substance) # Get rid of pseudo substance names of controls + zerodata <- subset(data,dose==0) + nc <- length(zerodata$dose) # Number of control points + sdc <- sd(zerodata$response) # Standard deviation of control responses + controlconf <- sdc * qt((1 + alpha)/2, nc - 1) / sqrt(nc) + if (nc > 0) { + cat("There are ",nc,"data points with dose 0 (control values)\n") + cat("with a standard deviation of",sdc,"\n") + cat("and a confidence interval of",controlconf,"\n") + if (nc < 3) { + cat("\nThere are less than 3 control points, therefore their scatter\n") + cat("will not be displayed\n") + ctype = "none" + } } - lhd <- log10(max(data$dose)) - hr <- max(data$response) - dsubstances <- levels(data$substance) + lld <- log10(min(nonzerodata$dose)) + lhd <- log10(max(nonzerodata$dose)) + hr <- max(nonzerodata$response) + if (ctype == "std") hr <- max(hr,1 + sdc) + if (ctype == "conf") hr <- max(hr,1 + controlconf) + dsubstances <- levels(nonzerodata$substance) } else { lld <- min(drresults[["logED50"]],na.rm=TRUE) - 2 lhd <- max(drresults[["logED50"]],na.rm=TRUE) + 2 @@ -349,7 +364,7 @@ drplot <- function(drresults, data, dtype = "std", alpha = 0.95, # Plot the data either as raw data or as error bars if(is.data.frame(data)) { - splitted <- split(data,data$substance) + splitted <- split(nonzerodata,nonzerodata$substance) # n is the index for the dose-response curves n <- 0 if (bw) colors <- rep("black",length(dsubstances)) @@ -389,6 +404,17 @@ drplot <- function(drresults, data, dtype = "std", alpha = 0.95, # factor has all levels, not # only the ones tested with # this substance + + # Plot the control lines, if requested + if (ctype == "std") { + abline(h = 1 - sdc, lty = 2) + abline(h = 1 + sdc, lty = 2) + } + if (ctype == "conf") { + abline(h = 1 - controlconf, lty = 2) + abline(h = 1 + controlconf, lty = 2) + } + # Plot the data, if requested if (dtype != "none") { if (dtype == "raw") { diff --git a/inst/doc/README.txt b/inst/doc/README.txt new file mode 100644 index 0000000..10945d9 --- /dev/null +++ b/inst/doc/README.txt @@ -0,0 +1,14 @@ +This sample data is provided to show how dose-response data can be collected +with a spreadsheet program like OpenOfficeCalc (sampledata.ods) or +MS Excel (sampledata.xls) and exported to CSV (comma separated values) format. +OpenOfficeCalc 2.0 (German version, decimal separator is ',') produces +sampledata.csv which can be read in by + + >sampledata <- read.csv('sampledata.csv',skip=2,dec=',') + +and MS Excel 97 produces sampledata.csv2 which can be read in by + + >sampledata <- read.csv2('sampledata2.csv',skip=2) + +if the working directory of R was set to the directory where these +files reside. diff --git a/inst/doc/sampledata.xls b/inst/doc/sampledata.xls Binary files differindex 0951ae0..513123b 100644 --- a/inst/doc/sampledata.xls +++ b/inst/doc/sampledata.xls diff --git a/inst/doc/sampledata2.csv b/inst/doc/sampledata2.csv new file mode 100644 index 0000000..f778dab --- /dev/null +++ b/inst/doc/sampledata2.csv @@ -0,0 +1,33 @@ +Concentration-response data for the Lemna growth test with Substances X and Y;;;;;
+;;;;;
+nr.;substance;dose;unit;fronds;response
+1;Control;0;mg/L;174;1,134782609
+2;Control;0;mg/L;143;0,932608696
+3;Control;0;mg/L;143;0,932608696
+4;Substance X;10;mg/L;147;0,958695652
+5;Substance X;10;mg/L;148;0,965217391
+6;Substance X;10;mg/L;148;0,965217391
+7;Substance X;100;mg/L;63;0,410869565
+8;Substance X;100;mg/L;65;0,423913043
+9;Substance X;100;mg/L;55;0,358695652
+10;Substance X;300;mg/L;20;0,130434783
+11;Substance X;300;mg/L;22;0,143478261
+12;Substance X;300;mg/L;25;0,163043478
+13;Substance X;1000;mg/L;13;0,084782609
+14;Substance X;1000;mg/L;16;0,104347826
+15;Substance X;1000;mg/L;16;0,104347826
+16;Control;0;mg/L;153;0,997826087
+17;Control;0;mg/L;144;0,939130435
+18;Control;0;mg/L;163;1,063043478
+19;Substance Y;10;mg/L;20;0,130434783
+20;Substance Y;10;mg/L;19;0,123913043
+21;Substance Y;10;mg/L;21;0,136956522
+22;Substance Y;100;mg/L;13;0,084782609
+23;Substance Y;100;mg/L;12;0,07826087
+24;Substance Y;100;mg/L;13;0,084782609
+25;Substance Y;300;mg/L;12;0,07826087
+26;Substance Y;300;mg/L;12;0,07826087
+27;Substance Y;300;mg/L;14;0,091304348
+28;Substance Y;1000;mg/L;12;0,07826087
+29;Substance Y;1000;mg/L;12;0,07826087
+30;Substance Y;1000;mg/L;12;0,07826087
diff --git a/man/drplot.Rd b/man/drplot.Rd index 25b598c..99f77ab 100644 --- a/man/drplot.Rd +++ b/man/drplot.Rd @@ -6,7 +6,7 @@ either combined or separately, for one or more substances. } \usage{ - drplot(drresults, data, dtype, alpha, path, fileprefix, overlay, + drplot(drresults, data, dtype, alpha, ctype, path, fileprefix, overlay, postscript, png, bw, pointsize, colors, devoff, lpos) } \arguments{ @@ -31,6 +31,12 @@ The confidence level, defaulting to 0.95, only used if dtype "conf" has been chosen. } + \item{ctype}{ + This argument decides if horizontal lines are drawn to show the scatter of + the control values (dose = 0, mean response = 1). Defaults to "none", + further allowed values are "std" and "conf" for displaying the standard deviation + of the controls or the confidence interval for the mean of the controls. + } \item{path}{ The path where graphic files should be put if any are produced. Defaults to "./" i.e. the current working directory of R. |