Skip to contents

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 x or character vector matching the row names in x If missing or i = NULL, all the rows in x are considered for the computation of the scores

na.rm

logical, whether to remove NA values before computation

scorers

named list of scoring functions. If provided, scores is 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 in x

scores

(optional) character vector, indicating the summary score(s) to compute

args

named list, where the names must match the scores or the names of scorers. 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 use trim = 0.4 when computing the trimmed mean scores (scores = "trimmedMean" or scorers = 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 Logger object. If provided, it will be used to report extra information on progress. To create a Logger use createLogger

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"

sumScorer

"weightedSum"

weightedSumScorer

"mean"

meanScorer

"trimmedMean"

trimmedMeanScorer

"weightedMean"

weightedMeanScorer

"median"

medianScorer

"mode"

modeScorer

"midrange"

midrangeScorer

"midhinge"

midhingeScorer

"trimean"

trimeanScorer

"iqr"

iqrScorer

"iqm"

iqmScorer

"mad"

madScorer

"aad"

aadScorer

"ssgsea"

ssgseaScorer

"gsva"

gsvaScorer

"plage"

plageScorer

"zscore"

zscoreScorer

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.

Author

Alessandro Barberis

Examples

if (FALSE) {
#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'
     )
   )
 )
)
}