Heteroscedastic Nearest Shrunken Centroid Classification

Nearest shrunken centroid (NSC) classifiers for high-dimensional, low-sample-size data such as gene expression. Implements the original homoscedastic NSC with soft thresholding (Prediction Analysis of Microarrays; Tibshirani et al. 2002 ), its hard- and order-thresholding versions (Sahtout, Wang and Ghimire 2024 ), and the heteroscedastic extension of Sahtout and Wang that uses class-specific variances in both the test statistic and the discriminant function (methods STh3, HTh3 and OTh3). The thresholding parameter is selected by a refined ("deep") cross-validation search. Also provides the simulation design, per-class performance metrics and the relative-heterogeneity diagnostic used in the paper.


hetNSC

Heteroscedastic nearest shrunken centroid (NSC) classification for high-dimensional, low-sample-size data such as gene expression.

The package implements six classifiers:

Label Thresholding Variance in test statistic and discriminant
STh soft pooled: the original PAM (Tibshirani et al. 2002)
HTh hard pooled (Sahtout, Wang and Ghimire 2024)
OTh order pooled (Sahtout, Wang and Ghimire 2024)
STh3 soft class-specific (Sahtout and Wang)
HTh3 hard class-specific (Sahtout and Wang)
OTh3 order class-specific (Sahtout and Wang)

The threshold is chosen by the refined ("deep") cross-validation search of Sahtout, Wang and Ghimire (2024).

Installation

# from a local copy of the source package
install.packages("hetNSC_0.1.0.tar.gz", repos = NULL, type = "source")

# or, once it is on GitHub
# remotes::install_github("<user>/hetNSC")

The package only depends on base R and MASS.

Quick start

Expression matrices have genes in rows and samples in columns (as in pamr).

library(hetNSC)

set.seed(8900)
dat <- simulate_hetero_data(ntr1 = 15, ntr2 = 20, nte1 = 50, nte2 = 50,
                            p = 1000, a = 14)

fit <- hnsc(dat$xtr, dat$ytr, method = "HTh3")   # or method = "hard", variance = "hetero"
fit
pred <- predict(fit, dat$xte)                    # class labels
mean(pred != dat$yte)                            # test error
predict(fit, dat$xte, type = "posterior")        # posterior probabilities
fit$selected.genes                               # genes used

Main functions

Function Purpose
hnsc() Fit a classifier with the threshold selected by deep CV
predict() Class labels, posterior probabilities, shrunken centroids or selected genes
hnsc_train(), hnsc_cv(), hnsc_select() Threshold grid fit, cross-validation, deep CV search
compare_nsc() Repeated-run comparison of homoscedastic vs heteroscedastic versions (protocol of the paper); summary() and recall_table() summarise it
simulate_hetero_data() Correlated-gene simulation designs (class B only, or both classes)
compute_rho2() Relative heterogeneity and bias-variance crossover check (Section 2.4)
make_cm(), per_class_recall(), balanced_acc() Class-level metrics
hnsc_methods() Table of the six classifiers

See vignette("hetNSC") for a walk-through, and system.file("scripts", "simulation_correlated.R", package = "hetNSC") for the full correlated-gene simulation studies.

Reproducibility

The original research scripts are kept in inst/legacy. For the same random seed the package returns the same selected thresholds, cross-validation errors, test errors, numbers of genes and posterior probabilities as those scripts; tests/testthat/test-legacy.R checks this.

Citation

citation("hetNSC")
  • Sahtout, M. O. and Wang, H. Heteroscedastic nearest shrunken centroid classification: Methods and applications to high-dimensional data. Statistical Applications in Genetics and Molecular Biology (accepted).
  • Sahtout, M. O., Wang, H. and Ghimire, S. (2024). Different thresholding methods on nearest shrunken centroid algorithm. Communications in Statistics - Simulation and Computation, 53(3), 1444-1460. https://doi.org/10.1080/03610918.2022.2047201

License

GPL-2 (GNU General Public License, version 2 only; see LICENSE). This is the licence of the R package pamr by Hastie, Tibshirani, Narasimhan and Chu, from which parts of the code are adapted.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("hetNSC")

0.1.0 by Haiyan Wang, a day ago


Browse source code at https://github.com/cran/hetNSC


Authors: Haiyan Wang [aut, cre] , Mohammad Omar Sahtout [aut] , Trevor Hastie [ctb] (Author of the 'pamr' code this package is derived from) , Robert Tibshirani [ctb] (Author of the 'pamr' code this package is derived from) , Balasubramanian Narasimhan [ctb] (Author of the 'pamr' code this package is derived from) , Gilbert Chu [ctb] (Author of the 'pamr' code this package is derived from)


Documentation:   PDF Manual  


GPL-2 license


Imports MASS, stats

Suggests testthat, knitr, rmarkdown, pamr


See at CRAN