aboutsummaryrefslogtreecommitdiff
path: root/R/drplot.R
diff options
context:
space:
mode:
Diffstat (limited to 'R/drplot.R')
-rw-r--r--R/drplot.R30
1 files changed, 19 insertions, 11 deletions
diff --git a/R/drplot.R b/R/drplot.R
index baec69d..8faaa0f 100644
--- a/R/drplot.R
+++ b/R/drplot.R
@@ -1,6 +1,7 @@
drplot <- function(drresults, data,
dtype = "std", alpha = 0.95, ctype = "none",
path = "./", fileprefix = "drplot", overlay = FALSE,
+ xlim = c("auto","auto"), ylim = c("auto","auto"),
postscript = FALSE, pdf = FALSE, png = FALSE,
bw = TRUE,
pointsize = 12,
@@ -14,14 +15,15 @@ drplot <- function(drresults, data,
unit <- "different units"
}
- # Get the plot limits on the x-axis (log of the dose) and y axis
+ # Determine the plot limits on the x-axis and y axis
if(is.data.frame(data)) {
+ # Get rid of pseudo substance names of controls
nonzerodata <- subset(data,dose!=0)
- nonzerodata$substance <- factor(nonzerodata$substance) # Get rid of pseudo substance names of controls
+ nonzerodata$substance <- factor(nonzerodata$substance)
zerodata <- subset(data,dose==0)
nc <- length(zerodata$dose) # Number of control points
if (nc > 0) {
- sdc <- sd(zerodata$response) # Standard deviation of control responses
+ sdc <- sd(zerodata$response)
controlconf <- sdc * qt((1 + alpha)/2, nc - 1) / sqrt(nc)
cat("There are ",nc,"data points with dose 0 (control values)\n")
cat("with a standard deviation of",sdc,"\n")
@@ -52,6 +54,12 @@ drplot <- function(drresults, data,
hr <- 1.0
}
}
+ if (xlim[1] == "auto") xlim[1] <- lld - 0.5
+ if (xlim[2] == "auto") xlim[2] <- lhd + 1
+ if (ylim[1] == "auto") ylim[1] <- -0.1
+ if (ylim[2] == "auto") ylim[2] <- hr + 0.2
+ xlim <- as.numeric(xlim)
+ ylim <- as.numeric(ylim)
# Prepare overlay plot if requested
if (overlay)
@@ -79,10 +87,10 @@ drplot <- function(drresults, data,
}
plot(0,type="n",
- xlim=c(lld - 0.5, lhd + 1),
- ylim= c(-0.1, hr + 0.2),
- xlab=paste("Decadic Logarithm of the dose in ", unit),
- ylab="Normalized response")
+ xlim = xlim,
+ ylim = ylim,
+ xlab = paste("Decadic Logarithm of the dose in ", unit),
+ ylab = "Normalized response")
}
# Plot the data either as raw data or as error bars
@@ -123,10 +131,10 @@ drplot <- function(drresults, data,
}
plot(0,type="n",
- xlim=c(lld - 0.5, lhd + 2),
- ylim= c(-0.1, hr + 0.2),
- xlab=paste("Decadic Logarithm of the dose in ", unit),
- ylab="Normalized response")
+ xlim = xlim,
+ ylim = ylim,
+ xlab = paste("Decadic Logarithm of the dose in ", unit),
+ ylab = "Normalized response")
}
if (!overlay) legend(lpos, i,lty = 1, col = color, inset=0.05)
tmp$dosefactor <- factor(tmp$dose) # necessary because the old

Contact - Imprint