Randomise the coordinates of the reactions in a plate, so that reactions with similar parameters are less likely to be affected by the same spatial technical biases. This is also useful when performing plate replicates. Finally, the coordinates of negative controls will usually make a non-symmetric pattern that helps to detect when a plate was rotated accidentally.
Usage
randomise(plate, seed, vector)
# S4 method for Plate,missing,missing
randomise(plate, seed, vector)
# S4 method for Plate,numeric,missing
randomise(plate, seed, vector)
# S4 method for Plate,missing,numeric
randomise(plate, seed, vector)
Arguments
- plate
A
Plate
object.- seed
An integer number to set the seed (optional).
- vector
A (usually random) vector to sort the plate with (optional).
Note
Working with random seeds is tricky. In particular, pay attention that
if you set the random seed just before running the randomise
function, its
results will become deterministic.
See also
Other Plate functions:
Plate-class
,
PlateTypeToWellNames()
,
as.character,Well-method
,
nextWell()
,
plateMap()
,
plateWellVolume()
,
seekReagent()
,
setWell()
,
set_block()
,
sourceReagent()
Examples
# Toy example of a 6-well plate containing a gradient increase of a reagent
p <- Plate(type = "6") |> set_block("A01~B03", "reagent", 1:6 * 10)
head(p)
#> DataFrame with 6 rows and 1 column
#> reagent
#> <numeric>
#> A01 10
#> A02 20
#> A03 30
#> B01 40
#> B02 50
#> B03 60
# Setting the same seed returns the same randomisation
randomise(p, seed = 1111) |> head()
#> DataFrame with 6 rows and 1 column
#> reagent
#> <numeric>
#> A01 40
#> A02 20
#> A03 50
#> B01 10
#> B02 60
#> B03 30
randomise(p, seed = 1111) |> head()
#> DataFrame with 6 rows and 1 column
#> reagent
#> <numeric>
#> A01 40
#> A02 20
#> A03 50
#> B01 10
#> B02 60
#> B03 30
# Not providing a seed returns a really random order
randomise(p) |> head()
#> DataFrame with 6 rows and 1 column
#> reagent
#> <numeric>
#> A01 20
#> A02 30
#> A03 50
#> B01 40
#> B02 60
#> B03 10
randomise(p) |> head()
#> DataFrame with 6 rows and 1 column
#> reagent
#> <numeric>
#> A01 30
#> A02 20
#> A03 40
#> B01 50
#> B02 10
#> B03 60
# The random order can also be passed with the vector argument
randomise(p, vector = sample(1:6)) |> head()
#> DataFrame with 6 rows and 1 column
#> reagent
#> <numeric>
#> A01 40
#> A02 10
#> A03 30
#> B01 60
#> B02 20
#> B03 50
# This means also that order can also be forced
randomise(p, vector = 6:1) |> head()
#> DataFrame with 6 rows and 1 column
#> reagent
#> <numeric>
#> A01 60
#> A02 50
#> A03 40
#> B01 30
#> B02 20
#> B03 10
# The randomisation vector is stored in the Plate object's metadata
p <- randomise(p)
p@metadata$randomisation_vector
#> [1] 3 6 2 1 4 5