Learn R Programming

TargetSearch (version 1.28.1)

ImportSamples: Sample definitions

Description

This function imports a sample list that will be processed from a tab delimited file.

Usage

ImportSamples(sampfile, CDFpath=".", RIpath=".", ftype=c("binary", "text"), ...)
ImportSamplesFromDir(CDFpath=".", RIfiles=FALSE, ignore.case=TRUE, ftype=c("binary", "text"))

Arguments

sampfile
A character string naming a sample file. See details.
CDFpath
A character string naming a directory where the CDF files are located.
RIpath
A character string naming a directory where the RI corrected text files are/will be located.
RIfiles
Logical. If TRUE, the function will look for for RI files (RI_*) instead of CDF files (the default).
ftype
A character string giving the file type for RI files. Options are "binary" and "text".
ignore.case
Logical. Should pattern-matching be case-insensitive?
...
Other options passed to read.delim function.

Value

A tsSample object.

Details

The sample file is a tab-delimited text file with at least two columns:
  • CDF_FILE - The list of baseline corrected CDF files.
  • MEASUREMENT_DAY - The day when the sample was measured.

The column names must be exactly as those indicated, but the column order doesn't matter. Other columns could be included in that file. They won't be used by the script, but will be included in the "sample" R object.

The ftype parameter sets the file format of the RI files, which are created by the function RIcorrect. "text" is the classic text format and "binary" is a binary version, designed for speed, of the text format (TargetSearch >= 1.12.0). The file format can be identified by the file extension (".txt" for text, ".dat" for binary), but this is just an indicator: the file format is detected dinamically during file reading. Use the method fileFormat to set or get this parameter.

See Also

ImportLibrary, tsSample

Examples

Run this code
# get the sample definition definition file
cdfpath <- file.path(find.package("TargetSearchData"), "gc-ms-data")
sample.file  <- file.path(cdfpath, "samples.txt")

# set a path where the RI files will be created
RIpath <- "."

# import samples
sampleDescription <- ImportSamples(sample.file, CDFpath = cdfpath, RIpath = RIpath)

# change the sample names
sampleNames(sampleDescription) <- paste("Sample", 1:length(sampleDescription), sep = "_")

# change the file paths (relative to the working path)
CDFpath(sampleDescription) <- "my_cdfs/"
RIpath(sampleDescription)  <- "my_RIs/"

Run the code above in your browser using DataLab