Skip to content

Commit

Permalink
Enhancement for Issue #34
Browse files Browse the repository at this point in the history
  • Loading branch information
Max-Bladen committed Aug 9, 2022
1 parent 0ff2d16 commit 332e45f
Show file tree
Hide file tree
Showing 34 changed files with 332 additions and 43 deletions.
16 changes: 14 additions & 2 deletions R/block.pls.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
#' \code{'horst'}, see reference.
#' @param init Mode of initialization use in the algorithm, either by Singular
#' Value Decomposition of the product of each block of X with Y ('svd') or each
#' block independently ('svd.single'). Default = \code{svd.single}.
#' block independently ('svd.single'). Default = \code{svd.single}
#' @template arg/verbose.call
#' @return \code{block.pls} returns an object of class \code{'block.pls'}, a
#' list that contains the following components:
#'
Expand All @@ -69,6 +70,9 @@
#' iterations of the algorithm for each component}
#' \item{prop_expl_var}{Percentage of explained variance for each
#' component and each block}
#' \item{call}{if \code{verbose.call = FALSE}, then just the function call is returned.
#' If \code{verbose.call = TRUE} then all the inputted values are accessable via
#' this component}
#' @author Florian Rohart, Benoit Gautier, Kim-Anh Lê Cao, Al J Abadi
#' @seealso \code{\link{plotIndiv}}, \code{\link{plotArrow}},
#' \code{\link{plotLoadings}}, \code{\link{plotVar}}, \code{\link{predict}},
Expand Down Expand Up @@ -98,7 +102,8 @@ block.pls <- function(X,
tol = 1e-06,
max.iter = 100,
near.zero.var = FALSE,
all.outputs = TRUE)
all.outputs = TRUE,
verbose.call = FALSE)
{

# call to 'internal_wrapper.mint.block'
Expand Down Expand Up @@ -132,6 +137,13 @@ block.pls <- function(X,
weights = weights,
prop_expl_var = result$prop_expl_var)

if (verbose.call) {
c <- out$call
out$call <- mget(names(formals()))
out$call <- append(c, out$call)
names(out$call)[1] <- "simple.call"
}

# give a class
class(out) = c("block.pls","sgcca")

Expand Down
13 changes: 12 additions & 1 deletion R/block.plsda.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
#' iterations of the algorithm for each component}
#' \item{prop_expl_var}{Percentage of explained variance for each
#' component and each block}
#' \item{call}{if \code{verbose.call = FALSE}, then just the function call is returned.
#' If \code{verbose.call = TRUE} then all the inputted values are accessable via
#' this component}
#' @author Florian Rohart, Benoit Gautier, Kim-Anh Lê Cao, Al J Abadi
#' @seealso \code{\link{plotIndiv}}, \code{\link{plotArrow}},
#' \code{\link{plotLoadings}}, \code{\link{plotVar}}, \code{\link{predict}},
Expand Down Expand Up @@ -98,7 +101,8 @@ block.plsda <- function(X,
tol = 1e-06,
max.iter = 100,
near.zero.var = FALSE,
all.outputs = TRUE)
all.outputs = TRUE,
verbose.call = FALSE)

{
# check inpuy 'Y' and transformation in a dummy matrix
Expand Down Expand Up @@ -186,6 +190,13 @@ block.plsda <- function(X,
prop_expl_var = result$prop_expl_var
)#[-result$indY])

if (verbose.call) {
c <- out$call
out$call <- mget(names(formals()))
out$call <- append(c, out$call)
names(out$call)[1] <- "simple.call"
}

# give a class
class(out) = c("block.plsda", "block.pls", "sgccda", "sgcca", "DA")
return(invisible(out))
Expand Down
14 changes: 13 additions & 1 deletion R/block.spls.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#' default all variables are kept in the model.
#' @param keepY Only if Y is provided (and not \code{indY}). Each entry is the number of variables to
#' select in each of the blocks of Y for each component.
#' @template arg/verbose.call
#' @return \code{block.spls} returns an object of class \code{"block.spls"}, a
#' list that contains the following components:
#'
Expand All @@ -66,6 +67,9 @@
#' of the algorithm for each component} \item{prop_expl_var}{Percentage of
#' explained variance for each component and each block after setting possible
#' missing values in the centered data to zero}
#' \item{call}{if \code{verbose.call = FALSE}, then just the function call is returned.
#' If \code{verbose.call = TRUE} then all the inputted values are accessable via
#' this component}
#' @author Florian Rohart, Benoit Gautier, Kim-Anh Lê Cao, Al J Abadi
#' @seealso \code{\link{plotIndiv}}, \code{\link{plotArrow}},
#' \code{\link{plotLoadings}}, \code{\link{plotVar}}, \code{\link{predict}},
Expand Down Expand Up @@ -101,7 +105,8 @@ block.spls = function(X,
tol = 1e-06,
max.iter = 100,
near.zero.var = FALSE,
all.outputs = TRUE)
all.outputs = TRUE,
verbose.call = FALSE)
{

# call to 'internal_wrapper.mint.block'
Expand Down Expand Up @@ -152,6 +157,13 @@ block.spls = function(X,
prop_expl_var = result$prop_expl_var
)

if (verbose.call) {
c <- out$call
out$call <- mget(names(formals()))
out$call <- append(c, out$call)
names(out$call)[1] <- "simple.call"
}

# give a class
class(out) = c("block.spls", "sgcca")
return(invisible(out))
Expand Down
14 changes: 13 additions & 1 deletion R/block.splsda.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#'
#' @inheritParams block.plsda
#' @inheritParams block.spls
#' @template arg/verbose.call
#' @return \code{block.splsda} returns an object of class \code{"block.splsda",
#' "block.spls"}, a list that contains the following components:
#'
Expand All @@ -52,6 +53,9 @@
#' between the variate of each block and the variate of the outcome. Used to
#' weight predictions.} \item{prop_expl_var}{Percentage of explained
#' variance for each component and each block}
#' \item{call}{if \code{verbose.call = FALSE}, then just the function call is returned.
#' If \code{verbose.call = TRUE} then all the inputted values are accessable via
#' this component}
#' @author Florian Rohart, Benoit Gautier, Kim-Anh Lê Cao, Al J Abadi
#' @seealso \code{\link{plotIndiv}}, \code{\link{plotArrow}},
#' \code{\link{plotLoadings}}, \code{\link{plotVar}}, \code{\link{predict}},
Expand Down Expand Up @@ -97,7 +101,8 @@ block.splsda <- function(X,
tol = 1e-06,
max.iter = 100,
near.zero.var = FALSE,
all.outputs = TRUE)
all.outputs = TRUE,
verbose.call = FALSE)
{
# check inpuy 'Y' and transformation in a dummy matrix
if (!missing(Y))
Expand Down Expand Up @@ -190,6 +195,13 @@ block.splsda <- function(X,
prop_expl_var = result$prop_expl_var
)#[-result$indY])

if (verbose.call) {
c <- out$call
out$call <- mget(names(formals()))
out$call <- append(c, out$call)
names(out$call)[1] <- "simple.call"
}

# give a class
class(out) = c("block.splsda", "block.spls", "sgccda", "sgcca", "DA")
return(invisible(out))
Expand Down
14 changes: 13 additions & 1 deletion R/mint.pca.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#' means and unit variances. Default = \code{TRUE}.
#' @param tol Convergence stopping value.
#' @param max.iter integer, the maximum number of iterations.
#' @template arg/verbose.call
#' @return \code{mint.pca} returns an object of class \code{"mint.pca", "pca"},
#' a list that contains the following components:
#'
Expand All @@ -51,6 +52,9 @@
#' spirit} \item{prop_expl_var}{Proportion of the explained variance from the multivariate
#' model after setting possible missing values to zero in the data.} \item{names}{list containing the names to be used
#' for individuals and variables.}
#' \item{call}{if \code{verbose.call = FALSE}, then just the function call is returned.
#' If \code{verbose.call = TRUE} then all the inputted values are accessable via
#' this component}
#' @author Florian Rohart, Kim-Anh Lê Cao, Al J Abadi
#' @seealso \code{\link{spls}}, \code{\link{summary}}, \code{\link{plotIndiv}},
#' \code{\link{plotVar}}, \code{\link{predict}}, \code{\link{perf}},
Expand Down Expand Up @@ -79,7 +83,8 @@ mint.pca <- function(X,
study,
scale = TRUE,
tol = 1e-06,
max.iter = 100)
max.iter = 100,
verbose.call = FALSE)
{

#-- checking general input parameters --------------------------------------#
Expand Down Expand Up @@ -177,6 +182,13 @@ mint.pca <- function(X,
# choose the desired output from 'result'
out$study <- study

if (verbose.call) {
c <- out$call
out$call <- mget(names(formals()))
out$call <- append(c, out$call)
names(out$call)[1] <- "simple.call"
}

class(out) <- c("mint.pca","pca")
return(invisible(out))

Expand Down
14 changes: 13 additions & 1 deletion R/mint.pls.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#' classification and factor response)
#' @param study Factor, indicating the membership of each sample to each of the
#' studies being combined
#' @template arg/verbose.call
#' @return \code{mint.pls} returns an object of class \code{"mint.pls", "pls"},
#' a list that contains the following components:
#'
Expand All @@ -59,6 +60,9 @@
#' explained variance for each component and each study (note that contrary to
#' PCA, this amount may not decrease as the aim of the method is not to
#' maximise the variance, but the covariance between data sets).}
#' \item{call}{if \code{verbose.call = FALSE}, then just the function call is returned.
#' If \code{verbose.call = TRUE} then all the inputted values are accessable via
#' this component}
#' @author Florian Rohart, Kim-Anh Lê Cao, Al J Abadi
#' @seealso \code{\link{spls}}, \code{\link{summary}}, \code{\link{plotIndiv}},
#' \code{\link{plotVar}}, \code{\link{predict}}, \code{\link{perf}},
Expand Down Expand Up @@ -101,7 +105,8 @@ mint.pls <- function(X,
tol = 1e-06,
max.iter = 100,
near.zero.var = FALSE,
all.outputs = TRUE)
all.outputs = TRUE,
verbose.call = FALSE)
{

# call to 'internal_wrapper.mint'
Expand Down Expand Up @@ -139,6 +144,13 @@ mint.pls <- function(X,
prop_expl_var = result$prop_expl_var
)

if (verbose.call) {
c <- out$call
out$call <- mget(names(formals()))
out$call <- append(c, out$call)
names(out$call)[1] <- "simple.call"
}

class(out) = c("mint.pls","mixo_pls")
return(invisible(out))

Expand Down
14 changes: 13 additions & 1 deletion R/mint.plsda.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#' @inheritParams mint.pls
#' @param Y A factor or a class vector indicating the discrete outcome of each
#' sample.
#' @template arg/verbose.call
#' @return \code{mint.plsda} returns an object of class \code{"mint.plsda",
#' "plsda"}, a list that contains the following components:
#'
Expand All @@ -55,6 +56,9 @@
#' (note that contrary to PCA, this amount may not decrease as the aim of the
#' method is not to maximise the variance, but the covariance between X and the
#' dummy matrix Y).}
#' \item{call}{if \code{verbose.call = FALSE}, then just the function call is returned.
#' If \code{verbose.call = TRUE} then all the inputted values are accessable via
#' this component}
#' @author Florian Rohart, Kim-Anh Lê Cao, Al J Abadi
#' @seealso \code{\link{spls}}, \code{\link{summary}}, \code{\link{plotIndiv}},
#' \code{\link{plotVar}}, \code{\link{predict}}, \code{\link{perf}},
Expand Down Expand Up @@ -100,7 +104,8 @@ mint.plsda <- function(X,
tol = 1e-06,
max.iter = 100,
near.zero.var = FALSE,
all.outputs = TRUE)
all.outputs = TRUE,
verbose.call = FALSE)
{
#-- validation des arguments --#
# most of the checks are done in 'internal_wrapper.mint'
Expand Down Expand Up @@ -169,6 +174,13 @@ mint.plsda <- function(X,
prop_expl_var = result$prop_expl_var
)

if (verbose.call) {
c <- out$call
out$call <- mget(names(formals()))
out$call <- append(c, out$call)
names(out$call)[1] <- "simple.call"
}

class(out) <- c("mint.plsda", "mixo_plsda", "mixo_pls", "DA")
return(invisible(out))

Expand Down
16 changes: 14 additions & 2 deletions R/mint.spls.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#' \code{X} on each component. By default all variables are kept in the model.
#' @param keepY numeric vector indicating the number of variables to select in
#' \code{Y} on each component. By default all variables are kept in the model.
#' @template arg/verbose.call
#' @return \code{mint.spls} returns an object of class
#' \code{"mint.spls","spls"}, a list that contains the following components:
#'
Expand All @@ -63,14 +64,17 @@
#' partial variates - partial loadings.} \item{names}{list containing the names
#' to be used for individuals and variables.} \item{nzv}{list containing the
#' zero- or near-zero predictors information.} \item{iter}{Number of iterations
#' of the algorithm for each component} #' \item{prop_expl_var}{The amount
#' of the algorithm for each component} \item{prop_expl_var}{The amount
#' of the variance explained by each variate / component divided by the total
#' variance in the \code{data} for each study (after removing the possible
#' missing values) using the definition of 'redundancy'. Note that contrary to
#' \code{PCA}, this amount may not decrease in the following components as the
#' aim of the method is not to maximise the variance, but the covariance between
#' data sets (including the dummy matrix representation of the outcome variable
#' in case of the supervised approaches).}
#' \item{call}{if \code{verbose.call = FALSE}, then just the function call is returned.
#' If \code{verbose.call = TRUE} then all the inputted values are accessable via
#' this component}
#' @author Florian Rohart, Kim-Anh Lê Cao, Al J Abadi
#' @seealso \code{\link{spls}}, \code{\link{summary}}, \code{\link{plotIndiv}},
#' \code{\link{plotVar}}, \code{\link{predict}}, \code{\link{perf}},
Expand Down Expand Up @@ -115,7 +119,8 @@ mint.spls <- function(X,
tol = 1e-06,
max.iter = 100,
near.zero.var = FALSE,
all.outputs = TRUE)
all.outputs = TRUE,
verbose.call = FALSE)
{

# call to 'internal_wrapper.mint'
Expand Down Expand Up @@ -157,6 +162,13 @@ mint.spls <- function(X,
prop_expl_var = result$prop_expl_var
)

if (verbose.call) {
c <- out$call
out$call <- mget(names(formals()))
out$call <- append(c, out$call)
names(out$call)[1] <- "simple.call"
}

class(out) <- c("mint.spls","mixo_spls")
return(invisible(out))

Expand Down
14 changes: 13 additions & 1 deletion R/mint.splsda.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#'
#' @inheritParams mint.plsda
#' @inheritParams mint.spls
#' @template arg/verbose.call
#' @return \code{mint.splsda} returns an object of class \code{"mint.splsda",
#' "splsda"}, a list that contains the following components:
#'
Expand All @@ -58,6 +59,9 @@
#' PCA, this amount may not decrease as the aim of the method is not to
#' maximise the variance, but the covariance between X and the dummy matrix
#' Y).}
#' \item{call}{if \code{verbose.call = FALSE}, then just the function call is returned.
#' If \code{verbose.call = TRUE} then all the inputted values are accessable via
#' this component}
#' @author Florian Rohart, Kim-Anh Lê Cao, Al J Abadi
#' @seealso \code{\link{spls}}, \code{\link{summary}}, \code{\link{plotIndiv}},
#' \code{\link{plotVar}}, \code{\link{predict}}, \code{\link{perf}},
Expand Down Expand Up @@ -106,7 +110,8 @@ mint.splsda <- function(X,
tol = 1e-06,
max.iter = 100,
near.zero.var = FALSE,
all.outputs = TRUE)
all.outputs = TRUE,
verbose.call = FALSE)
{

#-- validation des arguments --#
Expand Down Expand Up @@ -177,6 +182,13 @@ mint.splsda <- function(X,
prop_expl_var = result$prop_expl_var
)

if (verbose.call) {
c <- out$call
out$call <- mget(names(formals()))
out$call <- append(c, out$call)
names(out$call)[1] <- "simple.call"
}

class(out) <- c("mint.splsda", "mixo_splsda", "mixo_spls", "DA")
return(invisible(out))

Expand Down
Loading

0 comments on commit 332e45f

Please sign in to comment.