Convert Different Data Classes into DataFrame and Filter Features
prepareData.Rd
Input data could be of matrix, MultiAssayExperiment, or DataFrame format and this function will prepare a DataFrame of features and a vector of outcomes and help to exclude nuisance features such as dates or unique sample identifiers from subsequent modelling.
Usage
# S4 method for class 'matrix'
prepareData(measurements, outcome, ...)
# S4 method for class 'data.frame'
prepareData(measurements, outcome, ...)
# S4 method for class 'DataFrame'
prepareData(
measurements,
outcome,
useFeatures = NULL,
maxMissingProp = 0,
maxSimilarity = 1,
topNvariance = NULL
)
# S4 method for class 'MultiAssayExperiment'
prepareData(measurements, outcomeColumns = NULL, useFeatures = NULL, ...)
# S4 method for class 'list'
prepareData(measurements, outcome = NULL, useFeatures = NULL, ...)
Arguments
- measurements
Either a
matrix
,DataFrame
orMultiAssayExperiment
containing all of the data. For amatrix
orDataFrame
, the rows are samples, and the columns are features.- ...
Variables not used by the
matrix
nor theMultiAssayExperiment
method which are passed into and used by theDataFrame
method.- outcome
Either a factor vector of classes, a
Surv
object, or a character string, or vector of such strings, containing column name(s) of column(s) containing either classes or time and event information about survival. If column names of survival information, time must be in first column and event status in the second.- useFeatures
Default:
NULL
(i.e. use all provided features). Ifmeasurements
is aMultiAssayExperiment
or list of tabular data, a named list of features to use. Otherwise, the input data is a single table and this can just be a vector of feature names. For any assays not in the named list, all of their features are used."clinical"
is also a valid assay name and refers to the clinical data table. This allows for the avoidance of variables such spike-in RNAs, sample IDs, sample acquisition dates, etc. which are not relevant for outcome prediction.- maxMissingProp
Default: 0.0. A proportion less than 1 which is the maximum tolerated proportion of missingness for a feature to be retained for modelling.
- maxSimilarity
Default: 1. A number between 0 and 1 which is the maximum similarity between a pair of variables to be both kept in the data set. For numerical variables, the Pearson correlation is used and for categorical variables, the Chi-squared test p-value is used. For a pair that is too similar, the second variable will be excluded from the data set.
- topNvariance
Default: NULL. If
measurements
is aMultiAssayExperiment
or list of tabular data, a named integer vector of most variable features per assay to subset to. If the input data is a single table, then simply a single integer. If an assays has less features, it won't be reduced in size but stay as-is.- outcomeColumns
If
measurements
is aMultiAssayExperiment
, the names of the column (class) or columns (survival) in the table extracted bycolData(data)
that contain(s) the each individual's outcome to use for prediction.