knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
The goal of experDesign is to help you distribute your samples before an experiment but after they are collected. For example, checking for common problems in the data, and reducing or even preventing batch bias before performing an experiment, or measuring it once the experiment is performed. It provides four main functions:
check_data()
: Check if there are any problems with the data.design()
: Randomize the samples according to their variables.replicates()
: Selects some samples for replicates and randomizes the samples (highly recommended).spatial()
: Randomize the samples on a spatial grid.There are other helpers.
To install the latest version on CRAN use:
install.packages("experDesign")
::: {.pkgdown-devel} You can install the development version of pkgdown from GitHub with:
# install.packages("devtools") devtools::install_github("llrs/experDesign")
:::
We can use the survey dataset for the examples:
library("experDesign") data(survey, package = "MASS") head(survey)
The dataset has numeric, categorical values and NA
values.
We can check some issues from an experimental point of view via check_data()
:
check_data(survey)
As you can see with the warnings we get a collections of problems. In general, try to have at least 3 replicates for each condition and try to have all the data of each variable.
Imagine that we can only work in groups of 70, and we want to randomize by Sex,
Smoke, Age, and by hand.
There are r choose(237, 70)
combinations of samples per batch in a
this experiment.
However, in some of those combinations all the right handed students are in the same batch making it impossible to compare the right handed students with the others and draw conclusions from it.
We could check all the combinations to select those that allow us to do this comparison.
But as this would be too long with experDesign
we can try to find the combination with the best design by comparing each combination with the original according to multiple statistics.
# To reduce the variables used: omit <- c("Wr.Hnd", "NW.Hnd", "Fold", "Pulse", "Clap", "Exer", "Height", "M.I") (keep <- colnames(survey)[!colnames(survey) %in% omit]) head(survey[, keep]) # Set a seed for reproducibility set.seed(87732135) # Looking for groups at most of 70 samples. index <- design(pheno = survey, size_subset = 70, omit = omit, iterations = 100) index
We can transform then into a vector to append to the file or to pass to a colleague with:
head(batch_names(index)) # Or via inspect() to keep it in a matrix format: head(inspect(index, survey[, keep]))
The CRAN task View of Experimental Design includes many packages relevant for designing an experiment before collecting data, but none of them provides how to manage them once the samples are already collected.
Two packages allow to distribute the samples on batches:
The OSAT package handles categorical variables but not numeric data. It doesn't work with our data.
The minDiff package reported in Stats.SE, handles both numeric and categorical data. But it can only optimize for two nominal criteria. It doesn't work for our data.
The Omixer package handles both numeric and categorical data (converting categorical variables to numeric). But both the same way either Pearson's Chi-squared Test if there are few samples or Kendall's correlation. It does allow to protect some spots from being used.
If you are still designing the experiment and do not have collected any data DeclareDesign might be relevant for you. But specially the randomizr packages which makes common forms of random assignment and sampling.
Question in Bioinformatics.SE I made before developing the package.
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.