% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ComDim_OPLS.R
\name{ComDim_OPLS}
\alias{ComDim_OPLS}
\title{ComDim_OPLS}
\usage{
ComDim_OPLS(
  MB = MB,
  y = y,
  ndim = 1,
  nort = 1,
  method = c("OPLS-DA", "OPLS-R"),
  decisionRule = c("fixed", "max")[2],
  normalise = FALSE,
  loquace = FALSE,
  cv.k = 7
)
}
\arguments{
\item{MB}{A MultiBlock object.}

\item{y}{The Y-block. A class vector or dummy matrix for OPLS-DA, or a
numeric matrix/vector for OPLS-R.}

\item{ndim}{Number of predictive Common Dimensions. Default is 1.}

\item{nort}{Maximum number of orthogonal Common Dimensions. Default is 1.
The actual number used is determined by ConsensusOPLS cross-validation and
may be less than this value.}

\item{method}{'OPLS-DA' for discriminant analysis or 'OPLS-R' for regression.}

\item{decisionRule}{Only used if method is 'OPLS-DA'. If 'fixed', samples are
assigned to the class with Y-hat above 1/nclasses. If 'max', samples are
assigned to the class with the highest Y-hat.}

\item{normalise}{To apply block normalisation. FALSE == no (default), TRUE == yes.}

\item{loquace}{To display the calculation times. TRUE == yes, FALSE == no (default).}

\item{cv.k}{Number of folds for k-fold cross-validation (default 7). Set
to 0 to skip CV output. ConsensusOPLS always performs internal CV to select
the optimal number of orthogonal components; when \code{cv.k >= 2} the
resulting \code{Q2} and \code{DQ2} reflect that cross-validation.}
}
\value{
A \code{ComDim} object.  All slots are populated.  Key slots:
\describe{
  \item{\code{Method}}{\code{"OPLS-DA"} or \code{"OPLS-R"}.}
  \item{\code{ndim}}{Number of predictive Common Dimensions.}
  \item{\code{Q.scores}}{Predictive global scores matrix (\eqn{n \times ndim}).}
  \item{\code{T.scores}}{Named list of block-specific predictive local scores.}
  \item{\code{P.loadings}}{Global predictive loadings.}
  \item{\code{Saliences}}{Predictive block salience matrix (\eqn{ntable \times ndim}).}
  \item{\code{Orthogonal}}{List with orthogonal component outputs: \code{nort},
    \code{Q.scores}, \code{T.scores}, \code{P.loadings.ort}, \code{Saliences.ort}.}
  \item{\code{R2X}}{Named vector (length \eqn{ndim + nort}) of X-variance fractions.}
  \item{\code{R2Y}}{Named vector (length \eqn{ndim + nort}) of Y-variance fractions.}
  \item{\code{Q2}}{Cross-validated Q2 per class/response (when \code{cv.k >= 2};
    otherwise training-set fit).}
  \item{\code{DQ2}}{(OPLS-DA only) Cross-validated discriminant Q2 per class.}
  \item{\code{VIP}}{Global total VIP (named vector, length \eqn{p_{tot}}).}
  \item{\code{VIP.block}}{Named list (one data.frame per block) with columns
    \code{p}, \code{o}, \code{tot}.}
  \item{\code{PLS.model}}{KOPLS regression objects: \code{W}, \code{B}, \code{B0}, \code{Y}.}
  \item{\code{cv}}{Cross-validation results when \code{cv.k >= 2}: \code{k},
    \code{Ypred}, \code{Q2}, \code{DQ2}.}
  \item{\code{Prediction}}{Training-set predictions: \code{Y.pred}; for OPLS-DA
    also \code{decisionRule}, \code{trueClass}, \code{predClass},
    \code{Sensitivity}, \code{Specificity}, \code{confusionMatrix}.}
  \item{\code{Mean}}{List with \code{MeanMB} and \code{MeanY}.}
  \item{\code{Norm}}{List with \code{NormMB}, \code{FrobNorms}, \code{RVweights}.}
  \item{\code{variable.block}}{Block membership of each variable.}
  \item{\code{runtime}}{Total computation time in seconds.}
}
}
\description{
Finding common dimensions in multi-block datasets using OPLS. Also known as ConsensusOPLS
(ComDim-OPLS) for multiblock structures: orthogonal components uncorrelated
with Y are extracted from all blocks simultaneously before the predictive
components are computed.
}
\details{
This function is a wrapper around \code{\link[ConsensusOPLS]{ConsensusOPLS}}.
The core kernel-OPLS extraction is delegated to that package; all ComDim
output slots (local scores, loadings, VIP, sensitivity, confusion matrix,
etc.) are computed from the returned model objects.
}
\examples{
b1 <- matrix(rnorm(500), 10, 50)
b2 <- matrix(rnorm(800), 10, 80)
mb <- MultiBlock(Data = list(b1 = b1, b2 = b2))
y <- rep(c("A", "B"), 5)
results <- ComDim_OPLS(mb, y, ndim = 1, nort = 1, method = "OPLS-DA")
}
\references{
Boccard J, Rutledge DN (2013).
  A consensus OPLS-DA strategy for multiblock Omics data fusion.
  \emph{Analytica Chimica Acta}, 769, 30--39.
  \doi{10.1016/j.aca.2013.01.022}
}
