-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_batch_cal_maxF.R
More file actions
executable file
·47 lines (40 loc) · 1.24 KB
/
_batch_cal_maxF.R
File metadata and controls
executable file
·47 lines (40 loc) · 1.24 KB
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
#library("caTools")
#library("grid")
#library("KernSmooth")
#library("gtools")
#library("gdata")
#library("gplots")
library("ROCR", lib.loc='/mnt/home/seddonal/R/library/')
cArgs = commandArgs(trailingOnly=TRUE)
get_perf_maxF <- function(t)
{
ncol = dim(t)[2]
pred <- prediction( t[,seq(2,ncol,2)],t[,seq(1,ncol,2)])
folds <- ncol/2
perf <- performance(pred, "f")
c <- c()
# get the max AUC-ROCs
for(i in 1:folds){
Fmeasure <- unlist(perf@y.values[i])
Fmax <- max(Fmeasure, na.rm=T)
c <- c(c, Fmax)
}
c
}
calculate_F <- function(prefile){
file=read.table(prefile, sep = '\t', header = FALSE)
# You can choose to invert the predictions and observations.
# This allows you to calculate an AUC-ROC based on the negative class.
# An invert value of 1 allows you to do this
maxF <- get_perf_maxF(file)
maxF_mean <- mean(maxF)
maxF_standard_error <- sd(maxF)/length(maxF)
write.table(paste(maxF_mean, maxF_standard_error, sep = '\t')
, file=paste(prefile, 'maxF', sep=".")
, col.names = FALSE, row.names = FALSE
, quote = FALSE
)
}
for(prefile in cArgs){
calculate_F(prefile)
}