PStrainingWithWeights: PS training with weights

View source: R/PStrainingWithWeights.R

PStrainingWithWeightsR Documentation

PS training with weights

Description

This is the wrap up function to select top features, estimate parameters, and calculate PS (Prediction Strength) scores based on a given training data set.

Usage

PStrainingWithWeights(
  trainDat,
  groupInfo,
  refGroup = NULL,
  weights,
  classProbCut = 0.9,
  imputeNA = FALSE,
  byrow = TRUE,
  imputeValue = c("median", "mean")
)

Arguments

trainDat

training data set, a data matrix or a data frame, samples are in columns, and features/traits are in rows

groupInfo

a known group classification, which order should be the same as in colnames of trainDat

refGroup

the code for reference group, default is the 1st item in groupInfo

weights

a numeric vector with selected features (as names of the vector) and their weights

classProbCut

a numeric variable within (0,1), which is a cutoff of Empirical Bayesian probability, often used values are 0.8 and 0.9, default value is 0.9. Only one value is used for both groups, the samples that are not included in either group will be assigned as UNCLASS

imputeNA

a logic variable to indicate if NA imputation is needed, if it is TRUE, NA imputation is processed before any other steps, the default is FALSE

byrow

a logic variable to indicate direction for imputation, default is TRUE, which will use the row data for imputation

imputeValue

a character variable to indicate which value to be used to replace NA, default is "median", the median value of the chose direction with "byrow" data to be used

Details

PS calculation is based on Golub 1999. In this wrap up function, we use four steps to calculate PS scores and classification. The range of PS scores is [-1,1]. Before these four steps, we also give an option for NA imputation. The four steps are: a) apply "standardize" to standardize input data matrix for each feature; b) apply "getTrainingWeights" to select features and return weights for these features; c) apply "getMeanOfGroupMeans" to get mean of group means for each selected feature; d) use "apply" function to get PS scores for all samples with "getPS1sample", the formula is: PS = (V_win − V_lose)/(V_win + V_lose) Here, where V_win and V_lose are the vote totals for the winning and losing features/traits for a given sample This function also give classification for the training group and confusion matrix to compare PS classification with original group info for training data set. If NAs are not imputed, they are ignored for feature selection, weight calculation, PS parameter estimation, and PS calculation.

Value

A list with three items is returned: PS parameters for selected features, PS scores and classifications for training samples, and confusion matrix to compare classification based on PS scores and original classification.

PS_pars

a data frame with all parameters needed for PS calculation for each selected features

PS_train

a data frame of PS score, true classification and its classification based on scores for all training samples

classCompare

a confusion matrix list object that compare PS classification based on selected features and weights compared to input group classification for training data set

classTable

a table to display comparison of PS classification based on selected features and weights compared to input group classification for training data set

References

Golub TR, Slonim DK, Tamayo P, Huard C, Gaasenbeek M, Mesirov JP, et al. Molecular classification of cancer: class discovery and class prediction by gene expression monitoring. Science. 1999;286:531–7


ajiangsfu/PRPS documentation built on April 29, 2023, 10:13 p.m.