ImportSamples {TargetSearch} | R Documentation |
This function imports a sample list that will be processed from a tab delimited file.
ImportSamples(sampfile, CDFpath=".", RIpath=".", ftype=c("binary", "text"), ...) ImportSamplesFromDir(CDFpath=".", RIfiles=FALSE, ignore.case=TRUE, ftype=c("binary", "text"))
sampfile |
A character string naming a sample file or a |
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 |
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 |
The sample file is a tab-delimited text file or, alternatively, a
data.frame
like the one would get by calling
read.delim
. The following two columns
are expected:
CDF_FILE
- The list of baseline corrected CDF files.
MEASUREMENT_DAY
- The day when the sample was measured.
The function first looks for columns matching those names. If they are not found, then it looks for columns with the substrings 'cdf' and 'day' respectively. If the 'cdf' column is not found, the function raises an error, but if 'day' is not found, then it assumes the measurement day is the same for all. In case of multiple matches, then it takes the first column. The column order does not 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.
A tsSample
object.
Alvaro Cuadros-Inostroza, Matthew Hannah, Henning Redestig
# 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. It is required that the names must be unique. 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/"