@@ -78,10 +78,10 @@ mc5 <- function(ae, wr = FALSE) {
78
78
79
79
# # Load cutoff methods
80
80
ms <- tcplMthdLoad(lvl = 5L , id = ae , type = " mc" )
81
- if (' loec .coff' %in% ms $ mthd ) {
82
- # using the loec method
81
+ if (any(c( " ow_loec .coff" , " include_loec.coff " ) %in% ms $ mthd ) ) {
82
+ # using a loec method
83
83
loec.mthd = TRUE
84
- ms <- ms [! mthd == ' loec .coff' ]
84
+ ms <- ms [! mthd == ' include_loec .coff' ]
85
85
}
86
86
87
87
# special case where osd needs to be overwritten
@@ -93,6 +93,9 @@ mc5 <- function(ae, wr = FALSE) {
93
93
94
94
# # Extract methods that need to overwrite hitc and hit_val
95
95
ms_overwrite <- ms [grepl(" ow_" ,mthd ),]
96
+ if (nrow(ms_overwrite ) > 1 ) {
97
+ stop(paste0(" Only one level 5 hit-call override method may be assigned concurrently. Currently assigned: " , paste0(ms_overwrite $ mthd , collapse = " , " )))
98
+ }
96
99
# # Extract methods that don't overwrite
97
100
ms <- ms [! grepl(" ow_" ,mthd ),]
98
101
@@ -124,7 +127,6 @@ mc5 <- function(ae, wr = FALSE) {
124
127
125
128
# # Complete the loec calculations
126
129
if (loec.mthd ) {
127
-
128
130
all_resp_gt_conc <- function (resp ) {
129
131
# all resp > coff
130
132
return (as.integer(all(abs(resp ) > cutoff ))) # All responses must be greater than coff
@@ -137,13 +139,18 @@ mc5 <- function(ae, wr = FALSE) {
137
139
mc3 [is.infinite(loec ), loec : = NA ] # convert Inf to NA
138
140
mc3 [, loec_hitc : = max(loec_coff ), by = spid ] # is there a loec? used for hitc
139
141
mc3 <- mc3 [dat , mult = ' first' , on = ' spid' , nomatch = 0L ]
140
-
141
- dat <- dat [mc3 [,c(" spid" ," loec" , " loec_hitc" )],on = " spid" ]
142
-
143
- } else {
144
- # if we're using v3 schema and not loec method we want to tcplfit2
145
- dat <- tcplHit2(dat , coff = cutoff )
142
+ mc3 <- mc3 [,c(" m4id" ," aeid" ," coff" ," loec" )] | > melt(measure.vars = c(" loec" ), variable.name = " hit_param" , value.name = " hit_val" )
143
+ }
144
+
145
+ # if we're using v3 schema we want to tcplfit2
146
+ dat <- tcplHit2(dat , coff = cutoff )
147
+
148
+ if (loec.mthd ) {
149
+ exprs <- lapply(mthd_funcs [" include_loec.coff" ], do.call , args = list ())
150
+ fenv <- environment()
151
+ invisible (rapply(exprs , eval , envir = fenv ))
146
152
}
153
+
147
154
} else {
148
155
# Legacy fitting
149
156
@@ -381,30 +388,21 @@ mc5 <- function(ae, wr = FALSE) {
381
388
dat <- dat [ , .SD , .SDcols = outcols ]
382
389
}
383
390
384
-
385
- # apply overwrite methods
391
+ # apply overwrite method
386
392
if (nrow(ms_overwrite ) > 0 ) {
387
393
exprs <- lapply(mthd_funcs [ms_overwrite $ mthd ], do.call , args = list ())
388
394
fenv <- environment()
389
395
invisible (rapply(exprs , eval , envir = fenv ))
390
396
}
391
397
392
- # apply loec.coff
393
- if (loec.mthd ) {
394
- exprs <- lapply(mthd_funcs [c(" loec.coff" )], do.call , args = list ())
395
- fenv <- environment()
396
- invisible (rapply(exprs , eval , envir = fenv ))
397
- }
398
-
399
398
400
399
ttime <- round(difftime(Sys.time(), stime , units = " sec" ), 2 )
401
400
ttime <- paste(unclass(ttime ), units(ttime ))
402
401
cat(" Processed L5 AEID" , ae , " (" , nrow(dat ),
403
402
" rows; " , ttime , " )\n " , sep = " " )
404
403
405
404
res <- TRUE
406
-
407
-
405
+
408
406
409
407
# # Load into mc5 table -- else return results
410
408
if (wr ) {
0 commit comments