Skip to contents

InputControl: A class for controlling and validating inputs

InputControl: A class for controlling and validating inputs

Details

This class provides methods to validate the inputs of a function.

The method performs the following checks:

* Ensures that both `annotation` and `data` are provided. * Confirms that `annotation` is a dataframe. * Verifies that `annotation` and `data` have the same number of rows.

If any of these checks fail, an informative error message is returned.

The function performs the following checks: - If `clusters` is an integer or a vector of integers. Otherwise, it gives an error.

Check Plot Info

The method performs the following checks:

* Ensures that `plot_info` is provided and not NULL. * Confirms that `y_axis_label` is a character vector with maximally 30 characters. * Confirms that `time_unit` is a character vector with maximally 15 characters. * Validates that `treatment_labels` is either `NA` or a character vector with each element being maximally 15 characters long. * Validates that `treatment_timepoints` is either `NA` or a numeric vector with the same length as `treatment_labels` if `treatment_labels` is not `NA`.

If any of these checks fail, an informative error message is returned.

This function performs the following checks: 1. Ensures `feature_name_columns` and `annotation` are not `NULL`. 2. Verifies that each element in `feature_name_columns` is a character with a length of 1. 3. Checks that all elements of `feature_name_columns` are valid column names in the `annotation` data frame.

Check Report

The function performs the following checks: - Whether the `report` argument is present. - If `report` is not a Boolean value (`TRUE` or `FALSE`), it throws an error.

Functions

  • InputControl: This method verifies the spline test configurations and associated metadata within the object's arguments. It performs a series of checks on the configurations, including column verification, spline type validation, and ensuring that the degrees of freedom (dof) are within acceptable ranges.

See also

stop for error handling.

Check Top Tables

model.matrix

Validate and check all modes

Public fields

args

A list of arguments to be validated.

Initialize an InputControl object

Methods

Inherited methods


Method new()

Usage

InputControl$new(args)

Arguments

args

A list of arguments to be validated.

Returns

A new instance of the InputControl class.

Automatically Validate All Arguments

This method automatically validates all arguments by sequentially calling various validation methods defined within the class. Each validation method checks specific aspects of the input arguments and raises an error if the validation fails.

The following validation methods are called in sequence: - self$check_data_and_meta() - self$check_datas_and_metas() - self$check_datas_descr() - self$check_design_formula() - self$check_mode() - self$check_modes() - self$check_designs_and_metas() - self$check_spline_params() - self$check_spline_test_configs() - self$check_adj_pthresholds() - self$check_clusters() - self$check_time_unit() - self$check_report_dir() - self$check_padjust_method() - self$check_report_info() - self$check_report() - self$check_feature_name_columns()


Method auto_validate()

Usage

InputControl$auto_validate()

Returns

NULL. The function is used for its side effects of validating input arguments and raising errors if any validation fails.

Check Data and Meta


Method check_data_and_meta()

This function checks the validity of the data and meta objects, ensuring that data is a matrix with numeric values and that meta is a dataframe containing the specified condition column. Additionally, it verifies that the number of columns in the data matrix matches the number of rows in the meta dataframe.

Usage

InputControl$check_data_and_meta()

Arguments

data

A matrix containing numeric values.

meta

A dataframe containing the metadata, including the 'Time' column and the specified condition column.

condition

A single character string specifying the column name in the meta dataframe to be checked.

meta_batch_column

An optional parameter specifying the column name in the meta dataframe used to remove the batch effect. Default is NA.

data_meta_index

An optional parameter specifying the index of the data/meta pair for error messages. Default is NA.

Returns

Returns TRUE if all checks pass. Stops execution and returns an error message if any check fails.

Check Annotation Consistency


Method check_annotation()

This method checks the consistency of the annotation with the data. It ensures that the annotation is a dataframe and that it has the same number of rows as the data.

Usage

InputControl$check_annotation()

Returns

NULL if any required arguments are missing. Otherwise, performs checks and potentially raises errors if checks fail.

Check Multiple Data and Meta Pairs


Method check_datas_and_metas()

Iterates over multiple data and meta pairs to validate each pair using the `check_data_and_meta` function.

Usage

InputControl$check_datas_and_metas()

Arguments

datas

A list of matrices containing numeric values.

metas

A list of data frames containing metadata.

condition

A character string specifying the column name in the meta dataframe to be checked.

meta_batch_column

An optional parameter specifying the column name in the meta dataframe used to remove the batch effect. Default is NA.

meta_batch2_column

An optional parameter specifying the column name in the meta dataframe used to remove the second batch effect. Default is NA.

Returns

NULL if any check fails, otherwise returns TRUE.

Check Data Descriptions


Method check_datas_descr()

Validates that the data descriptions are character vectors with each element not exceeding 80 characters in length.

Usage

InputControl$check_datas_descr()

Arguments

datas_descr

A character vector of data descriptions.

Returns

No return value, called for side effects.


Method check_top_tables()

Validates that the top tables are a list of dataframes and checks each dataframe using the `check_dataframe` function.

Usage

InputControl$check_top_tables()

Arguments

top_tables

A list of top tables from limma analysis.

Returns

No return value, called for side effects.

Check Design Formula


Method check_design_formula()

Validates the design formula ensuring it is a valid character string, contains allowed characters, includes the intercept term 'X', and references columns present in the metadata.

Usage

InputControl$check_design_formula()

Arguments

formula

A character string representing the design formula.

meta

A data frame containing metadata.

meta_index

An optional index for the data/meta pair.

Returns

TRUE if the design formula is valid, otherwise an error is thrown.


Method check_modes()

This function iterates over the `modes` argument, sets each `mode` in `self$args`, and calls `check_mode()` to validate each mode. After each validation, the `mode` is removed from `self$args`.

Usage

InputControl$check_modes()

Returns

NULL if `modes` is missing; otherwise, checks all modes.

Check the mode argument for validity


Method check_mode()

This function checks if the `mode` argument is provided and validates that it is either "isolated" or "integrated". If `mode` is missing or invalid, an error is thrown.

Usage

InputControl$check_mode()

Returns

NULL if `mode` is missing; otherwise, validates the mode.

Check Multiple Designs and Metas


Method check_designs_and_metas()

Iterates over multiple design formulas and corresponding metadata to validate each pair using the `check_design_formula` function.

Usage

InputControl$check_designs_and_metas()

Arguments

designs

A vector of character strings representing design formulas.

metas

A list of data frames containing metadata.

meta_indices

A vector of optional indices for the data/meta pairs.

Returns

NULL if any check fails, otherwise returns TRUE.

Check Spline Parameters


Method check_spline_params()

Validates the spline parameters both generally and depending on the specified mode.

Usage

InputControl$check_spline_params()

Arguments

spline_params

A list of spline parameters.

mode

A character string specifying the mode ('integrated' or 'isolated').

meta

A dataframe containing metadata.

condition

A character string specifying the condition.

Returns

Returns `NULL` if any required arguments are mising, otherwise, called for side effects.

Check Spline Test Configurations


Method check_spline_test_configs()

Usage

InputControl$check_spline_test_configs()

Arguments

spline_test_configs

A configuration object for spline tests.

metas

A list of metadata corresponding to the data matrices.

Returns

Returns `NULL` if any required arguments are mising, otherwise, called for side effects.

Check Limma Top Tables Structure

This function checks if the provided limma top tables data structure is correctly formatted. It ensures that the data structure contains exactly three named elements ('time_effect', 'avrg_diff_conditions', and 'interaction_condition_time') and that each element contains dataframes with the correct columns and data types.


Method check_limma_top_tables()

Usage

InputControl$check_limma_top_tables()

Arguments

self

An object containing the data structure to check.

Returns

This function does not return a value. It stops execution if the data structure does not match the expected format.

Check Adjusted p-Thresholds


Method check_adj_pthresholds()

This function checks the validity of the adjusted p-thresholds vector, ensuring that all elements are numeric, greater than 0, and less than 1. If any of these conditions are not met, the function stops execution and returns an error message indicating the offending elements.

Usage

InputControl$check_adj_pthresholds()

Arguments

adj_pthresholds

A numeric vector of adjusted p-thresholds.

Returns

Returns TRUE if all checks pass. Stops execution and returns an error message if any check fails.

Check adjusted p-value thresholds for limma category 2 and 3


Method check_adj_pthresh_limma_category_2_3()

This function checks that both adjusted p-value thresholds for average difference conditions and interaction condition time are non-null, floats, and in the range [0, 1].

Usage

InputControl$check_adj_pthresh_limma_category_2_3()

Returns

`NULL` if either argument is `NULL` or invalid. Otherwise, no return value (assumed valid inputs).

Check Clusters


Method check_clusters()

This function verifies the cluster configurations within the object's arguments. It checks if the clusters argument is present and performs validation on its content. If no clusters are specified, it defaults to automatic cluster estimation.

Usage

InputControl$check_clusters()


Method check_plot_info()

This method checks the validity of the `plot_info` list. It ensures that `y_axis_label` and `time_unit` meet the length constraints, `treatment_labels` is either `NA` or a character vector with elements meeting the length constraint, and `treatment_timepoints` is either `NA` or a numeric vector with the same length as `treatment_labels`.

Usage

InputControl$check_plot_info()

Returns

NULL if `plot_info` is not provided or invalid. Otherwise, performs checks and potentially raises errors if checks fail.

Check plot options


Method check_plot_options()

This method checks if the `plot_options` list contains the required elements `meta_replicate_column` and `cluster_heatmap_columns`. It validates that `cluster_heatmap_columns` is either TRUE or FALSE, and that `meta_replicate_column` is a valid column name in the `meta` dataframe. If the checks fail, the script stops with an error message.

Check and Create Report Directory

Usage

InputControl$check_plot_options()


Method check_report_dir()

This function checks if the specified report directory exists and is a valid directory. If the directory does not exist, it attempts to create it. If there are any warnings or errors during directory creation, the function stops execution and returns an error message.

Usage

InputControl$check_report_dir()

Arguments

report_dir

A character string specifying the path to the report directory.

Returns

Returns TRUE if the directory exists or is successfully created. Stops execution and returns an error message if the directory cannot be created or is not valid.

Check Genes Validity


Method check_genes()

This function checks the validity of the `data` and `genes` arguments within the `self$args` list. It ensures that `genes` is a character vector, that neither `data` nor `genes` is `NULL`, and that the length of `genes` matches the number of rows in `data`.

Usage

InputControl$check_genes()

Returns

Returns `TRUE` if all checks pass. Returns `NULL` if any required arguments are `NULL`. Throws an error if `genes` is not a character vector or if the length of `genes` does not match the number of rows in `data`.

Check p-Adjustment Method


Method check_padjust_method()

This function checks if the provided p-adjustment method is valid. The valid methods are: "holm", "hochberg", "hommel", "bonferroni", "BH", "BY", "fdr", and "none". If the method is not one of these, the function stops execution and returns an error message.

Usage

InputControl$check_padjust_method()

Arguments

padjust_method

A character string specifying the p-adjustment method. Valid options are "holm", "hochberg", "hommel", "bonferroni", "BH", "BY", "fdr", and "none".

Returns

Returns TRUE if the p-adjustment method is valid. Stops execution and returns an error message if the method is invalid.

Check Report Information


Method check_report_info()

Validates the report information to ensure it contains all mandatory fields and adheres to the required formats.

Usage

InputControl$check_report_info()

Arguments

report_info

A named list containing report information.

Returns

TRUE if the report information is valid; otherwise, an error is thrown.

Check Feature Name Columns


Method check_feature_name_columns()

This function checks whether all elements of `feature_name_columns` are characters of length 1 and whether they are valid column names in the `annotation` data frame.

Usage

InputControl$check_feature_name_columns()

Returns

Returns `NULL` if any required arguments are missing. Throws an error if any element of `feature_name_columns` is not a character of length 1 or if any element is not a column name in `annotation`. Returns `TRUE` if all checks pass.


Method check_report()

This function verifies the `report` argument within the object's arguments. It checks if the `report` argument is present and validates its Boolean value.

Usage

InputControl$check_report()


Method clone()

The objects of this class are cloneable with this method.

Usage

InputControl$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.