readMSnSet: Read 'MSnSet'

View source: R/readMSnSet.R

readMSnSetR Documentation

Read 'MSnSet'

Description

This function reads data files to generate an MSnSet instance. It is a wrapper around Biobase's readExpressionSet function with an additional featureDataFile parameter to include feature data. See also readExpressionSet for more details. readMSnSet2 is a simple version that takes a single text spreadsheet as input and extracts the expression data and feature meta-data to create and MSnSet.

Note that when using readMSnSet2, one should not set rownames as additional argument to defined feature names. It is ignored and used to set fnames if not provided otherwise.

Usage

readMSnSet(exprsFile,
           phenoDataFile,
           featureDataFile,
           experimentDataFile,
           notesFile,
           path, annotation,
           exprsArgs = list(sep = sep, header = header, row.names = row.names, quote = quote, ...),
           phenoDataArgs = list(sep = sep, header = header, row.names = row.names, quote = quote, stringsAsFactors = stringsAsFactors, ...),
           featureDataArgs = list(sep = sep, header = header, row.names = row.names, quote = quote, stringsAsFactors = stringsAsFactors, ...),
           experimentDataArgs = list(sep = sep, header = header, row.names = row.names, quote = quote, stringsAsFactors = stringsAsFactors, ...),
           sep = "\t",
           header = TRUE,
           quote = "",
           stringsAsFactors = FALSE,
           row.names = 1L,
           widget = getOption("BioC")$Base$use.widgets, ...)

readMSnSet2(file, ecol, fnames, ...)

Arguments

Arguments direclty passed to readExpressionSet. The description is from the readExpressionSet documentation page.

exprsFile

(character) File or connection from which to read expression values. The file should contain a matrix with rows as features and columns as samples. read.table is called with this as its file argument and further arguments given by exprsArgs.

phenoDataFile

(character) File or connection from which to read phenotypic data. read.AnnotatedDataFrame is called with this as its file argument and further arguments given by phenoDataArgs.

experimentDataFile

(character) File or connection from which to read experiment data. read.MIAME is called with this as its file argument and further arguments given by experimentDataArgs.

notesFile

(character) File or connection from which to read notes; readLines is used to input the file.

path

(optional) directory in which to find all the above files.

annotation

(character) A single character string indicating the annotation associated with this ExpressionSet.

exprsArgs

A list of arguments to be used with read.table when reading in the expression matrix.

phenoDataArgs

A list of arguments to be used (with read.AnnotatedDataFrame) when reading the phenotypic data.

experimentDataArgs

A list of arguments to be used (with read.MIAME) when reading the experiment data.

sep, header, quote, stringsAsFactors, row.names

arguments used by the read.table-like functions.

widget

A boolean value indicating whether widgets can be used. Widgets are NOT yet implemented for read.AnnotatedDataFrame.

...

Further arguments that can be passed on to the read.table-like functions.

Additional argument, specific to readMSnSet:

featureDataFile

(character) File or connection from which to read feature data. read.AnnotatedDataFrame is called with this as its file argument and further arguments given by phenoDataArgs.

featureDataArgs

A list of arguments to be used (with read.AnnotatedDataFrame) when reading the phenotypic data.

Arguments for readMSnSet2:

file

A character indicating the spreadsheet file or a data.frame (new in version 1.19.8). Default, when file is a character, is to read the file as a comma-separated values (csv). If different, use the additional arguments, passed to read.csv, to parametrise file import.

Passing a data.frame can be particularly useful if the spreadsheet is in Excel format. The appropriate sheet can first be read into R as a data.frame using, for example readxl::read_excel, and then pass it to readMSnSet2.

ecol

A numeric indicating the indices of the columns to be used as expression values. Can also be a character indicating the names of the columns. Caution must be taken if the column names are composed of special characters like ( or - that will be converted to a .. If ecol does not match, the error message will dislpay the column names are see by R.

fnames

An optional character or numeric of length 1 indicating the column to be used as feature names.

Value

An instance of the MSnSet class.

Author(s)

Laurent Gatto <laurent.gatto@uclouvain.be>

See Also

The grepEcols and getEcols helper functions to identify the ecol values. The MSnbase-io vignette illustrates these functions in detail. It can be accessed with vignette("MSnbase-io").

Examples

## Not run: 
exprsFile <- "path_to_intensity_file.csv"
fdatafile <- "path_to_featuredata_file.csv"
pdatafile <- "path_to_sampledata_file.csv"
## Read ExpressionSet with appropriate parameters
res <- readMSnSet(exprsFile, pdataFile, fdataFile, sep = "\t", header=TRUE)

## End(Not run)

library("pRolocdata")
f0 <- dir(system.file("extdata", package = "pRolocdata"),
          full.names = TRUE,
          pattern = "Dunkley2006")
basename(f0)
res <- readMSnSet2(f0, ecol = 5:20)
res
head(exprs(res)) ## columns 5 to 20
head(fData(res)) ## other columns

lgatto/MSnbase documentation built on Nov. 12, 2024, 10:58 a.m.