tsSample-class {TargetSearch}R Documentation

Class for representing samples

Description

This is a class to represent a set of samples.

Objects from the Class

Objects can be created by the function ImportSamples or by calling the object generator function.

new("tsSample", Names = [sample names], CDFfiles = [list of CDF file names], RIfiles = [list of RI file names], CDFpath = [CDF files path], RIpath = [RI files path], days = [measurement days], data = [additional sample information], ftype = [RI file format])

Slots

Names:

"character", the sample names.

CDFfiles:

"character", the list of CDF file names.

RIfiles:

"character", the list of RI file names.

CDFpath:

"character", CDF files path.

RIpath:

"character", RI file path.

days:

"character", measurement days.

data:

"data.frame", additional sample information.

Methods

[

signature(x = "tsSample"): Selects a subset of samples.

$name

signature(x = "tsSample"): Access column name of sampleData slot.

CDFfiles

signature(obj = "tsSample"): list of CDF files.

RIfiles

signature(obj = "tsSample"): list of RI files.

RIpath

signature(obj = "tsSample"): The RI file path.

CDFpath

signature(obj = "tsSample"): The CDF file path.

length

signature(x = "tsSample"): number of samples.

sampleData

signature(obj = "tsSample"): additional sample information.

sampleDays

signature(obj = "tsSample"): measurement days.

sampleNames

signature(obj = "tsSample"): sample names. The names must be unique

show

signature(object = "tsSample"): the show funtion.

fileFormat

signatureobj = "tsSample": Sets or gets the RI file format. Options are either "binary" or "text". See note below.

Notes

The method fileFormat only changes the internal information of the file type and not the files themselves. To actually change the files, use the functions bin2text and text2bin.

Note that the slot Names (i.e., the sample names/identifiers) must be unique. This allows sample selection by using sample identifiers as well as indices. Also, if columns are selected, the output will be either a vector or a data.frame depending on whether one or more columns were selected.

Author(s)

Alvaro Cuadros-Inostroza, Matthew Hannah, Henning Redestig

See Also

ImportSamples

Examples

showClass("tsSample")

# get a list of CDF files from a directory
require(TargetSearchData)
CDFpath <- system.file("gc-ms-data", package = "TargetSearchData")
cdffiles <- dir(CDFpath, "cdf")

# define the RI file path 
RIpath  <- "."

# create the sample object
sampleDescription <- new("tsSample", CDFfiles = cdffiles, CDFpath = CDFpath, RIpath = RIpath) 

##

# More parameters could be defined:
# define the RI files and the RI path
RIfiles <- sub("cdf$", "txt", paste("RI_", cdffiles, sep = ""))
RIpath  <- "."

# get the measurement days (the four first numbers of the cdf files, in this
# example)
days <- substring(cdffiles, 1, 4)

# sample names 
smp_names <- sub(".cdf", "", cdffiles, fixed = TRUE)

# add some sample info
smp_data <- data.frame(CDF_FILE =cdffiles, GROUP = gl(5,3))

# create the sample object
sampleDescription <- new("tsSample", Names = smp_names, CDFfiles = cdffiles, CDFpath = CDFpath,
    RIpath = RIpath, days = days, RIfiles = RIfiles, data = smp_data)

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

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

## sample subsetting.
# select samples 1, 3 and 5
(sampleset <- sampleDescription[c(1, 3, 5)])

# or use sample IDs
(sampleset <- sampleDescription[c("Sample_1", "Sample_3", "Sample_5")])

## extract columns
# select column 'GROUP'
(group <- sampleDescription$GROUP)
# or
(group <- sampleDescription[, 'GROUP'])


[Package TargetSearch version 1.40.3 Index]