Learn R Programming

switchBox (version 1.6.0)

SWAP.CalculateSignedScore: Function to calculate the pair-wise scores.

Description

SWAP.CalculateSignedScore calculates the pair-wise scores between features pairs. The user may pass a filtering function to reduce the number of starting features, or provide a restricted set of pairs to limit the reported scores to this list.

Usage

SWAP.CalculateSignedScore(inputMat, phenoGroup, FilterFunc = SWAP.Filter.Wilcoxon, RestrictedPairs, ...)

Arguments

inputMat
is a numerical matrix containing the measurements (e.g., gene expression data) to be used to build the K-TSP classifier. The columns represent samples and the rows represent the features (e.g., genes). The number of columns must agree with the length of phenoGroup. Note that rownames(inputMat) will be construed as feature names (e.g., gene symbols) in all subsequent analyses.
phenoGroup
is a factor containing the training phenotypes with two levels.
FilterFunc
is a filtering function to reduce the starting number of features to be used to identify the Top Scoring Pairs (TSPs). The default filter is based on the Wilcoxon rank-sum test and alternative filtering functions can be passed too (see SWAP.Filter.Wilcoxon for details). Note the filtering function must return feature names, i.e. a subset of rownames(inputMat).
RestrictedPairs
is a character matrix with two columns containing the feature pairs to be considered for score calculations. Each row should contain a pair of feature names matching the rownames(inputMat). If RestrictedPairs is missing all available feature pairs will be considered.
...
Additional argument passed to the filtering function FilterFunc.

Value

The output is a list containing the following items:
labels
the levels (phenotypes) in phenoGroup.
P
a matrix or a vector containing the probability of comparisons in samples with phenotype equal to label[1]. In case RestrictedPairs is not given, P is a matrix and P[i,j] = P(InputMat1[i,] < InputMat2[j,] | phenoGroup == $label[1]). In case RestrictedPairs is given, P[k] = P(InputMat1[RestrictedPairs[k,1],] < InputMat2[RestrictedPairs[k,2],] | phenoGroup == $label[1]).
Q
a matrix or a vector containing the probability of comparisons in samples with phenotype label[2].
score
a matrix or a vector containing the pair-wise scores. Basically, score = P - Q + C. The C term is the tie breaker and proportion to the secondary score to avoid the ties.
Note that the P, Q, and score list elements are matrices when scores are computed for all possible feature pairs, while they are vectors when scores are computed for restricted pairs defined by RestrictedPairs.

References

See switchBox for the references.

See Also

See SWAP.KTSP.Train, SWAP.Filter.Wilcoxon, and SWAP.KTSP.Statistics.

Examples

Run this code

### Load gene expression data for the training set
data(trainingData)

### Show group variable for the TRAINING set
table(trainingGroup)

### Compute the scores using all features (a matrix will be returned)
scores <- SWAP.CalculateSignedScore(matTraining,  trainingGroup, FilterFunc=NULL, )

### Show scores
class(scores)
dim(scores$score)

### Get the scores for a couple of features
diag(scores$score[ 1:3 , 5:7 ])

### Compute the scores using the default filtering function for 20 features
scores <- SWAP.CalculateSignedScore(matTraining, trainingGroup, featureNo=20)

### Show scores
dim(scores$score)

### Creating some random pairs
set.seed(123)
somePairs <- matrix(sample(rownames(matTraining), 25, replace=FALSE), ncol=2)

### Compute the scores for restricted pairs (a vector will be returned)
scores <- SWAP.CalculateSignedScore(matTraining, trainingGroup,
				    FilterFunc = NULL, RestrictedPairs = somePairs )

### Show scores
class(scores$score)
length(scores$score)

Run the code above in your browser using DataLab