The CMTFtoolbox
package provides R users with two data
fusion methods that have previously been presented in the MATLAB
sphere.
cmtf_opt
: Coupled Matrix and Tensor Factorization
(CMTF) (doi:10.48550/arXiv.1105.3422).acmtf_opt
: Advanced Coupled Matrix and Tensor
Factorization (ACMTF) (doi:10.1186/1471-2105-15-239).acmtfr_opt
: ACMTF-regression (ACMTF-R) as described in
van der Ploeg et al., 2025 (see citation below).Both of these methods were implemented using the all-at-once
optimization approaches as described in the papers above. This
implementation was achieved using the S4 Tensor object from
rTensor
and the various conjugate gradient approaches from
mize
. Other features of the package include:
ACMTF_modelSelection
: Combined random initialization
and cross-validation approach for determining the correct number of
components in ACMTF.ACMTFR_modelSelection
: Combined random initialization
and cross-validation approach for determining the correct number of
components in ACMTF-R.npred
: Prediction of Y for a new sample using an
existing ACMTF-R model.Georgiou2025
: An example dataset containing a tensor of
inflammatory mediator data and a matrix of tooth microbiome data in a
cohort of apical periodontitis patients (doi:10.1111/iej.13854 and doi:10.1111/iej.13912).The CMTFtoolbox
package can be installed from CRAN
using:
install.packages("CMTFtoolbox")
You can install the development version of CMTFtoolbox
from GitHub with:
# install.packages("devtools")
::install_github("GRvanderPloeg/CMTFtoolbox") devtools
Please use the following citation when using this package:
library(CMTFtoolbox)
set.seed(123)
= 3
numComponents = 108
I = 100
J = 10
K = 100
L = array(rnorm(I*numComponents), c(I, numComponents)) # shared subject mode
A = array(rnorm(J*numComponents), c(J, numComponents)) # distinct feature mode of X1
B = array(rnorm(K*numComponents), c(K, numComponents)) # distinct condition mode of X1
C = array(rnorm(L*numComponents), c(L, numComponents)) # distinct feature mode of X2
D = matrix(A[,1])
Y = array(c(1, 1, 1, 0, 0, 1), c(2,3))
lambdas
= array(0L, c(I, J, K))
df1 = array(0L, c(I, L))
df2 for(i in 1:numComponents){
= df1 + lambdas[1,i] * reinflateTensor(A[,i], B[,i], C[,i])
df1 = df2 + lambdas[2,i] * reinflateMatrix(A[,i], D[,i])
df2
}= list(df1, df2)
datasets = list(c(1,2,3), c(1,4))
modes = setupCMTFdata(datasets, modes, normalize=TRUE)
Z
= cmtf_opt(Z, 3)
cmtf_model = acmtf_opt(Z, 3)
acmtf_model = acmtfr_opt(Z, Y, 3) acmtfr_model