randomizeSinglePlate: Randomize Single Plate

View source: R/MainFunctions.R

randomizeSinglePlateR Documentation

Randomize Single Plate

Description

Randomize up to 96 samples across a single 96 well plate.

Usage

randomizeSinglePlate(designTable, outputFile = NULL,
  primaryGroup = "SampleGroup", batchColumns = NULL, nIter = 10000,
  nCores = 4)

Arguments

designTable

The meta data table - a data.frame/tibble.

outputFile

The root name for the output files if required.

primaryGroup

The name of a column in the metadata table to use for optimising the distribution of samples across the plate

batchColumns

A character vector wit the names of additional columns in the metadata table to use in assessing the distribution of the samples across the plate.

nIter

The number of random layouts to generate and assess.

nCores

The number of cores to use. Set to 1 to run serial.

Details

The metadata (designTable) should be a data.frame/tibble. The column names can be anything. By default the function expects one column named SampleGroup that it will use to distribute the samples across the plate. This can be set to any other column using the primaryGroup argument.

The columns specified in batchColumns are used in addition to primaryGroup to assess which of the nIter layouts is optimal in terms of the distribution of samples. This is assessed based on the sum of Euclidean distances between replicate samples within each column.

Value

If no outputFile is provided, a tibble containing the original metadata and the well assignments for each sample. If an outputFile is provided, nothing - the function writes out the plate layout to a tsv file and a plot for each of 'primaryGroup' and 'batchColumns' to png files.

Examples

library(readr)
designSheet <- system.file("extdata", "metadata_12x3.tsv",
                           package = "PlateLayout")
bColumns <- c("ExtractionInformation", "PassageNumber") 
designTable <- read_tsv(designSheet)
# Create an R object in the session
plateLayout <- randomizeSinglePlate(designTable,  batchColumns = bColumns,
                     nIter = 100) 

# Or directly output a table and plots
outputFile <- "Test"
randomizeSinglePlate(designTable, 
                     outputFile = outputFile, 
                     batchColumns = bColumns,
                     nIter = 100) 

crukci-bioinformatics/PlateLayout documentation built on Feb. 27, 2023, 6:49 p.m.