aboutsummaryrefslogtreecommitdiff
path: root/R/checksubstance.R
diff options
context:
space:
mode:
Diffstat (limited to 'R/checksubstance.R')
-rw-r--r--R/checksubstance.R54
1 files changed, 27 insertions, 27 deletions
diff --git a/R/checksubstance.R b/R/checksubstance.R
index 790182f..06cc635 100644
--- a/R/checksubstance.R
+++ b/R/checksubstance.R
@@ -1,7 +1,7 @@
checksubstance <- function(substance, db = "cytotox", experimentator = "%",
- celltype = "%", enzymetype = "%", organism = "%",
+ celltype = "%", enzymetype = "%", organism = "%",
endpoint = "%",
- whereClause = "1", ok= "%")
+ whereClause = "1", ok= "%")
{
databases <- data.frame(
responsename=c("viability","activity","response"),
@@ -11,7 +11,7 @@ checksubstance <- function(substance, db = "cytotox", experimentator = "%",
if (!(db %in% rownames(databases))) stop("Database is not supported")
- if (require("RODBC")) {
+ if (requireNamespace("RODBC")) {
channel <- RODBC::odbcConnect(db, uid="cytotox", pwd="cytotox", case="tolower")
} else {
stop("For this function, the RODBC package has to be installed and configured.")
@@ -23,13 +23,13 @@ checksubstance <- function(substance, db = "cytotox", experimentator = "%",
if (db == "cytotox") {
type <- celltype
- }
+ }
if (db == "enzymes") {
type <- enzymetype
- }
+ }
if (db == "ecotox") {
type <- organism
- }
+ }
query <- paste("SELECT experimentator,substance,",
testtype, ",", exptype, ",conc,unit,",responsename,",ok",
@@ -41,7 +41,7 @@ checksubstance <- function(substance, db = "cytotox", experimentator = "%",
sep = "")
if (db == "ecotox") {
- query <- paste(query, " AND type LIKE '",
+ query <- paste(query, " AND type LIKE '",
endpoint, "'", sep = "")
}
@@ -51,39 +51,39 @@ checksubstance <- function(substance, db = "cytotox", experimentator = "%",
if (length(data$experimentator) < 1) {
stop(paste("\nNo response data for",substance,"in database",
db,"found with these parameters\n"))
- }
-
- data$experimentator <- factor(data$experimentator)
+ }
+
+ data$experimentator <- factor(data$experimentator)
data$substance <- factor(data$substance)
- substances <- levels(data$substance)
- data$type <- factor(data[[testtype]])
- data[[exptype]] <- factor(data[[exptype]])
+ substances <- levels(data$substance)
+ data$type <- factor(data[[testtype]])
+ data[[exptype]] <- factor(data[[exptype]])
experiments <- levels(data[[exptype]])
concentrations <- split(data$conc,data$conc)
concentrations <- as.numeric(names(concentrations))
- data$unit <- factor(data$unit)
+ data$unit <- factor(data$unit)
data$ok <- factor(data$ok)
if (length(experiments)>6) {
- palette(rainbow(length(experiments)))
+ palette(rainbow(length(experiments)))
}
-
+
plot(log10(data$conc),data[[responsename]],
- xlim=c(-2.5, 4.5),
- ylim= c(-0.1, 2),
- xlab=paste("decadic logarithm of the concentration in ",levels(data$unit)),
- ylab=responsename)
-
+ xlim=c(-2.5, 4.5),
+ ylim= c(-0.1, 2),
+ xlab=paste("decadic logarithm of the concentration in ",levels(data$unit)),
+ ylab=responsename)
+
explist <- split(data,data[[exptype]])
-
- for (i in 1:length(explist)) {
- points(log10(explist[[i]]$conc),explist[[i]][[responsename]],col=i);
- }
-
+
+ for (i in 1:length(explist)) {
+ points(log10(explist[[i]]$conc),explist[[i]][[responsename]],col=i);
+ }
+
legend("topleft", experiments, pch=1, col=1:length(experiments), inset=0.05)
title(main=paste(substance," - ",levels(data$experimentator)," - ",levels(data$type)))
- exptypename <- paste(toupper(substring(exptype,1,1)),
+ exptypename <- paste(toupper(substring(exptype,1,1)),
substring(exptype,2), sep = "")
experimentators <- paste(levels(data$experimentator), collapse = " ")
types <- paste(levels(data$type), collapse = " ")

Contact - Imprint