rankFeatures.RdUses supervised learning methods (PLS-DA, PLS, or DWD) to rank features by their ability to discriminate between groups or predict a continuous response. Based on PhiSpace's correlatePhiSpace but generalized to work with any numeric data (not just PhiSpace scores).
A matrix or data.frame where rows are observations and columns are features. Can also be a SpatialExperiment, SingleCellExperiment, or SummarizedExperiment object.
Either a character string specifying a column name in colData
(when data is an experiment object), or a vector of response values.
For classification (PLSDA, DWD), should be factor or character.
For regression (PLS), should be numeric.
Character string specifying the method: "PLSDA" for classification, "PLS" for regression, or "DWD" for binary classification. Default is "PLSDA".
Character string specifying data source when data is an
experiment object: "assay" or "reducedDim". Default is "reducedDim".
Character string specifying which assay to use when
source = "assay". Default is "logcounts".
Character string specifying which reduced dimension
to use when source = "reducedDim". Default is "PhiSpace".
Integer specifying number of components. If NULL (default), set automatically: number of classes for PLSDA, min(10, ncol(data)/2) for PLS. Not used for DWD.
Logical indicating whether to center features. Default is TRUE.
Logical indicating whether to scale features. Default is FALSE.
List of parameters for DWD method (see Details).
Integer seed for reproducibility. Default is NULL.
A list with class "FeatureRanking" containing:
The method used
Matrix of feature importance scores
Component or discriminant scores for observations
The fitted model object
Data frame with features ranked by importance
Summary of the response variable
List of parameters used
Methods:
PLSDA: Partial Least Squares Discriminant Analysis for multi-class classification. Features ranked by coefficient magnitude.
PLS: Partial Least Squares regression for continuous response. Features ranked by coefficient magnitude.
DWD: Distance Weighted Discrimination for binary classification. Features ranked by discriminant weights.
DWD Parameters (in dwd_params list):
kernel: Kernel function (default: vanilladot())
qval: q-value parameter (default: 1)
lambda: Regularization parameter or sequence (default: auto-tuned)
cv_folds: Cross-validation folds (default: 5)
if (FALSE) { # \dontrun{
# With matrix input - PLSDA
expr_mat <- t(assay(spe, "logcounts"))
result <- rankFeatures(expr_mat, response = spe$cluster, method = "PLSDA")
head(result$feature_ranking, 10)
# With experiment object - from assay
result <- rankFeatures(spe, response = "cluster", method = "PLSDA",
source = "assay", assay_name = "logcounts")
# From reduced dimensions (e.g., PhiSpace scores)
result <- rankFeatures(spe, response = "cluster", method = "PLSDA",
source = "reducedDim", reducedDim_name = "PhiSpace")
# PLS for continuous response
result <- rankFeatures(expr_mat, response = spe$spatial_score, method = "PLS")
# DWD for binary classification
result <- rankFeatures(expr_mat, response = spe$treatment, method = "DWD")
} # }