update_config: Update a local YAML config file using a default one.

View source: R/config_update.R

update_configR Documentation

Update a local YAML config file using a default one.

Description

By update is meant the following: if a default config contains a new parameter, it will be appended to a local config. If a parameter is present in both configs, its value from the local config will be used. In case the local config does not exist, the default one will be simply copied. See vignette("config", package = "scdrake") for details.

update_config() will update a single config file.

⁠update_*_config()⁠ functions update a specific config group (pipeline, single-sample, integration).

update_configs() will run all ⁠update_*_config()⁠.

Usage

update_config(
  default_file,
  use_default_structure = FALSE,
  force = FALSE,
  yq_binary = getOption("scdrake_yq_binary"),
  verbose = getOption("scdrake_verbose")
)

update_pipeline_config(
  dir = getOption("scdrake_pipeline_config_dir"),
  verbose = getOption("scdrake_verbose"),
  ...
)

update_single_sample_configs(
  dir = getOption("scdrake_single_sample_config_dir"),
  verbose = getOption("scdrake_verbose"),
  ...
)

update_integration_configs(
  dir = getOption("scdrake_integration_config_dir"),
  verbose = getOption("scdrake_verbose"),
  ...
)

update_configs(
  pipeline_config_dir = getOption("scdrake_pipeline_config_dir"),
  single_sample_config_dir = getOption("scdrake_single_sample_config_dir"),
  integration_config_dir = getOption("scdrake_integration_config_dir"),
  verbose = getOption("scdrake_verbose"),
  ...
)

Arguments

default_file

A character scalar: path to the default YAML config file. Must have a .default.yaml extension.

use_default_structure

A logical scalar: if TRUE, a structure (comments, order of parameters) of the default config will be used, otherwise a structure of the local config will be preserved. See description for more details.

force

A logical scalar: if TRUE, overwrite local configs with default ones (instead of updating them).

yq_binary

A character scalar: path to yq tool's binary.

verbose

A logical scalar: if TRUE, be verbose. The default value is obtained from getOption("scdrake_verbose").

dir

A character scalar:

  • For update_pipeline_config(): a path to directory with pipeline.default.yaml file.

  • For update_single_sample_configs(): a path to directory with ⁠00_main.default.yaml⁠, ⁠01_input_qc.default.yaml⁠, ⁠02_norm_clustering.default.yaml⁠, cluster_markers.default.yaml, and contrasts.default.yaml files.

  • For update_integration_configs(): a path to directory with ⁠00_main.default.yaml⁠, ⁠01_integration.default.yaml⁠, ⁠02_int_clustering.default.yaml⁠, cluster_markers.default.yaml, and contrasts.default.yaml files.

...

Passed to update_config().

pipeline_config_dir

Passed to update_pipeline_config().

single_sample_config_dir

Passed to update_single_sample_configs().

integration_config_dir

Passed to update_integration_configs().

Details

Internally, the yq tool (version 3) is used for merging of YAML files.

Value

Invisibly NULL.

Using default config structure

Consider the following example of config update, showing also differences in the use_default_structure parameter:

Default config:

# Comment 1.
PARAM_1: 1
PARAM_2: 2
PARAM_3: 3

Local config:

# Comment 2.
PARAM_2: 6
# Comment 3.
PARAM_1: 5

With use_default_structure = TRUE, the result of update will be:

# Comment 1.
PARAM_1: 5
PARAM_2: 6
PARAM_3: 3

With use_default_structure = FALSE:

# Comment 2.
PARAM_2: 6
# Comment 3.
PARAM_1: 5
PARAM_3: 3

NOTE: yq tool, which is used internally for merging (updating) of YAML files, cannot ovewrite comments, and thus we need to use this schema to preserve local structure.

See Also

download_yq(), check_yq(), yq_merge_cmd(), vignette("scdrake_config")

Examples

# If a scdrake project is in the current working directory.
## Not run: 
update_config("config/pipeline.default.yaml")

## End(Not run)

## Not run: 
update_pipeline_config("config")

## End(Not run)

## Not run: 
update_single_sample_configs("config/single_sample")

## End(Not run)
## Not run: 
update_integration_configs("config/integration")

## End(Not run)


bioinfocz/scdrake documentation built on Jan. 29, 2024, 10:24 a.m.