check_well_positions {microdiluteR}R Documentation

Check monotonicity of well positions across groups

Description

check_well_positions checks if well positions across groups, i.e. experiments, monotonically increase or decrease with timepoints measured.

check_monotonicity checks whether the values in a numeric vector are monotonically increasing or decreasing.

Usage

check_well_positions(
  input_data,
  x_var = "Timepoint",
  y_var = "Value",
  grouping = "Position",
  v_var = "Validity",
  wp_var = "Position"
)

check_monotonicity(vec)

Arguments

input_data

A data.frame containing the input data, e.g. from a function call to tidy_single_plate, tidy_plates_via_params or tidy_plates_via_prompts.

x_var

A character string specifying the variable to be plotted on the x-axis. Defaults to 'Timepoint'.

y_var

A character string specifying the variable to be plotted on the y-axis. Defaults to 'Value'.

grouping

A vector of character strings specifying the grouping variables. Defaults to 'Position' if no grouping is provided.

v_var

A character string specifying the validity information. Usually a column with all rows being 'valid'. Rows are set to 'invalid' based on user selection. Defaults to "Validity".

wp_var

A character string specifying the column providing the well positions. Defaults to "Position".

vec

A numeric vector to be checked for monotonicity.

Details

If non-monotonic groups of well positions are detected, check_well_positions plots them as line graphs and returns a list with both the corresponding subset of the data for further inspection and the input data adjusted for invalid well positions from visual inspection.

check_monotonicity checks if all differences between consecutive elements in the vector 'vec' are non-negative (indicating monotonic non-decreasing behavior) or non-positive (indicating monotonic non-increasing behavior).

Value

check_well_positions returns a subset of the input data containing only the data from non-monotonic groups, if non-monotonic groups are detected. Otherwise, NULL is returned.

check_monotonicity returns a logical value.

See Also

tidy_plate, tidy_plates_via_params, tidy_plates_via_prompts

validate_cells, update_validity

Examples

# Generate example data
set.seed(123)
df <- data.frame(Position = rep(1:21, 2),
                 Value = c(1:21, sample(1:21,21, TRUE)),
                 Timepoint = rep(paste0("T",1:3),14),
                 Validity = "valid",
                 Group_1 = rep(LETTERS[1:2], each=21),
                 Group_2 = rep(letters[1:14], each = 3))
# All groups behave monotonically
check_well_positions(df[df$Group_1 == "A",],
                     x_var = "Timepoint",
                     y_var = "Value",
                     grouping = c("Group_1", "Group_2"))
# Six groups behave non-monotonically
check_well_positions(df[df$Group_1 == "B",],
                     x_var = "Timepoint",
                     y_var = "Value",
                     grouping = c("Group_1", "Group_2"))
# Check if a vector is monotonically increasing (will return TRUE)
check_monotonicity(c(1, 2, 3, 4, 5))
# Check if a vector is monotonically decreasing (will return FALSE)
check_monotonicity(c(5, 80, 3, 2, 1))

[Package microdiluteR version 1.0.1 Index]