Title: | Utilities for Working With Plate Based Data |
---|---|
Description: | Provides a range of utility functions for working with plate-based data from microtitre plates such as enzyme assays, bacterial growth assays and protein binding experiments. Working with column IDs, row numbers and letters and transforming between a matrix and a data frame are all made simpler. |
Authors: | Brady Johnston [aut, cre] |
Maintainer: | Brady Johnston <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.3.4 |
Built: | 2024-10-31 18:37:56 UTC |
Source: | https://github.com/bradyajohnston/wellr |
Logical test for well ID format.
is_well_id(x)
is_well_id(x)
x |
A string vector. |
A logical vector.
is_well_id(c("a12", "a2", "a02", "foo1"))
is_well_id(c("a12", "a2", "a02", "foo1"))
{plater{
Formatted Metadata to a DatasetAdd {plater{
Formatted Metadata to a Dataset
plate_add_meta(data, file)
plate_add_meta(data, file)
data |
A tibble::tibble() which contains a 'well' column, that will have the metadata added to it. |
file |
File patch to a |
a tibble::tibble()
file_data <- system.file( "extdata", "20220929_1steptimer20.csv", package = "wellr" ) file_meta <- system.file( "extdata", "20220929_1steptimer20_metainfo.csv", package = "wellr" ) plate_read_biotek(file_data) |> plate_add_meta(file_meta)
file_data <- system.file( "extdata", "20220929_1steptimer20.csv", package = "wellr" ) file_meta <- system.file( "extdata", "20220929_1steptimer20_metainfo.csv", package = "wellr" ) plate_read_biotek(file_data) |> plate_add_meta(file_meta)
Read Biotek Output CSV Files
plate_read_biotek(file, time_average = TRUE, second_wl = FALSE)
plate_read_biotek(file, time_average = TRUE, second_wl = FALSE)
file |
The filepath to a |
time_average |
Logical, whether to average the time points across different observations (LUM / OD) and pivot them to their own columns. |
second_wl |
Whether to include the second wavelength when reading in data blocks, or to keep just the label and the first wavelength. |
tibble::tibble()
file_data <- system.file( "extdata", "2024-02-29_vio_GFP_main.csv", package = "wellr" ) plate_read_biotek(file_data) plate_read_biotek(file_data, second_wl = TRUE)
file_data <- system.file( "extdata", "2024-02-29_vio_GFP_main.csv", package = "wellr" ) plate_read_biotek(file_data) plate_read_biotek(file_data, second_wl = TRUE)
wavelength
data blocks from a biotek .csv
file.Read the wavelength
data blocks from a biotek .csv
file.
plate_read_biotek_wl(file, format_well = TRUE)
plate_read_biotek_wl(file, format_well = TRUE)
file |
File path to the |
format_well |
Whether to format the |
a tibble
file_data <- system.file( "extdata", "2024-02-29_vio_GFP_main.csv", package = "wellr" ) plate_read_biotek_wl(file_data) plate_read_biotek_wl(file_data, format = FALSE)
file_data <- system.file( "extdata", "2024-02-29_vio_GFP_main.csv", package = "wellr" ) plate_read_biotek_wl(file_data) plate_read_biotek_wl(file_data, format = FALSE)
{plater}
Formatted Metadata FileRead a {plater}
Formatted Metadata File
plate_read_meta(file, sep = ",")
plate_read_meta(file, sep = ",")
file |
File path to a |
sep |
The separator for the |
a tibble::tibble()
file_meta <- system.file( "extdata", "20220929_1steptimer20_metainfo.csv", package = "wellr" ) plate_read_meta(file_meta)
file_meta <- system.file( "extdata", "20220929_1steptimer20_metainfo.csv", package = "wellr" ) plate_read_meta(file_meta)
Read the output of Tecan Plate Readers
plate_read_tecan(file, temp = FALSE)
plate_read_tecan(file, temp = FALSE)
file |
File path to the |
temp |
Logical, whether to include the temperature column. |
a tibble::tibble()
of the values from the file.
# read a .csv tecan file fl <- system.file( 'extdata', 'tecanON1.csv', package = 'wellr' ) plate_read_tecan(fl) # read a .xlsx tecan file fl <- system.file( 'extdata', 'tecanON1.xlsx', package = 'wellr' ) plate_read_tecan(fl)
# read a .csv tecan file fl <- system.file( 'extdata', 'tecanON1.csv', package = 'wellr' ) plate_read_tecan(fl) # read a .xlsx tecan file fl <- system.file( 'extdata', 'tecanON1.xlsx', package = 'wellr' ) plate_read_tecan(fl)
{plater}
formatted metadata fileRead a {plater}
formatted metadata file
read_meta(file)
read_meta(file)
file |
to read metadata from. |
a tibble
file <- system.file("extdata", "plate_layout_96.csv", package = "wellr") read_meta(file)
file <- system.file("extdata", "plate_layout_96.csv", package = "wellr") read_meta(file)
Checks if a well ID contains a letter and a number in the correct format.
well_check(x)
well_check(x)
x |
well ID to check for proper structure. |
A vector the same length as x with a TRUE of FALSE for a a well that can be read by wellr
Extracts row and column information from the column specified by well_col
(defaults to 'well') and uses this to create a matrix that contains values
from the values_from
column.
well_df_to_mat(df, values_from, well_col = "well", plate = NULL)
well_df_to_mat(df, values_from, well_col = "well", plate = NULL)
df |
A dataframe containing at least a column called "well" that contains well IDs. |
values_from |
Column that contains values to populate matrix. |
well_col |
Column containing the well IDs to extract row and column information from. |
plate |
Size of the plate, to override the auto-detected plate size. |
A matrix containing the values that were present in the data frame in
the values_from
column
library(wellr) # pivot a long data frame into a matrix based on the row and col columns, # with values from a given column plate <- well_plate(8, 12) plate$value <- seq(nrow(plate)) well_df_to_mat(plate, values_from = "value") # the function also handles missing values from a plate, filling with with NA # if certain wells are missing plate <- well_plate(7, 11) plate$value <- seq(nrow(plate)) well_df_to_mat(plate, values_from = "value", plate = 384)
library(wellr) # pivot a long data frame into a matrix based on the row and col columns, # with values from a given column plate <- well_plate(8, 12) plate$value <- seq(nrow(plate)) well_df_to_mat(plate, values_from = "value") # the function also handles missing values from a plate, filling with with NA # if certain wells are missing plate <- well_plate(7, 11) plate$value <- seq(nrow(plate)) well_df_to_mat(plate, values_from = "value", plate = 384)
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.
well_df_to_mat_frames(data, value, frame, well)
well_df_to_mat_frames(data, value, frame, well)
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. |
a matrix where each column is a well and each row is a time point.
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])
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])
Relative Distance Between Given Well and a Reference Row
well_dis(row, col, ref_row, ref_col)
well_dis(row, col, ref_row, ref_col)
row |
Numeric vector of row numbers. Must be equal in length to col. |
col |
Numeric vector of col numbers. Must be equal in length to row. |
ref_row |
Single reference row number. |
ref_col |
Single reference column number. |
a numeric vector.
well_dis(3, 4, ref_row = 5, ref_col = 5) well_dis(1:8, 1:8, ref_row = well_to_row_num("C4"), ref_col = well_to_col_num("C4"))
well_dis(3, 4, ref_row = 5, ref_col = 5) well_dis(1:8, 1:8, ref_row = well_to_row_num("C4"), ref_col = well_to_col_num("C4"))
Relative Distance for an Entire Plate
well_dis_plate(ref_row, ref_col, plate = 96)
well_dis_plate(ref_row, ref_col, plate = 96)
ref_row |
Row number to calculate distance from. |
ref_col |
Column number to calculate distance from. |
plate |
Plate size to calculate distances for. |
a matrix of relative distances.
well_dis_plate(5, 5) image(well_dis_plate(5, 5))
well_dis_plate(5, 5) image(well_dis_plate(5, 5))
Format a Well to Uppercase and Padded Numbers
well_format(x, num_width = 2, uppercase = TRUE)
well_format(x, num_width = 2, uppercase = TRUE)
x |
Vector of well IDs to be formatted. |
num_width |
Width to pad out number component with 0's. |
uppercase |
Logical, whether the letter should be upercase. |
Vector of strings as formatted well IDs.
well_format(c("A9", "c3", "h12"))
well_format(c("A9", "c3", "h12"))
Convert Numeric Index to Well ID.
well_from_index(x, plate = 96, num_width = 2, colwise = FALSE)
well_from_index(x, plate = 96, num_width = 2, colwise = FALSE)
x |
numeric index to convert to a well ID |
plate |
number of wells in the plate. One of c(6, 12, 24, 96, 384) |
num_width |
number of zeros to pad the column number with to the left. |
colwise |
if TRUE, index instead down the columns, so H01 is index 8, A12 is index 89 and B01 is index 2 for a 96 well plate. |
a column ID as a vector of strings.
# indexing first along the rows well_from_index(1:20) # indexing first down the columns well_from_index(1:20, colwise = TRUE)
# indexing first along the rows well_from_index(1:20) # indexing first down the columns well_from_index(1:20, colwise = TRUE)
Joins a column number and a row letter or number into a well ID. i.e. joins "A" and "1" to "A01" and joins "3 and "10" to "C10".
well_join(row, col, num_width = 2)
well_join(row, col, num_width = 2)
row |
either a row letter or number for to be coerced into a letter. |
col |
a column number. |
num_width |
the number of digits to pad out the column number with 0. |
a vector of well IDs as strings.
well_join(1:3, 4) well_join(c("A", "B", "H"), 9) well_join("C", 1:10)
well_join(1:3, 4) well_join(c("A", "B", "H"), 9) well_join("C", 1:10)
Takes a matrix where each row is a time point and each column is a well and converts it to a DataFrame containing a column for the well, a column for the row, a column for the column, a column for the time and a column for the values.
well_mat_frames_to_df(mat, value = "value")
well_mat_frames_to_df(mat, value = "value")
mat |
A matrix where each column is a well and each row is a frame from a multi time point experiment. |
value |
Name for the column containing the values in the resulting data frame. |
a tibble
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]) # convert the matrix back to a dataframe well_mat_frames_to_df(mat)
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]) # convert the matrix back to a dataframe well_mat_frames_to_df(mat)
Takes a matrix that is formatted as a plate, and converts it to a long-format 'tidy' data frame with a column for the well ID, the row, the column and the values that were in the matrix.
well_mat_to_df(matrix, value_col = "value")
well_mat_to_df(matrix, value_col = "value")
matrix |
A matrix object to be converted. |
value_col |
The name of the value column in the final DataFrame. |
a tibble
mat <- matrix(rnorm(96), ncol = 12) well_mat_to_df(mat, "random_values")
mat <- matrix(rnorm(96), ncol = 12) well_mat_to_df(mat, "random_values")
Generates a tibble that contains row, col, and well
ID for the size of the plate specified in nrow and ncol. If vectors of length
> 1
are supplied to either nrow or ncol, the contents of the vectors are used
instead of their numeric value.
well_plate(nrow = 8, ncol = 12)
well_plate(nrow = 8, ncol = 12)
nrow |
Number of rows to have in the generated plate. |
ncol |
NUmber of columns to have in the generated plate. |
a tibble
well_plate(nrow = 8, ncol = 12) well_plate(nrow = 4, ncol = 6)
well_plate(nrow = 8, ncol = 12) well_plate(nrow = 4, ncol = 6)
Plot a Plate Map
well_plot(data, well, value, colour = "black")
well_plot(data, well, value, colour = "black")
data |
Dataframe containing data. |
well |
Name of the column with well IDs. |
value |
Name of the column with the values to plot. |
colour |
Colour of the well borders. |
ggplot2 object.
dat <- wellr::well_plate()[, "well"] dat$value <- rnorm(96) well_plot(dat, well, value)
dat <- wellr::well_plate()[, "well"] dat$value <- rnorm(96) well_plot(dat, well, value)
Reorder a Plate-Based DataFrame
well_reorder_df(data, well_col = "well", row_col = NULL, col_col = NULL)
well_reorder_df(data, well_col = "well", row_col = NULL, col_col = NULL)
data |
Data frame to reorder, than contains a row column and a col column. |
well_col |
Column containing the well IDs. |
row_col |
Column containing the row letters or numbers. |
col_col |
Column containing the column numbers. |
A data.frame that has been reordered according to the row
& col
columns.
df <- well_plate(nrow = 8, ncol = 12) df <- df[sample(1:96, 96), ] head(df) df <- well_reorder_df(df) head(df)
df <- well_plate(nrow = 8, ncol = 12) df <- df[sample(1:96, 96), ] head(df) df <- well_reorder_df(df) head(df)
Extract number from well ID.
well_to_col_num(x)
well_to_col_num(x)
x |
Well ID as string in format "A10" |
Numeric verctor of column numbers extracted from well ID.
well_to_col_num(c("A10", "c3", "h12")) well_to_col_num("H08") well_to_col_num("h8")
well_to_col_num(c("A10", "c3", "h12")) well_to_col_num("H08") well_to_col_num("h8")
Indexes along rows first, so A12 is index 12 and B01 is index 13 for a 96 well plate.
well_to_index(x, plate = 96, colwise = FALSE)
well_to_index(x, plate = 96, colwise = FALSE)
x |
string well ID |
plate |
size of the plate. One of c(6, 12, 24, 96, 384) |
colwise |
if TRUE, index instead down the columns, so H01 is index 8, A12 is index 89 and B01 is index 2 for a 96 well plate. |
numeric well index.
# indexing along the row first well_to_index(c("A10", "c3", "h12")) well_to_index("H08") well_to_index("h8") well_to_index("C20") # indexing instead down the column first well_to_index(c("A10", "c3", "h12"), colwise = TRUE) well_to_index("H08", colwise = TRUE) well_to_index("h8", colwise = TRUE) well_to_index("C20", colwise = TRUE)
# indexing along the row first well_to_index(c("A10", "c3", "h12")) well_to_index("H08") well_to_index("h8") well_to_index("C20") # indexing instead down the column first well_to_index(c("A10", "c3", "h12"), colwise = TRUE) well_to_index("H08", colwise = TRUE) well_to_index("h8", colwise = TRUE) well_to_index("C20", colwise = TRUE)
Extracts letter from well ID.
well_to_row_let(x)
well_to_row_let(x)
x |
Well ID as string. |
a string which is the letter extracted from a well ID.
well_to_row_let(c("A10", "c3", "h12")) well_to_row_let("H08") well_to_row_let("h8") well_to_row_let("C20")
well_to_row_let(c("A10", "c3", "h12")) well_to_row_let("H08") well_to_row_let("h8") well_to_row_let("C20")
Calculates the row, but returns it as a number.
well_to_row_num(x)
well_to_row_num(x)
x |
Well ID as a string. |
Numeric row number.
well_to_row_num(c("A10", "c3", "h12")) well_to_row_num("H08") well_to_row_num("h8") well_to_row_num("C20")
well_to_row_num(c("A10", "c3", "h12")) well_to_row_num("H08") well_to_row_num("h8") well_to_row_num("C20")