aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.Rbuildignore7
-rw-r--r--ChangeLog20
-rw-r--r--DESCRIPTION12
-rw-r--r--GNUmakefile46
-rw-r--r--INDEX18
-rw-r--r--R/checkexperiment.R2
-rw-r--r--R/checksubstance.R1
-rw-r--r--R/drdata.R1
-rw-r--r--R/drfit.R64
-rw-r--r--R/drplot.R1
-rw-r--r--man/drfit.Rd25
11 files changed, 163 insertions, 34 deletions
diff --git a/.Rbuildignore b/.Rbuildignore
new file mode 100644
index 0000000..6b03659
--- /dev/null
+++ b/.Rbuildignore
@@ -0,0 +1,7 @@
+GNUmakefile
+out$
+toc$
+bbl$
+blg$
+aux$
+log$
diff --git a/ChangeLog b/ChangeLog
new file mode 100644
index 0000000..9163fbb
--- /dev/null
+++ b/ChangeLog
@@ -0,0 +1,20 @@
+2014-02-03 Johannes Ranke
+
+ * DESCRIPTION: New version 0.5-97 (leading zeros in version numbers are
+ deprecated), modernize author field, enable lazy loading
+
+ * Add this ChangeLog, a GNUMakefile, and an .Rbuildignore file
+
+ * R/*.R: Clean out unnecessary calls to library() and require()
+
+ * R/*.R: Tell R (>2.15.1) about some undeclared global variables to avoid NOTES in
+ package checks
+
+ * R/drfit.R: Add the argument showED50. If set to TRUE, drfit includes the
+ ED50 and its confidence interval on the original scale in the output
+
+ * R/drfit.R: Add the possibility to calculate several EDx values for each
+ dose-response model
+
+ * man/drfit.Rd: Update the documentation and use the new optional arguments
+ in the example
diff --git a/DESCRIPTION b/DESCRIPTION
index b5bfb8a..7dac5df 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,10 +1,10 @@
Package: drfit
-Version: 0.05-96
-Date: 2012-10-29
+Version: 0.5-97
+Date: 2014-02-03
Title: Dose-response data evaluation
-Author: Johannes Ranke <jranke@uni-bremen.de>
-Maintainer: Johannes Ranke <jranke@uni-bremen.de>
-Depends: R (>= 2.1.0),stats,MASS,RODBC
+Authors@R: c(person("Johannes", "Ranke", role = c("aut", "cre"),
+ email = "jranke@uni-bremen.de"))
+Depends: R (>= 2.1.0), MASS, RODBC
Description: drfit provides basic and easy-to-use functions for fitting
dose-response curves to dose-response data, calculating some
(eco)toxicological parameters and plotting the results. Functions that are
@@ -17,6 +17,8 @@ Description: drfit provides basic and easy-to-use functions for fitting
are included.
Encoding: latin1
License: GPL (>= 2)
+LazyLoad: yes
+LazyData: yes
URL: http://www.r-project.org,
http://www.uft.uni-bremen.de/chemie/ranke?page=drfit,
http://kriemhild.uft.uni-bremen.de/viewcvs/?root=drfit
diff --git a/GNUmakefile b/GNUmakefile
new file mode 100644
index 0000000..dfc1b7b
--- /dev/null
+++ b/GNUmakefile
@@ -0,0 +1,46 @@
+PKGNAME := $(shell sed -n "s/Package: *\([^ ]*\)/\1/p" DESCRIPTION)
+PKGVERS := $(shell sed -n "s/Version: *\([^ ]*\)/\1/p" DESCRIPTION)
+PKGSRC := $(shell basename $(PWD))
+
+# Specify the directory holding R binaries. To use an alternate R build (say a
+# pre-prelease version) use `make RBIN=/path/to/other/R/` or `export RBIN=...`
+# If no alternate bin folder is specified, the default is to use the folder
+# containing the first instance of R on the PATH.
+RBIN ?= $(shell dirname "`which R`")
+
+.PHONY: help
+
+help:
+ @echo "\nExecute development tasks for $(PKGNAME)\n"
+ @echo "Usage: \`make <task>\` where <task> is one of:"
+ @echo ""
+ @echo "Development Tasks"
+ @echo "-----------------"
+ @echo " build Create the package"
+ @echo " check Invoke build and then check the package"
+ @echo " install Invoke build and then install the result"
+ @echo ""
+ @echo "Packaging Tasks"
+ @echo "---------------"
+ @echo " release Give some reminders"
+ @echo ""
+ @echo "Using R in: $(RBIN)"
+ @echo "Set the RBIN environment variable to change this."
+ @echo ""
+
+
+#------------------------------------------------------------------------------
+# Development Tasks
+#------------------------------------------------------------------------------
+
+build:
+ cd ..;\
+ "$(RBIN)/R" CMD build $(PKGSRC)
+
+install: build
+ cd ..;\
+ "$(RBIN)/R" CMD INSTALL $(PKGNAME)_$(PKGVERS).tar.gz
+
+check: build
+ cd ..;\
+ "$(RBIN)/R" CMD check --as-cran $(PKGNAME)_$(PKGVERS).tar.gz
diff --git a/INDEX b/INDEX
deleted file mode 100644
index 6e4c0cc..0000000
--- a/INDEX
+++ /dev/null
@@ -1,18 +0,0 @@
-antifoul Dose-Response data for TBT and Zink Pyrithione
- in IPC-81 cells
-checkexperiment Check raw data from a specified experiment or
- microtiter plate
-drdata Get dose-response data via RODBC
-drfit Fit dose-response models
-drfit-package Dose-response data evaluation
-drplot Plot dose-response models
-IM1xIPC81 Dose-Response data for
- 1-methyl-3-alkylimidazolium tetrafluoroborates
- in IPC-81 cells
-IM1xVibrio Dose-Response data for
- 1-methyl-3-alkylimidazolium tetrafluoroborates
- in V. fischeri
-linlogitf Linear-logistic function
-pyrithione Cytotoxicity data for different pyrithionates
- and related species
-XY Dose-Response data for two substances X and Y
diff --git a/R/checkexperiment.R b/R/checkexperiment.R
index 58fecad..2bf0ce7 100644
--- a/R/checkexperiment.R
+++ b/R/checkexperiment.R
@@ -1,3 +1,4 @@
+if(getRversion() >= '2.15.1') utils::globalVariables(c("type", "conc"))
checkexperiment <- function(id, db = "ecotox", endpoint = "%")
{
databases <- data.frame(
@@ -8,7 +9,6 @@ checkexperiment <- function(id, db = "ecotox", endpoint = "%")
if (!(db %in% rownames(databases))) stop("Database is not supported")
- library(RODBC)
channel <- odbcConnect(db,uid="cytotox",pwd="cytotox",case="tolower")
diff --git a/R/checksubstance.R b/R/checksubstance.R
index 96be999..b50c3da 100644
--- a/R/checksubstance.R
+++ b/R/checksubstance.R
@@ -11,7 +11,6 @@ checksubstance <- function(substance, db = "cytotox", experimentator = "%",
if (!(db %in% rownames(databases))) stop("Database is not supported")
- library(RODBC)
channel <- odbcConnect(db,uid="cytotox",pwd="cytotox",case="tolower")
responsename = as.character(databases[db,1])
diff --git a/R/drdata.R b/R/drdata.R
index 9da7d96..15c61ac 100644
--- a/R/drdata.R
+++ b/R/drdata.R
@@ -3,7 +3,6 @@ drdata <- function(substances, experimentator = "%", db = "cytotox",
organism="Vibrio fischeri",endpoint="Luminescence",whereClause="1",
ok="'ok','no fit'")
{
- library(RODBC)
channel <- odbcConnect(db,uid="cytotox",pwd="cytotox",case="tolower")
slist <- paste(substances,collapse="','")
if (db == "cytotox") {
diff --git a/R/drfit.R b/R/drfit.R
index 462bc43..fc73632 100644
--- a/R/drfit.R
+++ b/R/drfit.R
@@ -1,11 +1,13 @@
+if(getRversion() >= '2.15.1') utils::globalVariables(c("ok", "dose"))
drfit <- function(data, startlogED50 = NA, chooseone=TRUE,
probit = TRUE, logit = FALSE, weibull = FALSE,
linlogit = FALSE, level = 0.95,
linlogitWrong = NA, allWrong = NA,
ps0 = 1, ls0 = 0.5, ws0 = 0.5,
- b0 = 2, f0 = 0)
+ b0 = 2, f0 = 0,
+ showED50 = FALSE,
+ EDx = NULL, EDx.tolerance = 1e-4)
{
- require(MASS)
if(!is.null(data$ok)) data <- subset(data,ok!="no fit") # Don't use data
# with ok set to
# "no fit"
@@ -282,14 +284,68 @@ drfit <- function(data, startlogED50 = NA, chooseone=TRUE,
}
results <- data.frame(rsubstance, rndl, rn, rlld, rlhd, mtype,
logED50, logED50low, logED50high, runit, sigma, a, b)
+ lower_level_percent = paste(100 * (1 - level)/2, "%", sep = "")
+ upper_level_percent = paste(100 * (1 + level)/2, "%", sep = "")
names(results) <- c("Substance","ndl","n","lld","lhd","mtype","logED50",
- paste(100*(1-level)/2,"%",sep=""),
- paste(100*(1+level)/2,"%",sep=""),
+ lower_level_percent, upper_level_percent,
"unit","sigma","a","b")
if (linlogit) {
results$c <- c
}
+ if (showED50) {
+ results[c("ED50", paste("ED50", c(lower_level_percent, upper_level_percent)))] <-
+ 10^results[7:9]
+ }
+ if (!is.null(EDx)) {
+ for (row.i in 1:ri) {
+ logED50 <- results[row.i, "logED50"]
+ mtype <- as.character(results[row.i, "mtype"])
+ if (mtype == "probit") {
+ scale <- results[row.i, "b"]
+ drfunction <- function(x) pnorm(-x, -logED50, scale)
+ }
+ if (mtype == "logit") {
+ scale <- results[row.i, "b"]
+ drfunction <- function(x) plogis(-x, -logED50, scale)
+ }
+ if (mtype == "weibull") {
+ location <- results[row.i, "a"]
+ shape <- results[row.i, "b"]
+ drfunction <- function(x) pweibull(-x + location, shape)
+ }
+ if (mtype == "linlogit") {
+ drfunction <- function(x) {
+ r <- linlogitf(10^x, 1,
+ results[row.i, "c"],
+ results[row.i, "logED50"],
+ results[row.i, "b"])
+ # Do not return response values above 1 to avoid trapping
+ # the optimization algorithm in a local minimum later on
+ if (r < 1) return(r)
+ else return(2 - 0.001 * x) # Start with 2 and decrease slowly to
+ # guide to the interesting part of the curve
+ }
+ }
+ if (mtype %in% c("probit", "logit", "weibull", "linlogit")) {
+ for (ED in EDx) {
+ of <- function(x) abs(drfunction(x) - (1 - (ED/100)))
+
+ # Search over interval starting an order of magnitude below
+ # the lowest dose up to one order of magnitude above the
+ # highest dose
+ o = optimize(of,
+ results[row.i, c("lld", "lhd")] + c(-1, 1))
+ # Only keep results within the tolerance
+ if ((o$objective) < EDx.tolerance) {
+ logdose.ED = o$minimum
+ results[row.i, paste0("EDx", ED)] <- 10^logdose.ED
+ }
+ }
+ }
+ }
+ }
+
rownames(results) <- 1:ri
return(results)
}
diff --git a/R/drplot.R b/R/drplot.R
index 55b9da4..149337c 100644
--- a/R/drplot.R
+++ b/R/drplot.R
@@ -1,3 +1,4 @@
+if(getRversion() >= '2.15.1') utils::globalVariables(c("dose", "Substance"))
drplot <- function(drresults, data,
dtype = "std", alpha = 0.95, ctype = "none",
path = "./", fileprefix = "drplot", overlay = FALSE,
diff --git a/man/drfit.Rd b/man/drfit.Rd
index 6b98f36..7237404 100644
--- a/man/drfit.Rd
+++ b/man/drfit.Rd
@@ -8,7 +8,9 @@
\usage{
drfit(data, startlogED50 = NA, chooseone = TRUE, probit = TRUE, logit = FALSE,
weibull = FALSE, linlogit = FALSE, level = 0.95, linlogitWrong = NA,
- allWrong = NA, ps0 = 1, ls0 = 0.5, ws0 = 0.5, b0 = 2, f0 = 0)
+ allWrong = NA, ps0 = 1, ls0 = 0.5, ws0 = 0.5, b0 = 2, f0 = 0,
+ showED50 = FALSE,
+ EDx = NULL, EDx.tolerance = 1e-4)
}
\arguments{
\item{data}{
@@ -68,6 +70,17 @@
\item{b0,f0}{
If the linearlogistic model is fitted, \code{b0} and \code{f0} give the
possibility to adjust the starting values for the parameters b and f.}
+ \item{showED50}{
+ If set to TRUE, the ED50 and its confidence interval on the original dose
+ scale (not log scale) is included in the output.
+ }
+ \item{EDx}{
+ A vector of inhibition values x in percent for which the corresponding doses
+ EDx should be reported.
+ }
+ \item{EDx.tolerance}{
+ Tolerance of the effect level, expressed on the response scale from 0 to 1.
+ }
}
\value{
\item{results}{
@@ -97,12 +110,16 @@
and in the \dQuote{weibull} fit it is the \code{shape} parameter of the
fitted \code{\link{pweibull}} function. Only the \dQuote{linlogit} fit
produces a third parameter \code{c} which is the variable f from the
- \code{\link{linlogitf}} function.}
+ \code{\link{linlogitf}} function.
+
+ If the parameter \code{showED50} was set to TRUE, the ED50 values and their
+ confidence intervals are also included on the original dose scale.
+ }
}
\examples{
data(antifoul)
-r <- drfit(antifoul)
-format(r,digits=2)
+r <- drfit(antifoul, showED50 = TRUE, EDx = c(5, 10, 20))
+format(r, digits = 2)
}
\note{There is a demo for each dataset that can be accessed by
\code{demo(dataset)}}

Contact - Imprint