1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
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)))
}
|