run_umap: Run UMAP on the MOFA factors

View source: R/dimensionality_reduction.R

run_umapR Documentation

Run UMAP on the MOFA factors

Description

Run UMAP on the MOFA factors

Usage

run_umap(
  object,
  factors = "all",
  groups = "all",
  n_neighbors = 30,
  min_dist = 0.3,
  metric = "cosine",
  ...
)

Arguments

object

a trained MOFA object.

factors

character vector with the factor names, or numeric vector with the indices of the factors to use, or "all" to use all factors (default).

groups

character vector with the groups names, or numeric vector with the indices of the groups of samples to use, or "all" to use all groups (default).

n_neighbors

number of neighboring points used in local approximations of manifold structure. Larger values will result in more global structure being preserved at the loss of detailed local structure. In general this parameter should often be in the range 5 to 50.

min_dist

This controls how tightly the embedding is allowed compress points together. Larger values ensure embedded points are moreevenly distributed, while smaller values allow the algorithm to optimise more accurately with regard to local structure. Sensible values are in the range 0.01 to 0.5

metric

choice of metric used to measure distance in the input space

...

arguments passed to umap

Details

This function calls umap to calculate a UMAP representation from the MOFA factors For details on the hyperparameters of UMAP see the documentation of umap. Subsequently, you can plot the UMAP representation with plot_dimred or fetch the coordinates using plot_dimred(..., method="UMAP", return_data=TRUE). Remember to use set.seed before the function call to get reproducible results.

Value

Returns a MOFA object with the MOFAobject@dim_red slot filled with the UMAP output

Examples

# Using an existing trained model on simulated data
file <- system.file("extdata", "model.hdf5", package = "MOFA2")
model <- load_model(file)

# Change hyperparameters passed to umap
## Not run:  model <- run_umap(model, min_dist = 0.01, n_neighbors = 10) 
# Plot
## Not run:  model <- plot_dimred(model, method="UMAP") 

# Fetch data
## Not run:  umap.df <- plot_dimred(model, method="UMAP", return_data=TRUE) 


bioFAM/MOFA2 documentation built on Feb. 1, 2024, 6:41 a.m.