From 68acc77275fc316a432a5151d5e8454c3740d672 Mon Sep 17 00:00:00 2001 From: david-hirst Date: Fri, 1 Aug 2025 15:22:08 +1000 Subject: [PATCH 1/6] changes to mint.block.pls function --- R/mint.block.pls.R | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/R/mint.block.pls.R b/R/mint.block.pls.R index 0ca48409..760d8bfe 100644 --- a/R/mint.block.pls.R +++ b/R/mint.block.pls.R @@ -40,8 +40,9 @@ #' @return \code{mint.block.pls} returns an object of class \code{"mint.pls", #' "block.pls"}, a list that contains the following components: #' -#' \item{X}{the centered and standardized original predictor matrix.} +#' \item{X}{the centered and standardized original predictor and response matrices.} #' \item{Y}{the centered and standardized original response vector or matrix.} +#' \item{indY}{the position of the outcome Y in the output list X.} #' \item{ncomp}{the number of components included in the model for each block.} #' \item{mode}{the algorithm used to fit the model.} \item{mat.c}{matrix of #' coefficients from the regression of X / residual matrices X on the @@ -128,11 +129,15 @@ mint.block.pls <- function(X, DA = FALSE ) + # calculate weights for each dataset + weights = get.weights(result$variates, indY = result$indY) + # choose the desired output from 'result' out=list( call = match.call(), X = result$A, - Y = result$A[[1]], + Y = result$A[[result$indY]], + indY = result$indY, ncomp = result$ncomp, mode = result$mode, study = result$study, @@ -146,9 +151,10 @@ mint.block.pls <- function(X, iter = result$iter, max.iter = result$max.iter, nzv = result$nzv, - scale = result$scale) + scale = result$scale, + weights = weights) - class(out) = c("mint.block.pls","block.pls","sgcca") + class(out) = c("mint.block.pls","mint.pls","block.pls","sgcca") return(invisible(out)) } From 9f52a1041dc5a9336f20c6f349f83d4733eb6b58 Mon Sep 17 00:00:00 2001 From: david-hirst Date: Fri, 1 Aug 2025 17:11:43 +1000 Subject: [PATCH 2/6] changes to mint.block.spls function --- R/mint.block.spls.R | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/R/mint.block.spls.R b/R/mint.block.spls.R index f33c8d52..508447a9 100644 --- a/R/mint.block.spls.R +++ b/R/mint.block.spls.R @@ -32,8 +32,9 @@ #' @return \code{mint.block.spls} returns an object of class \code{"mint.spls", #' "block.spls"}, a list that contains the following components: #' -#' \item{X}{the centered and standardized original predictor matrix.} +#' \item{X}{the centered and standardized original predictor and response matrices.} #' \item{Y}{the centered and standardized original response vector or matrix.} +#' \item{indY}{the position of the outcome Y in the output list X.} #' \item{ncomp}{the number of components included in the model for each block.} #' \item{mode}{the algorithm used to fit the model.} \item{mat.c}{matrix of #' coefficients from the regression of X / residual matrices X on the @@ -124,16 +125,22 @@ mint.block.spls <- function(X, DA = FALSE ) + # calculate weights for each dataset + weights = get.weights(result$variates, indY = result$indY) + # choose the desired output from 'result' out = list( call = match.call(), X = result$A, - Y = result$A[[1]], + Y = result$A[[result$indY]], + indY = result$indY, ncomp = result$ncomp, mode = result$mode, study = result$study, - keepX = result$keepA[-result$indY], - keepY = result$keepA[result$indY][[1]], + # keepX = result$keepA[-result$indY], + # keepY = result$keepA[result$indY][[1]], + keepX = lapply(result$keepA, function(x){x[,-result$indY]}), + keepY = lapply(result$keepA, function(x){x[,result$indY]}), variates = result$variates, loadings = result$loadings, variates.partial = result$variates.partial, @@ -144,10 +151,11 @@ mint.block.spls <- function(X, iter = result$iter, max.iter = result$max.iter, nzv = result$nzv, - scale = result$scale + scale = result$scale, + weights = weights ) - class(out) = c("mint.block.spls","block.spls","sgcca") + class(out) = c("mint.block.spls","mint.spls","block.spls","sgcca") return(invisible(out)) } From 1f1ca475833d79592d54c7197b1df6cff4834bf0 Mon Sep 17 00:00:00 2001 From: david-hirst Date: Thu, 7 Aug 2025 10:18:08 +1000 Subject: [PATCH 3/6] Treatment of mint block objects by the predict function --- R/mint.block.pls.R | 6 +++--- R/mint.block.spls.R | 6 +++--- R/predict.R | 3 ++- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/R/mint.block.pls.R b/R/mint.block.pls.R index 760d8bfe..df9a7236 100644 --- a/R/mint.block.pls.R +++ b/R/mint.block.pls.R @@ -41,7 +41,7 @@ #' "block.pls"}, a list that contains the following components: #' #' \item{X}{the centered and standardized original predictor and response matrices.} -#' \item{Y}{the centered and standardized original response vector or matrix.} +# \item{Y}{the centered and standardized original response vector or matrix.} #' \item{indY}{the position of the outcome Y in the output list X.} #' \item{ncomp}{the number of components included in the model for each block.} #' \item{mode}{the algorithm used to fit the model.} \item{mat.c}{matrix of @@ -136,7 +136,7 @@ mint.block.pls <- function(X, out=list( call = match.call(), X = result$A, - Y = result$A[[result$indY]], + # Y = result$A[[result$indY]], indY = result$indY, ncomp = result$ncomp, mode = result$mode, @@ -154,7 +154,7 @@ mint.block.pls <- function(X, scale = result$scale, weights = weights) - class(out) = c("mint.block.pls","mint.pls","block.pls","sgcca") + class(out) = c("mint.block.pls","block.pls","sgcca") return(invisible(out)) } diff --git a/R/mint.block.spls.R b/R/mint.block.spls.R index 508447a9..bbfce7eb 100644 --- a/R/mint.block.spls.R +++ b/R/mint.block.spls.R @@ -33,7 +33,7 @@ #' "block.spls"}, a list that contains the following components: #' #' \item{X}{the centered and standardized original predictor and response matrices.} -#' \item{Y}{the centered and standardized original response vector or matrix.} +# \item{Y}{the centered and standardized original response vector or matrix.} #' \item{indY}{the position of the outcome Y in the output list X.} #' \item{ncomp}{the number of components included in the model for each block.} #' \item{mode}{the algorithm used to fit the model.} \item{mat.c}{matrix of @@ -132,7 +132,7 @@ mint.block.spls <- function(X, out = list( call = match.call(), X = result$A, - Y = result$A[[result$indY]], + # Y = result$A[[result$indY]], indY = result$indY, ncomp = result$ncomp, mode = result$mode, @@ -155,7 +155,7 @@ mint.block.spls <- function(X, weights = weights ) - class(out) = c("mint.block.spls","mint.spls","block.spls","sgcca") + class(out) = c("mint.block.spls","block.spls","sgcca") return(invisible(out)) } diff --git a/R/predict.R b/R/predict.R index 10bf3097..4739c179 100644 --- a/R/predict.R +++ b/R/predict.R @@ -221,7 +221,7 @@ predict.mixo_pls <- multilevel = NULL } - mint.object = c("mint.pls", "mint.spls", "mint.plsda", "mint.splsda") + mint.object = c("mint.block.spls", "mint.block.pls", "mint.pls", "mint.spls", "mint.plsda", "mint.splsda") block.object = c("block.pls", "block.spls", "block.plsda", "block.splsda") ### if the object is a block, the input newdata is different, we check newdata, make sure it's a list and check newdata/X if(!inherits(object, block.object)) # not a block (pls/spls/plsda/splsda/mint...) @@ -510,6 +510,7 @@ predict.mixo_pls <- means.Y=matrix(0,nrow=nrow(concat.newdata[[1]]),ncol=q) sigma.Y=matrix(1,nrow=nrow(concat.newdata[[1]]),ncol=q) + # NOTE: Could use same values as for non mint here to use training data to estimate values for new studies #loop on the blocks to define means.Y and sigma.Y for mint analysis for(m in 1:M) From db6ab30ec5d2ec319db330cac8ba503b2e130c55 Mon Sep 17 00:00:00 2001 From: david-hirst Date: Wed, 1 Oct 2025 16:51:25 +1000 Subject: [PATCH 4/6] Fix keepX and keepY values returned for mint.block.splsda --- R/mint.block.splsda.R | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/R/mint.block.splsda.R b/R/mint.block.splsda.R index 7b3a569a..9f51cdf7 100644 --- a/R/mint.block.splsda.R +++ b/R/mint.block.splsda.R @@ -186,8 +186,10 @@ mint.block.splsda <- function(X, ncomp = result$ncomp, mode = result$mode, study = result$study, - keepX = result$keepA[-result$indY], - keepY = result$keepA[result$indY][[1]], + # keepX = result$keepA[-result$indY], + # keepY = result$keepA[result$indY][[1]], + keepX = lapply(result$keepA, function(x){x[,-result$indY]}), + keepY = lapply(result$keepA, function(x){x[,result$indY]}), variates = result$variates, loadings = result$loadings, variates.partial = result$variates.partial, From f2814c18b3297053d18108c2de8978bd7a071624 Mon Sep 17 00:00:00 2001 From: david-hirst Date: Fri, 28 Nov 2025 09:53:00 +1100 Subject: [PATCH 5/6] add in block.(s)plsda to class list --- R/mint.block.plsda.R | 2 +- R/mint.block.splsda.R | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/mint.block.plsda.R b/R/mint.block.plsda.R index f4cb3676..b13e06a0 100644 --- a/R/mint.block.plsda.R +++ b/R/mint.block.plsda.R @@ -225,7 +225,7 @@ mint.block.plsda <- function(X, nzv = result$nzv, scale = result$scale) - class(out) = c("mint.block.plsda","mint.block.pls","block.pls","sgccda","sgcca","DA") + class(out) = c("mint.block.plsda","mint.block.pls","block.plsda","block.pls","sgccda","sgcca","DA") return(invisible(out)) } diff --git a/R/mint.block.splsda.R b/R/mint.block.splsda.R index 9f51cdf7..65a8500e 100644 --- a/R/mint.block.splsda.R +++ b/R/mint.block.splsda.R @@ -203,7 +203,7 @@ mint.block.splsda <- function(X, scale = result$scale ) - class(out) = c("mint.block.splsda","mint.block.spls","block.spls","sgccda","sgcca","DA") + class(out) = c("mint.block.splsda","mint.block.spls","block.splsda","block.spls","sgccda","sgcca","DA") return(invisible(out)) } From 97c8cacf8c16e9ca03cf05b50bb5cab6c83016ab Mon Sep 17 00:00:00 2001 From: david-hirst Date: Thu, 12 Feb 2026 13:59:19 +1100 Subject: [PATCH 6/6] return design matrix with mint block (s)pls model fits --- R/mint.block.pls.R | 1 + R/mint.block.spls.R | 1 + 2 files changed, 2 insertions(+) diff --git a/R/mint.block.pls.R b/R/mint.block.pls.R index df9a7236..565a86c9 100644 --- a/R/mint.block.pls.R +++ b/R/mint.block.pls.R @@ -139,6 +139,7 @@ mint.block.pls <- function(X, # Y = result$A[[result$indY]], indY = result$indY, ncomp = result$ncomp, + design = result$design, mode = result$mode, study = result$study, variates = result$variates, diff --git a/R/mint.block.spls.R b/R/mint.block.spls.R index bbfce7eb..529f980b 100644 --- a/R/mint.block.spls.R +++ b/R/mint.block.spls.R @@ -141,6 +141,7 @@ mint.block.spls <- function(X, # keepY = result$keepA[result$indY][[1]], keepX = lapply(result$keepA, function(x){x[,-result$indY]}), keepY = lapply(result$keepA, function(x){x[,result$indY]}), + design = result$design, variates = result$variates, loadings = result$loadings, variates.partial = result$variates.partial,