% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/run_mofa.R
\name{run_mofa}
\alias{run_mofa}
\title{Train a MOFA model}
\usage{
run_mofa(object, outfile = NULL, save_data = TRUE, use_basilisk = FALSE)
}
\arguments{
\item{object}{an untrained \code{\link{MOFA}} object}

\item{outfile}{output file for the model (.hdf5 format). If \code{NULL}, a temporary file is created.}

\item{save_data}{logical indicating whether to save the training data in the hdf5 file. 
This is useful for some downstream analysis (mainly functions with the prefix \code{plot_data}), but it can take a lot of disk space.}

\item{use_basilisk}{use \code{basilisk} to automatically provision a Python environment with mofapy2 and all dependencies. 
If \code{FALSE} (default), python will be used directly via \code{reticulate} - this needs to be set up beforehand, e.g. with \code{\link[reticulate]{py_require}} or \code{\link[reticulate]{use_python}}.}
}
\value{
a trained \code{\link{MOFA}} object
}
\description{
Function to train an untrained \code{\link{MOFA}} object.
}
\details{
This function is called once a MOFA object has been prepared (using \code{\link{prepare_mofa}})
In this step the R package calls the \code{mofapy2} Python package, where model training is performed. \cr

The interface with Python is done with the \code{\link{reticulate}} package. 
Setting \code{use_basilisk = TRUE} needs no Python setup: \code{basilisk} provisions a dedicated environment
on first use, pinned to the \code{mofapy2} version MOFA2 targets.
Otherwise mofapy2 is taken from whichever Python you point reticulate at, either by declaring it with \code{\link[reticulate]{py_require}}
(e.g. \code{reticulate::py_require("mofapy2==0.7.5", python_version = "3.12")}) or by selecting an existing installation with \code{\link[reticulate]{use_python}}.
See the \href{https://biofam.github.io/MOFA2/installation.html#notes-on-the-connection-of-r-to-python}{installation notes} for more details.
}
\examples{
# Load data (in data.frame format)
file <- system.file("extdata", "test_data.RData", package = "MOFA2")
load(file) 

# Create the MOFA object
MOFAmodel <- create_mofa(dt)

# Prepare the MOFA object with default options
MOFAmodel <- prepare_mofa(MOFAmodel)

# A. Run the MOFA model using basilisk
\dontrun{
MOFAmodel <- run_mofa(MOFAmodel, use_basilisk = TRUE)}

# B. Run the MOFA model via reticulate
\dontrun{ 
reticulate::py_require("mofapy2==0.7.5", python_version = "3.12")
MOFAmodel <- run_mofa(MOFAmodel)}
}
