aboutsummaryrefslogtreecommitdiff
path: root/R
diff options
context:
space:
mode:
Diffstat (limited to 'R')
-rw-r--r--R/checkexperiment.R101
1 files changed, 101 insertions, 0 deletions
diff --git a/R/checkexperiment.R b/R/checkexperiment.R
new file mode 100644
index 0000000..68169c7
--- /dev/null
+++ b/R/checkexperiment.R
@@ -0,0 +1,101 @@
+checkexperiment <- function(id,db="cytotox")
+{
+ databases <- data.frame(
+ responsetype=c("viability","activity","response"),
+ testtype=c("celltype","enzyme","organism"),
+ exptype=c("plate","plate","experiment"))
+ rownames(databases) <- c("cytotox","enzymes","ecotox")
+
+ if (!(db %in% rownames(databases))) stop("Database does not exist")
+
+ library(RODBC)
+ channel <- odbcConnect(db,uid="cytotox",pwd="cytotox",case="tolower")
+
+ responsetype = as.character(databases[db,1])
+ testtype = as.character(databases[db,2])
+ exptype = as.character(databases[db,3])
+
+ expquery <- paste("SELECT experimentator,substance,",
+ testtype,",conc,unit,",responsetype,",performed,ok",
+ "FROM ",db," WHERE ",exptype,"=", id)
+
+ expdata <- sqlQuery(channel,expquery)
+
+ if (db %in% c("cytotox","enzymes")) {
+ controlquery <- paste("SELECT type,response FROM controls
+ WHERE plate=",id)
+ controldata <- sqlQuery(channel,controlquery)
+ }
+
+ odbcClose(channel)
+
+ if (db %in% c("cytotox","enzymes")) {
+ blinds <- subset(controldata,type=="blind")
+ controls <- subset(controldata,type=="control")
+
+ numberOfBlinds <- length(blinds$response)
+ stdOfBlinds <- sd(blinds$response)
+ } else {
+ controls <- subset(expdata,conc == 0)
+
+ numberOfBlinds <- NA
+ stdOfBlinds <- NA
+
+ }
+
+
+ if (length(expdata$experimentator) < 1) {
+ stop("There is no response data for ",exptype," ",
+ id," in database ",db,"\n")
+ }
+ expdata$experimentator <- factor(expdata$experimentator)
+ expdata$type <- factor(expdata[[testtype]])
+ expdata$substance <- factor(expdata$substance)
+ expdata$unit <- factor(expdata$unit)
+ expdata$performed <- factor(expdata$performed)
+ expdata$ok <- factor(expdata$ok)
+
+ numberOfControls <- length(controls$response)
+
+ meanOfBlinds <- mean(blinds$response)
+ meanOfControls <- mean(controls$response)
+ stdOfControls <- sd(controls$response)
+ percentstdOfcontrols <-stdOfControls *100/meanOfControls
+
+ cat("Plate ",plate," from database ",db,"\n",
+ "\tExperimentator: ",levels(platedata$experimentator),"\n",
+ "\tType(s): ",levels(platedata$type),"\n",
+ "\tPerformed on : ",levels(platedata$performed),"\n",
+ "\tSubstance(s): ",levels(platedata$substance),"\n",
+ "\tConcentration unit: ",levels(platedata$unit),"\n",
+ "\tOK: ",levels(platedata$ok),"\n",
+ "\t\tNumber \tMean \t\tStandard Deviation \t% Standard Deviation \n",
+ "\tblind\t",numberOfBlinds,"\t",meanOfBlinds,"\t",stdOfBlinds,"\n",
+ "\tcontrol\t",numberOfControls,"\t",meanOfControls,"\t",stdOfControls,"\t\t",percentstdOfcontrols,"\n")
+
+ par(ask=TRUE)
+
+ boxplot(blinds$response,controls$response,
+ names=c("blinds","controls"),
+ ylab="Response",main=paste("Plate ",plate))
+
+ drdata <- platedata[c(2,4,6)]
+ drdata$substance <- factor(drdata$substance)
+ substances <- levels(drdata$substance)
+
+ plot(log10(drdata$conc),drdata$viability,
+ xlim=c(-2.5, 4.5),
+ ylim= c(-0.1, 2),
+ xlab=paste("decadic logarithm of the concentration in ",levels(platedata$unit)),
+ ylab=responsetype)
+
+ drdatalist <- split(drdata,drdata$substance)
+
+ for (i in 1:length(drdatalist)) {
+ points(log10(drdatalist[[i]]$conc),drdatalist[[i]][[responsetype]],col=i);
+ }
+
+ legend("topleft",substances, pch=1, col=1:length(substances), inset=0.05)
+ title(main=paste("Plate ",plate," - ",
+ levels(platedata$experimentator)," - ",levels(platedata$type)))
+}

Contact - Imprint