Update function default parameters
Usage
update_function_params(
function_name = NULL,
param_name = NULL,
new_values = NULL,
verbose = FALSE,
...
)Arguments
- function_name
characterfunction name, passed toformals()- param_name
characterstring of one parameter / argument name.- new_values
any relevant R object type to use for the function parameter / argument.
- verbose
logicalwhether to print verbose output- ...
additional arguments are ignored.
Details
This function is a minor extension to update_list_elements()
intended to help update function parameters which are defined
as a nested list. It will update internal components of the
nested list without replacing the whole list.
It is very similar to modifyList() except for a nested list.
See also
Other jamses utilities:
choose_annotation_colnames(),
combine_sestats(),
contrast2comp_dev(),
fold_to_log2fold(),
intercalate(),
list2im_opt(),
list2im_value_internal(),
list_to_sestats(),
log2fold_to_fold(),
make_block_arrow_polygon(),
mark_stat_hits(),
matrix_normalize(),
merge_statdf_all_test(),
point_handedness(),
point_slope_intercept(),
shortest_unique_abbreviation(),
shrinkDataFrame(),
shrink_df(),
shrink_matrix(),
sort_samples(),
strsplitOrdered(),
sub_split_vector(),
update_list_elements()
Examples
params1 <- list(
jammanorm=list(
controlGenes=c("HK1", "HK2")
),
cyclicLoess=list(method="affy"),
quantile=list(ties=FALSE)
)
# 1. Not correct: update arguments with modifyList()
fn_defaults <- eval(formals("matrix_normalize"))
new_fn_args <- modifyList(fn_defaults, list(params=params1))
str(new_fn_args$params)
#> List of 3
#> $ jammanorm :List of 1
#> ..$ controlGenes: chr [1:2] "HK1" "HK2"
#> $ cyclicLoess:List of 1
#> ..$ method: chr "affy"
#> $ quantile :List of 1
#> ..$ ties: logi FALSE
str(new_fn_args$params$jammanorm)
#> List of 1
#> $ controlGenes: chr [1:2] "HK1" "HK2"
# 2. update only params argument with modifyList()
new_fn_params <- modifyList(eval(fn_defaults$params), params1)
str(new_fn_params)
#> List of 6
#> $ cyclicLoess :List of 5
#> ..$ weights : NULL
#> ..$ span : num 0.7
#> ..$ adaptive.span: logi FALSE
#> ..$ iterations : num 3
#> ..$ method : chr "affy"
#> $ quantile :List of 1
#> ..$ ties: logi FALSE
#> $ jammanorm :List of 8
#> ..$ controlGenes : chr [1:2] "HK1" "HK2"
#> ..$ minimum_mean : num 0
#> ..$ maximum_mean : num Inf
#> ..$ controlSamples : NULL
#> ..$ centerGroups : NULL
#> ..$ useMedian : logi FALSE
#> ..$ noise_floor : NULL
#> ..$ noise_floor_value: NULL
#> $ limma_batch_adjust:List of 2
#> ..$ batch: NULL
#> ..$ group: NULL
#> $ TMM :List of 5
#> ..$ refColumn : NULL
#> ..$ logratioTrim: num 0.3
#> ..$ sumTrim : num 0.05
#> ..$ doWeighting : logi TRUE
#> ..$ Acutoff : NULL
#> $ TMMwsp :List of 5
#> ..$ refColumn : NULL
#> ..$ logratioTrim: num 0.3
#> ..$ sumTrim : num 0.05
#> ..$ doWeighting : logi TRUE
#> ..$ Acutoff : NULL
str(new_fn_params$jammanorm)
#> List of 8
#> $ controlGenes : chr [1:2] "HK1" "HK2"
#> $ minimum_mean : num 0
#> $ maximum_mean : num Inf
#> $ controlSamples : NULL
#> $ centerGroups : NULL
#> $ useMedian : logi FALSE
#> $ noise_floor : NULL
#> $ noise_floor_value: NULL
# 3. use update_function_params()
params2 <- update_function_params(
function_name="matrix_normalize",
param_name="params",
new_values=params1)
str(params2)
#> List of 6
#> $ cyclicLoess :List of 5
#> ..$ weights : NULL
#> ..$ span : num 0.7
#> ..$ adaptive.span: logi FALSE
#> ..$ iterations : num 3
#> ..$ method : chr "affy"
#> $ quantile :List of 1
#> ..$ ties: logi FALSE
#> $ jammanorm :List of 8
#> ..$ controlGenes : chr [1:2] "HK1" "HK2"
#> ..$ minimum_mean : num 0
#> ..$ maximum_mean : num Inf
#> ..$ controlSamples : NULL
#> ..$ centerGroups : NULL
#> ..$ useMedian : logi FALSE
#> ..$ noise_floor : NULL
#> ..$ noise_floor_value: NULL
#> $ limma_batch_adjust:List of 2
#> ..$ batch: NULL
#> ..$ group: NULL
#> $ TMM :List of 5
#> ..$ refColumn : NULL
#> ..$ logratioTrim: num 0.3
#> ..$ sumTrim : num 0.05
#> ..$ doWeighting : logi TRUE
#> ..$ Acutoff : NULL
#> $ TMMwsp :List of 5
#> ..$ refColumn : NULL
#> ..$ logratioTrim: num 0.3
#> ..$ sumTrim : num 0.05
#> ..$ doWeighting : logi TRUE
#> ..$ Acutoff : NULL
str(params2$jammanorm)
#> List of 8
#> $ controlGenes : chr [1:2] "HK1" "HK2"
#> $ minimum_mean : num 0
#> $ maximum_mean : num Inf
#> $ controlSamples : NULL
#> $ centerGroups : NULL
#> $ useMedian : logi FALSE
#> $ noise_floor : NULL
#> $ noise_floor_value: NULL