This function computes summary
score(s) of the signature i in input
considering each column vector in the input matrix
x.
Usage
computeScores(
x,
i = NULL,
na.rm = TRUE,
scorers = NULL,
scores = NULL,
args = NULL,
sample.id = TRUE,
cores = 1L,
logger = NULL,
filename = "sigscores",
outdir = NULL
)Arguments
- x
features-by-samples matrix
- i
(optional) numerical vector giving the rows in
xor character vector matching the row names inxIfmissingori = NULL, all the rows inxare considered for the computation of the scores- na.rm
logical, whether to remove
NAvalues before computation- scorers
named list of scoring functions. If provided,
scoresis not considered. Each function must accept some specific arguments, i.e.x,i,na.rm,...and is expected to compute a score for each column inx- scores
(optional) character vector, indicating the summary score(s) to compute
- args
named list, where the names must match the
scoresor the names ofscorers. Each element in the list is another list containing the arguments to pass to the function used for computing the named score. For example,args = list(trimmedMean = list(trim = 0.4))indicates to usetrim = 0.4when computing the trimmed mean scores (scores = "trimmedMean"orscorers = list(trimmedMean = getScorer("trimmedMean")))- sample.id
logical, whether to report the sample ID as a column in the output data frame
- cores
number of cores to use for parallel execution.
- logger
(optional) a
Loggerobject. If provided, it will be used to report extra information on progress. To create a Logger usecreateLogger- filename
(optional) character string, a name without extension for the output file
- outdir
(optional) character string, path to the output directory. If provided the returned data will be stored
Value
A data frame containing the computed score(s) for each sample. Each row corresponds to a different sample.
Details
computeScores uses the provided scorers
to calculate the measures.
If scorers = NULL and scores are provided,
the scorers are retrieved by using the function
getScorers:
"sum""weightedSum""mean""trimmedMean""weightedMean""median""mode""midrange""midhinge""trimean""iqr""iqm""mad""aad""ssgsea""gsva""plage""zscore"
Look at the different functions to know which specific
arguments they accept (arguments can be passed via the
args parameter).
Scorers also accepts a transformation function
via the transform.fun argument, which
is used to transform the data before the computation
of the scores so that:
x = transform.fun(x = x, transform.args),
where transform.args is a list of parameters passed
to the transformation function.
Look at the different functions for further details.
Examples
if (FALSE) { # \dontrun{
#set seed for reproducibility
set.seed(seed = 5381L)
#Define row/col size
nr = 20
nc = 10
#Create input matrix
x = matrix(
data = stats::runif(n = nr*nc, min = 0, max = 1000),
nrow = nr,
ncol = nc,
dimnames = list(
paste0("g",seq(nr)),
paste0("S",seq(nc))
)
)
#Compute all scores
computeScores(
x = x,
i = rownames(x)[1:10]
)
#Compute all scores using 'scorers' argument
computeScores(
x = x,
i = rownames(x)[1:10],
scorers = list(
'score1' = getScorer('sum'),
'score2' = getScorer('mean')
)
)
#Pass different parameters to the same scorer
computeScores(
x = x,
i = rownames(x)[1:10],
scorers = list(
'score1' = getScorer('trimmedMean'),
'score2' = getScorer('trimmedMean')
),
args = list(
'score1' = list(trim = 0),
'score2' = list(trim = 0.3)
)
)
#Transform data and compute the scores
computeScores(
x = x,
i = rownames(x)[1:10],
scorers = list(
'score1' = getScorer('weightedSum'),
'score2' = getScorer('mean')
),
args = list(
'score1' = list(transform.fun = getDataTransformer('quantile')),
'score2' = list(
transform.fun = getDataTransformer('stepFunction'),
transform.args = list(
method = 'median',
by = 'rows'
)
)
)
)
} # }