-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphenoData.R
54 lines (49 loc) · 2.06 KB
/
phenoData.R
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
createThresholdMatrix <- function(){
columns <- c("totalDroplets","minOutlier","maxOutlier","threshold","thresholdMeanStDev","minAmplitude","maxAmplitude","minRain","maxRain")
channel.1 <- matrix(data = NA, nrow = 0, ncol = length(columns),
dimnames = list(Sample.Names, columns))
channel.2 <- matrix(data = NA, nrow = 0, ncol = length(columns),
dimnames = list(Sample.Names, columns))
result <- phenoData <- list(channel.1 = channel.1, channel.2 = channel.2)
return(result)
}
addThresholdData <- function(x = NULL, add, type = ''){
if (class(result != "matrix"))
{
result <- matrix(data = NA, nrow = 7, ncol = 2,
dimnames = list(c("minOutlier","maxOutlier","threshold","thresholdMeanStDev","maxAmplitude","minAmplitude","minRain","maxRain"), c("ch1","ch2")))
}
dimnames = list(c("minOutlier","maxOutlier","threshold","thresholdMeanStDev","maxAmplitude","minAmplitude","minRain","maxRain"), c("ch1","ch2"))
}
thresholdData <- function(tData = NULL, amplitude = NULL, type = NULL) {
if(class(type) != "NULL")
{
thresholds <- c("minOutlier","maxOutlier","threshold","thresholdMeanStDev","maxAmplitude","minAmplitude","mode","minRain","maxRain")
if(tolower(type) %in% tolower(thresholds) == TRUE)
{
type <- thresholds[tolower(thresholds) %in% tolower(type)]
} else {stop("No correct threshold type is given.\n")}
}
if(length(amplitude) == 2)
{
if(class(tData) == "matrix")
{
if(type %in% rownames(tData) == TRUE)
{
tData[grep(pattern = type, x = rownames(tData)),] <- amplitude
}else
{
tData <- rbind(tData, type = amplitude)
rownames(tData)[nrow(tData)] <- type
}
}else
{
tData <- matrix(data = amplitude, nrow = 1, ncol = 2, dimnames = list(c(type), c("ch1.Amplitude","ch2.Amplitude")))
}
}else{stop("Threshold data must have a length of 2.\n")}
return(tData)
}
# [ ] - create new function that will create matrix or add settings to it.
# some fixed settings
# able to add own settings as well
#