| Type: | Package | 
| Title: | Multiomics Data Integration | 
| Version: | 0.0.25 | 
| 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. | 
| License: | GPL-3 | 
| Imports: | Rcpp (≥ 1.0.7), dplyr, magrittr, parallel, ggplot2, ggrepel, methods, stats | 
| Encoding: | UTF-8 | 
| Suggests: | knitr, markdown, rmarkdown | 
| VignetteBuilder: | knitr | 
| LinkingTo: | Rcpp, RcppArmadillo | 
| RoxygenNote: | 7.3.1 | 
| NeedsCompilation: | yes | 
| Repository: | CRAN | 
| Packaged: | 2024-07-18 20:02:16 UTC; bioguo | 
| Author: | Kai Guo [aut, cre], Junguk Hur [aut], Eva Feldman [aut] | 
| Maintainer: | Kai Guo <guokai8@gmail.com> | 
| Date/Publication: | 2024-07-18 22:40:02 UTC | 
do cross-validation with group factors
Description
do cross-validation with group factors
Usage
.o2cv(X, Y, n, nx, ny, group, nr)
Arguments
| X | a Numeric matrix (input) | 
| Y | a Numeric matrix (input) | 
| n | 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 | Integer to indicate the folds for cross validation | 
Value
a list of o2pls results
Author(s)
Kai Guo
Partial least squares discriminant analysis
Description
Perform a PLS discriminant analysis
Usage
.pls(X, Y, nc, 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 . | 
| 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. @return list with PLS results | 
trans matrix * matrix
Description
trans matrix * matrix
Usage
AtA(A)
Value
A matrix
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
calcualte the Q value
Description
calcualte the Q value
Usage
Q(y, y_hat)
Value
a numeric
get the sd for a matrix
Description
get the sd for a matrix
Usage
colsds(X)
Value
standard deviation of the matrix
get the total values for a matrix
Description
get the total values for a matrix
Usage
column_sums(X)
Value
sum value of the column
two matrix mutiplication
Description
two matrix mutiplication
Usage
eigenmult(A, B)
Value
A matrix
three matrix mutiplication
Description
three matrix mutiplication
Usage
eigenthree(A, B, C)
Value
A matrix
MCCV sampling
Description
MCCV sampling
Usage
getMCCV_cpp(x, n)
Value
a vector with random sampling based on group-balanced Monte Carlo cross-validation
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  | 
| ... | 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  | 
| 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  | 
| ... | 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  | 
| Xloading | Joint  | 
| Yscore | Joint  | 
| Yloading | Joint  | 
| TYosc | Orthogonal  | 
| PYosc | Orthogonal  | 
| WYosc | Orthogonal  | 
| UXosc | Orthogonal  | 
| PXosc | Orthogonal  | 
| CXosc | Orthogonal  | 
| BU | Regression coefficient in  | 
| BT | Regression coefficient in  | 
| Xhat | Prediction of  | 
| Yhat | Prediction of  | 
| R2Xhat | Variation of the predicted  | 
| R2Yhat | Variation of the predicted  | 
| R2X | Variation of the modeled part in  | 
| R2Y | Variation of the modeled part in  | 
| R2Xcorr | Variation of the joint part in  | 
| R2Ycorr | Variation of the joint part in  | 
| R2Xo | Variation of the orthogonal part in  | 
| R2Yo | Variation of the orthogonal part in  | 
| R2Xp | Variation in  | 
| R2Yp | Variation in  | 
| varXj | Variation in each Latent Variable (LV) in  | 
| varYj | Variation in each Latent Variable (LV) in  | 
| varXorth | Variation in each Latent Variable (LV) in  | 
| varYorth | Variation in each Latent Variable (LV) in  | 
| Exy | Residuals in  | 
| Fxy | Residuals in  | 
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)
orthogonal scores algorithn of partial leat squares (opls) projection
Description
orthogonal scores algorithn of partial leat squares (opls) projection
Usage
opls(X, Y, ncomp, maxiter, tol)
Value
a list of opls result
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  | 
| 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:
- ncthe number of components used(one joint components + number of orthogonal components
- scoresa matrix of scores corresponding to the observations in- X, The components retrieved correspond to the ones optimized or specified.
- Xloadingsa matrix of loadings corresponding to the explanatory variables. The components retrieved correspond to the ones optimized or specified.
- Yloadingsa matrix of partial least squares loadings corresponding to- Y
- vipthe VIP matrix.
- xvara 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_matrixthe matrix of projection matrix
- weighta 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)
order a vector
Description
order a vector
Usage
order_cpp(x)
Value
a integer vector
order a vector of sting
Description
order a vector of sting
Usage
order_str(x)
Value
An character vector
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  | 
| center | logical indicating whether  | 
| 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:
- ncthe number of components used(one joint components + number of orthogonal components
- scoresa matrix of scores corresponding to the observations in- X, The components retrieved correspond to the ones optimized or specified.
- Xloadingsa matrix of loadings corresponding to the explanatory variables. The components retrieved correspond to the ones optimized or specified.
- vipthe VIP matrix.
- xvarvariance explained of X by each single component.
- R2Yvariance explained of Y by each single component.
- PRESSThe residual sum of squares for the samples which were not used to fit the model
- Q2quality 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)
calculate RMSE
Description
calculate RMSE
Usage
rcpp_rmse(y, y_hat)
Value
root-mean-square error value
sum square of a matrix
Description
sum square of a matrix
Usage
s2(x)
Value
sum square value of the vector
sampling a vector
Description
sampling a vector
Usage
sample_cpp(x, n)
Value
a vector of length ‘size’ with element drawn from ‘x’
lapply sampling
Description
lapply sampling
Usage
sample_lapply(X, n)
Value
a list
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  | 
| ... | 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  | 
| 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  | 
| ... | 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  | 
| ... | Other arguments | 
Value
score matrix
Author(s)
Kai Guo
sort string
Description
sort string
Usage
sort_str(strings)
Value
A vector of string
split a vector
Description
split a vector
Usage
split_str(x)
Value
a list of vectors containing the values for the groups
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)
unlist a list
Description
unlist a list
Usage
unlist_cpp(list)
Value
a vector of an appropriate mode to hold the list components.
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