Register a Custom Screening Method for Phenotype-Driven Analysis
Source:R/62-RegisterScreenMethod.R
RegisterScreenMethod.RdRegisters one or more user-defined screening functions into a shared registry
(i.e., ScreenStrategy), enabling dynamic dispatch based on phenotype type
(binary, survival, or continuous). Each method is stored with metadata including
supported phenotypes and an optional parameter remapping function.
This function supports community-driven extension of analysis pipelines—ideal for integrating novel single cell phenotypic screening methods while maintaining compatibility with downstream validation and execution frameworks
Usage
RegisterScreenMethod(
...,
supported_phenotypes = c("binary", "survival", "continuous"),
parameter_mapper = NULL,
registry = ScreenStrategy,
verbose = getFuncOption("verbose") %||% TRUE
)Arguments
- ...
Named arguments where each value is a function implementing a screening method. The name becomes the method identifier (e.g.,
Scissor = DoScissorregistersDoScissorunder the key"Scissor"). Unnamed arguments are auto-named using their expression (e.g.,Scissor→ name"Scissor").- supported_phenotypes
Character vector specifying which phenotype types the method supports. Must be a subset of
c("binary", "survival", "continuous"). Default: all three.- parameter_mapper
A function that transforms the input parameter list before passing it to the executor. Useful for changing parameters from interface function. Receives a named list
paramsand must return a modified list. Default:NULL.- registry
An environment used as a method registry (e.g.,
ScreenStrategy). New methods are stored asregistry[["MethodName"]]= metadata list. Default:ScreenStrategy.- verbose
Logical. Whether to print a success message upon registration. Default:
TRUE.
Registry Entry Structure
Each registered method is stored as a list with four elements:
method_nameCharacter: the method key (e.g., "Scissor")
executorFunction: the actual screening implementation
phenotypesCharacter vector: supported phenotype classes
mapperFunction: parameter transformation hook
Examples
if (FALSE) { # \dontrun{
# Example: Register a custom screen method for survival data
DoMyScreen <- function(...) {
stop("Not implemented")
}
RegisterScreenMethod(
# Key = function
MyCox = DoMyScreen,
# If `continuous` phenotype is not supported
supported_phenotypes = c("survival", "binary"),
parameter_mapper = function(params) {
# If I perfer to use `quiet` instead of `verbose`
params$quiet <- !params$verbose
params
}
)
} # }