well_df_to_mat_frames: Convert a DataFrame to a Multi-Frame Matrix

View source: R/plate.R

well_df_to_mat_framesR Documentation

Convert a DataFrame to a Multi-Frame Matrix

Description

Converts a DataFrame to a matrix where each row is a single time point, and each column is a single well. The wells are in index order, indexing across the rows so the first values are all from row A.

Usage

well_df_to_mat_frames(data, value, frame, well)

Arguments

data

Data frame or tibble to convert to a multi-frame matrix.

value

Column with value data that will be used to populate the matrix.

frame

Column with the frame or time data that will be used to create the rows of the matrix.

well

Column with the well IDs which will be used to create the columns of the matrix.

Value

a matrix where each column is a well and each row is a time point.

Examples

df_list <- lapply(1:10, function(x) {
  df <- wellr::well_plate()
  df$value <- rnorm(96)
  df$frame <- x
  df
})

df_frames <- do.call(rbind, df_list)

# convert the data frame to multi-frame matrix
mat <- well_df_to_mat_frames(
  data = df_frames,
  value = value,
  frame = frame,
  well = well
)

head(mat[, 1:14])


rforbiochemists/wellr documentation built on March 28, 2024, 4:26 a.m.