Package 'o2plsda'

Title: Multiomics Data Integration
Description: Provides functions to do 'O2PLS-DA' analysis for multiple omics data integration. The algorithm came from "O2-PLS, a two-block (X±Y) latent variable regression (LVR) method with an integral OSC filter" which published by Johan Trygg and Svante Wold at 2003 <doi:10.1002/cem.775>. 'O2PLS' is a bidirectional multivariate regression method that aims to separate the covariance between two data sets (it was recently extended to multiple data sets) (Löfstedt and Trygg, 2011 <doi:10.1002/cem.1388>; Löfstedt et al., 2012 <doi:10.1016/j.aca.2013.06.026>) from the systematic sources of variance being specific for each data set separately.
Authors: Kai Guo [aut, cre], Junguk Hur [aut], Eva Feldman [aut]
Maintainer: Kai Guo <[email protected]>
License: GPL-3
Version: 0.0.25
Built: 2024-11-16 06:30:16 UTC
Source: CRAN

Help Index


Extract the loadings from an O2PLS fit

Description

This function extracts loading parameters from an O2PLS fit

This function extracts loading parameters from an O2PLS fit

Usage

loadings(x, ...)

## S3 method for class 'O2pls'
loadings(x, loading = c("Xjoint", "Yjoint", "Xorth", "Yorth"), ...)

Arguments

x

Object of class O2pls

...

For consistency

loading

the loadings for one of "Xjoint", "Yjoint", "Xorth", "Yorth"

Value

Loading matrix

Loading matrix


extract the loading value from the O2PLSDA analysis

Description

extract the loading value from the O2PLSDA analysis

Usage

## S3 method for class 'o2plsda'
loadings(x, loading = "Xloading", ...)

Arguments

x

Object of class o2plsda

loading

the loadings for one of "Xjoint", "Yjoint", "Xorth", "Yorth"

...

For consistency


extract the loading value from the PLSDA analysis

Description

extract the loading value from the PLSDA analysis

Usage

## S3 method for class 'plsda'
loadings(x, ...)

Arguments

x

Object of class plsda

...

For consistency


Cross validation for O2PLS

Description

Cross validation for O2PLS

Usage

o2cv(
  X,
  Y,
  nc,
  nx,
  ny,
  group = NULL,
  nr_folds = 5,
  ncores = 1,
  scale = FALSE,
  center = FALSE
)

Arguments

X

a Numeric matrix (input)

Y

a Numeric matrix (input)

nc

Integer. Number of joint PLS components.

nx

Integer. Number of orthogonal components in X

ny

Integer. Number of orthogonal components in Y

group

a vector to indicate the group for Y

nr_folds

Integer to indicate the folds for cross validation

ncores

Integer. Number of CPUs to use for cross validation

scale

boolean values determining if data should be scaled or not

center

boolean values determining if data should be centered or not

Value

a data frame with the Q and RMSE values

Author(s)

Kai Guo

Examples

set.seed(123)
X = matrix(rnorm(500),50,10)
Y = matrix(rnorm(500),50,10)
X = scale(X, scale = TRUE)
Y = scale(Y, scale = TRUE)
# group factor could be omitted if you don't have any group 
group <- rep(c("Ctrl","Treat"), each = 25)
cv <- o2cv(X, Y, 1:2, 1:2, 1:2, group=group, nr_folds = 2, ncores=1)

fit O2PLS model with best nc, nx, ny

Description

fit O2PLS model with best nc, nx, ny

Usage

o2pls(X, Y, nc, nx, ny, scale = FALSE, center = FALSE)

Arguments

X

a Numeric matrix (input)

Y

a Numeric matrix (input)

nc

Integer. Number of joint PLS components.

nx

Integer. Number of orthogonal components in X

ny

Integer. Number of orthogonal components in Y

scale

boolean values determining if data should be scaled or not

center

boolean values determining if data should be centered or not

Value

An object containing

Xscore

Joint XX scores

Xloading

Joint XX loadings

Yscore

Joint YY scores

Yloading

Joint YY loadings

TYosc

Orthogonal XX scores

PYosc

Orthogonal XX loadings

WYosc

Orthogonal XX weights

UXosc

Orthogonal YY scores

PXosc

Orthogonal YY loadings

CXosc

Orthogonal YY weights

BU

Regression coefficient in Tt ~ U

BT

Regression coefficient in U ~ Tt

Xhat

Prediction of XX with YY

Yhat

Prediction of YY with XX

R2Xhat

Variation of the predicted XX as proportion of variation in XX

R2Yhat

Variation of the predicted YY as proportion of variation in YY

R2X

Variation of the modeled part in XX (defined by Joint + Orthogonal variation) as proportion of total variation in XX

R2Y

Variation of the modeled part in YY (defined by Joint + Orthogonal variation) as proportion of total variation in YY

R2Xcorr

Variation of the joint part in XX

R2Ycorr

Variation of the joint part in YY

R2Xo

Variation of the orthogonal part in XX as proportion of variation in XX

R2Yo

Variation of the orthogonal part in YY as proportion of variation in YY

R2Xp

Variation in XX joint part predicted by YY Joint part

R2Yp

Variation in YY joint part predicted by XX Joint part

varXj

Variation in each Latent Variable (LV) in XX Joint part

varYj

Variation in each Latent Variable (LV) in YY Joint part

varXorth

Variation in each Latent Variable (LV) in XX Orthogonal part

varYorth

Variation in each Latent Variable (LV) in YY Orthogonal part

Exy

Residuals in XX

Fxy

Residuals in YY

Author(s)

Kai Guo

Examples

set.seed(123)
X = matrix(rnorm(500),50,10)
Y = matrix(rnorm(500),50,10)
X = scale(X, scale = TRUE)
Y = scale(Y, scale = TRUE)
fit <- o2pls(X, Y, 1, 2, 2)
summary(fit)

Class "O2pls" This class represents the Annotation information

Description

Class "O2pls" This class represents the Annotation information

Slots

X

a Numeric matrix (input)

Y

a Numeric matrix (input)

params

paramaters ysed in o2pls analysis

results

list of o2pls results

Author(s)

Kai Guo


Orthogonal partial least squares discriminant analysis

Description

Computes orthogonal scores partial least squares regressions with the NIPALS algorithm. It return a comprehensive set of pls outputs (e.g. scores and vip).

Usage

oplsda(X, Y, nc, scale = FALSE, center = TRUE, maxiter = 100, tol = 1e-05)

Arguments

X

a O2pls object or a matrix of predictor variables.

Y

a single vector indicate the group

nc

the number of pls components (the one joint components + number of orthogonal components ).

scale

logical indicating whether X must be scaled (suggest TRUE).

center

boolean values determining if data should be centered or not

maxiter

maximum number of iterations.

tol

limit for convergence of the algorithm in the nipals algorithm.

Value

a list containing the following elements:

  • nc the number of components used(one joint components + number of orthogonal components

  • scores a matrix of scores corresponding to the observations in X, The components retrieved correspond to the ones optimized or specified.

  • Xloadings a matrix of loadings corresponding to the explanatory variables. The components retrieved correspond to the ones optimized or specified.

  • Yloadings a matrix of partial least squares loadings corresponding to Y

  • vip the VIP matrix.

  • xvar a matrix indicating the standard deviation of each component (sd), the variance explained by each single component (explained_var) and the cumulative explained variance (cumulative_explained_var). These values are computed based on the data used to create the projection matrices.

  • projection_matrix the matrix of projection matrix

  • weight a matrix of partial least squares ("pls") weights.

Author(s)

Kai Guo

Examples

X <- matrix(rnorm(50),10,5)
Y <- matrix(rnorm(50),10,5)
fit <- o2pls(X,Y,2,1,1)
yy <- rep(c(0,1),5)
fit0 <- oplsda(fit,yy,2)

Score or loading plot for the O2PLS results

Description

Score or loading plot for the O2PLS results

Usage

## S3 method for class 'O2pls'
plot(
  x,
  type = "score",
  var = "Xjoint",
  group = NULL,
  ind = c(1, 2),
  color = NULL,
  top = 20,
  ellipse = TRUE,
  order = FALSE,
  pt.size = 3,
  label = TRUE,
  label.size = 4,
  repel = TRUE,
  rotation = FALSE,
  ...
)

Arguments

x

an O2pls object

type

score or loading

var

specify Xjoint

group

color used for score plot

ind

which components to be used for score plot or loading plot

color

color used for score or loading plot

top

the number of largest loading value to plot

ellipse

TRUE/FALSE

order

order by the value or not

pt.size

point size

label

plot label or not (TRUE/FALSE)

label.size

label size

repel

use ggrepel to show the label or not

rotation

flip the figure or not (TRUE/FALSE)

...

For consistency

Value

a ggplot2 object

Author(s)

Kai Guo

Examples

X <- matrix(rnorm(50),10,5)
Y <- matrix(rnorm(50),10,5)
fit <- o2pls(X,Y,2,1,1)
plot(fit, type="score")

Score, VIP or loading plot for the O2PLS results

Description

Score, VIP or loading plot for the O2PLS results

Usage

## S3 method for class 'o2plsda'
plot(
  x,
  type = "score",
  group = NULL,
  ind = c(1, 2),
  color = NULL,
  top = 20,
  ellipse = TRUE,
  order = FALSE,
  pt.size = 3,
  label = TRUE,
  label.size = 4,
  repel = FALSE,
  rotation = FALSE,
  ...
)

Arguments

x

an o2plsda object

type

score, vip or loading

group

color used for score plot

ind

which components to be used for score plot or loading plot

color

color used for score or loading plot

top

the number of largest loading value to plot

ellipse

TRUE/FALSE

order

order by the value or not

pt.size

point size

label

plot label or not (TRUE/FALSE)

label.size

label size

repel

use ggrepel to show the label or not

rotation

flip the figure or not (TRUE/FALSE)

...

For consistency

Value

a ggplot2 object

Author(s)

Kai Guo

Examples

X <- matrix(rnorm(50),10,5)
Y <- matrix(rnorm(50),10,5)
fit <- o2pls(X,Y,2,1,1)
yy <- rep(c(0,1),5)
fit0 <- oplsda(fit,yy,2)
plot(fit0, type="score", group = factor(yy))

Score, VIP or loading plot for the plsda results

Description

Score, VIP or loading plot for the plsda results

Usage

## S3 method for class 'plsda'
plot(
  x,
  type = "score",
  group = NULL,
  ind = c(1, 2),
  color = NULL,
  top = 20,
  ellipse = TRUE,
  order = FALSE,
  pt.size = 3,
  label = TRUE,
  label.size = 4,
  repel = FALSE,
  rotation = FALSE,
  ...
)

Arguments

x

an plsda object

type

score, vip or loading

group

color used for score plot

ind

which components to be used for score plot or loading plot

color

color used for score or loading plot

top

the number of largest loading value to plot

ellipse

TRUE/FALSE

order

order by the value or not

pt.size

point size

label

plot label or not (TRUE/FALSE)

label.size

label size

repel

use ggrepel to show the label or not

rotation

flip the figure or not (TRUE/FALSE)

...

For consistency

Value

a ggplot2 object

Author(s)

Kai Guo

Examples

X <- matrix(rnorm(500),10,50)
Y <- rep(c("a","b"),each=5)
fit0 <- plsda(X,Y,2)
plot(fit0, type = "score", group = factor(Y))

Partial least squares discriminant analysis

Description

Perform a PLS discriminant analysis

Usage

plsda(X, Y, nc, scale = TRUE, center = TRUE, cv = TRUE, nr_folds = 5)

Arguments

X

a matrix of predictor variables.

Y

a single vector indicate the group

nc

the number of pls components (the one joint components + number of orthogonal components ).

scale

logical indicating whether X must be scaled (suggest TRUE).

center

logical indicating whether X must be centered (suggest TRUE).

cv

logical indicating whether cross-validation will be performed or not (suggest TRUE).

nr_folds

nr_folds Integer to indicate the folds for cross validation.

Value

a list containing the following elements:

  • nc the number of components used(one joint components + number of orthogonal components

  • scores a matrix of scores corresponding to the observations in X, The components retrieved correspond to the ones optimized or specified.

  • Xloadings a matrix of loadings corresponding to the explanatory variables. The components retrieved correspond to the ones optimized or specified.

  • vip the VIP matrix.

  • xvar variance explained of X by each single component.

  • R2Y variance explained of Y by each single component.

  • PRESS The residual sum of squares for the samples which were not used to fit the model

  • Q2 quality of cross-validation

Author(s)

Kai Guo

Examples

X <- matrix(rnorm(500),10,50)
Y <- rep(c("a","b"),each=5)
fit <- plsda(X,Y,2)

Print the summary of O2PLS results.

Description

Print the summary of O2PLS results.

Usage

## S3 method for class 'O2pls'
print(x, ...)

Arguments

x

An O2pls object

...

For consistency

Author(s)

Kai Guo

Examples

X <- matrix(rnorm(50),10,5)
Y <- matrix(rnorm(50),10,5)
object <- o2pls(X,Y,1,1,1)
print(object)

Print the summary of plsda results.

Description

Print the summary of plsda results.

Usage

## S3 method for class 'plsda'
print(x, ...)

Arguments

x

An plsda object

...

For consistency

Author(s)

Kai Guo

Examples

X <- matrix(rnorm(500),10,50)
Y <- rep(c("a","b"),each=5)
fit <- plsda(X,Y,2)
print(fit)

Extract the scores from an O2PLS fit

Description

This function extracts score matrices from an O2PLS fit

Usage

scores(x, ...)

Arguments

x

Object of class O2pls

...

For consistency

Value

Scores matrix


Extract the scores from an O2PLS fit

Description

This function extracts scores parameters from an O2PLS fit

Usage

## S3 method for class 'O2pls'
scores(x, score = c("Xjoint", "Yjoint", "Xorth", "Yorth"), ...)

Arguments

x

Object of class O2pls

score

the scores matrix for one of "Xjoint", "Yjoint", "Xorth", "Yorth"

...

Other arguments

Value

score matrix


Extract the scores from an O2PLS DA analysis

Description

Extract the scores from an O2PLS DA analysis

Usage

## S3 method for class 'o2plsda'
scores(x, ...)

Arguments

x

Object of class o2plsda

...

Other arguments

Value

score matrix

Author(s)

Kai Guo


Extract the scores PLSDA analysis

Description

Extract the scores PLSDA analysis

Usage

## S3 method for class 'plsda'
scores(x, ...)

Arguments

x

Object of class plsda

...

Other arguments

Value

score matrix

Author(s)

Kai Guo


Summary of an O2PLS object

Description

Summary of an O2PLS object

Usage

## S3 method for class 'O2pls'
summary(object, ...)

Arguments

object

a O2pls object

...

For consistency

Value

Detail of O2PLS results

Author(s)

Kai Guo

Examples

X <- matrix(rnorm(50),10,5)
Y <- matrix(rnorm(50),10,5)
object <- o2pls(X,Y,1,1,1)
summary(object)

Summary of an plsda object

Description

Summary of an plsda object

Usage

## S3 method for class 'plsda'
summary(object, ...)

Arguments

object

a plsda object

...

For consistency

Value

Detail of plsda results

Author(s)

Kai Guo

Examples

X <- matrix(rnorm(500),10,50)
Y <- rep(c("a","b"),each=5)
fit <- plsda(X,Y,2)
summary(fit)

Extract the VIP values from the O2PLS-DA object

Description

Extract the VIP values from the O2PLS-DA object

Usage

vip(x)

Arguments

x

the o2plsda object or plsda object

Value

a data frame