Learn R Programming

drLumi (version 0.1.2)

data_selection: Extracts samples information from a lum_export object or data.frame

Description

Extracts from a lum_export or data.frame object controls, dilutions points, background and samples to be calibrated. These files can be merged to an expected concentration and flag dataset.

Usage

data_selection(x, ecfile = NULL, flagsfile = NULL, backname = "Back", stanname = "Stan", posname = "Con", unkname = NULL, byvar.ecfile = c("analyte", "sample"), byvar.flagsfile = c("well", "analyte"), fsample = "sample", fanalyte = "analyte", fbatch = "plate", ...)

Arguments

x
a lum_export object or data.frame with samples information.
ecfile
a data.frame or CSV path file with the expected concentration in order to merge to x.
flagsfile
a data.frame or CSV path with the flags information in order to merge to x.
backname
character vector or list of the background samples identification of x.
stanname
character vector or list of the standard points identification of x.
posname
character vector or list of the positive controls identification of x.
unkname
character vector or list of the samples identification of x. Default NULL.
byvar.ecfile
character vector of the merging variable(s) of x and ecfile.
byvar.flagsfile
character vector of the merging variable(s) of x and flagsfile.
fsample
character vector of the name of the sample variable.
fanalyte
character vector of the name of the analyte variable.
fbatch
character vector of the name of the Batch variable.
...
other options. Ignored.

Value

The name of the batch in a list format with the following components: background, standard, positive and unknowns datasets.

Details

Default method for identifying background, standard and positives samples is to define a character vector of length one and apply agrep functions in order to extract databases. Samples to be calibrated (unknowns) are identified as the remaining ones (default NULL).

If the arguments are defined as a list the function will subset exactly that information from x object.

The expected concentration file is merged based on byvar.ecfile. Only applies when ecfile is not NULL. Same applies for flags file. A variable named 'flag' must be in flags data in order to perform the merge.

Examples

Run this code
# Load data
data(ecdata)
data(mfidata)

dat <- subset(mfidata,plate=="plate_1" & analyte=="FGF")

# Example 1
sdf <- data_selection(dat)

lapply(sdf$plate_1, function(x) head(x))

# Example 2 (merge ecdata)
sdf <- data_selection(dat, ecfile = ecdata,
             byvar.ecfile=c("analyte","sample"))

lapply(sdf$plate_1, function(x) head(x))

# Example 3 (extract specific samples names with list)
sdf <- data_selection(dat,
             stanname=list("Standard10"),
             backname = list("Background0"),
             posname = list("Control1","Control2"),
             unkname = list("B_sid_13_CSP"))

lapply(sdf$plate_1, function(x) head(x))

# Example 4 (extract aproximate names samples)
sdf <- data_selection(dat,
             stanname="Standard1",
             backname = "Background0",
             posname = "Control1",
             unkname = "B_sid_13_CSP")

lapply(sdf$plate_1, function(x) (x))

Run the code above in your browser using DataLab