Giter VIP home page Giter VIP logo

comppls's Introduction

compPLS

An R package for [sparse] Partial least squares discriminant analysis and biplots for compositional data analysis.

This package is the implementation for the method developed in Lee et al. (2014) [1] for the classification of independently-sampled microbial compositions based on Helminth-infection status of a people in Malaysia. Under an assumption of model sparsity (that is, relatively few microbial populations truly correlate with Helminth-status) we get a factor analysis as well as a classifier.

Currently, this package consists of functions for compositionally-robust data transformations that you can apply prior to (sparse) partial least squares discriminant analysis: here, just wrappers to key functions from the caret package [2]. As described in the paper, I've added parameter selection via cross-validation and bootstrap-based p-value calculation to assess PLS model coefficients (for feature selection). This package also includes some methods for ggplot2-based biplots for PLS-DA output, and for a few other commonly used projection/ordination/classification methods. This code was forked from vqv's biplot package [3].

This package is still under development and I am currently adding features, based on some new and exciting microbiome data being generated by the good people at the Loke lab [4] and collaborators. Installation and example instructions will be added soon.

Installation

This development package requires the devtools package for installation. Additionally, compPLS depends on the caret and MASS packages. Suggested packages are boot, (for bootstrapping) ggplot2, grid and scales (for biplots).

 library(devtools)
 install_github('zdk123/compPLS')

Usage

Some minimal examples for running 1) PLS 2) sparse PLS and biplots for the results.

 # a too low-dim example, for code demo purposes only
 data(ArcticLake)
 # clr transform the data along row margin (1)
 ALake.clr <- clr(ArcticLake[,1:3], 1)
 res <- plsDA(ALake.clr, grouping=ArcticLake[,4], K=2)
 ggbiplot(res, grouping=ArcticLake[,4], group.ellipse=TRUE, label.loadings=TRUE, label.offset=.2, alpha=.6)
 # alternative biplot
 biplot(res)
 
 ## a higher dim example
 set.seed(1100)
 data(Hydrochem)
 Hchem.clr <- clr(Hydrochem[,6:19], 1)
 # try without bootstrapping
 res <- plsDA_main(Hchem.clr, grouping=Hydrochem$River, K=8:10, nboots=0) #, n.core=4) # if on multicore system
 ggbiplot(res$plsda, grouping=Hydrochem$River, group.ellipse=TRUE, alpha=.5, plot.loadings=FALSE, label.loadings=TRUE)
 optK <- res$plsda$ncomp
 
 # do bootstrapping, warning: this can take a long time 
  res <- plsDA_main(Hchem.clr, grouping=Hydrochem$River, K=optK, nboots=999) #, n.core=4) # if on multicore system

[1] http://www.plosntds.org/article/info%3Adoi%2F10.1371%2Fjournal.pntd.0002880

[2] http://topepo.github.io/caret/index.html

[3] https://github.com/vqv/ggbiplot

[4] http://microbiology-parasitology.med.nyu.edu/png-loke

comppls's People

Contributors

zdk123 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.