plot_dimred {MOFA2} | R Documentation

## Plot dimensionality reduction based on MOFA factors

### Description

Plot dimensionality reduction based on MOFA factors

### Usage

    plot_dimred(
      object,
      method = c("UMAP", "TSNE"),
      groups = "all",
      show_missing = TRUE,
      color_by = NULL,
      shape_by = NULL,
      color_name = NULL,
      shape_name = NULL,
      label = FALSE,
      dot_size = 1.5,
      stroke = NULL,
      alpha_missing = 1,
      legend = TRUE,
      rasterize = FALSE,
      return_data = FALSE,
      ...
    )

### Arguments

`object` | a trained `MOFA` object.
`method` | string indicating which method has been used for non-linear dimensionality reduction (either 'umap' or 'tsne')
`groups` | character vector with the groups names, or numeric vector with the indices of the groups of samples to use, or "all" to use samples from all groups.
`show_missing` | logical indicating whether to include samples for which `shape_by` or `color_by` is missing
`color_by` | specifies groups or values used to color the samples. This can be either: (1) a character giving the name of a feature present in the training data. (2) a character giving the same of a column present in the sample metadata. (3) a vector of the same length as the number of samples specifying discrete groups or continuous numeric values.
`shape_by` | specifies groups or values used to shape the samples. This can be either: (1) a character giving the name of a feature present in the training data, (2) a character giving the same of a column present in the sample metadata. (3) a vector of the same length as the number of samples specifying discrete groups.
`color_name` | name for color legend.
`shape_name` | name for shape legend.
`label` | logical indicating whether to label the medians of the clusters. Only if color_by is specified
`dot_size` | numeric indicating dot size.
`stroke` | numeric indicating the stroke size (the black border around the dots, default is NULL, infered automatically).
`alpha_missing` | numeric indicating dot transparency of missing data.
`legend` | logical indicating whether to add legend.
`rasterize` | logical indicating whether to rasterize plot using `geom_point_rast`
`return_data` | logical indicating whether to return the long data frame to plot instead of plotting
`...` | extra arguments passed to `run_umap` or `run_tsne`.

### Details

This function plots dimensionality reduction projections that are stored in the `dim_red` slot. Typically this contains UMAP or t-SNE projections computed using `run_tsne` or `run_umap`, respectively.

### Value

Returns a `ggplot2` object or a long data.frame (if return_data is TRUE)

### Examples

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

    # Run UMAP
    model <- run_umap(model)

    # Plot UMAP
    plot_dimred(model, method = "UMAP")

    # Plot UMAP, colour by Factor 1 values
    plot_dimred(model, method = "UMAP", color_by = "Factor1")

    # Plot UMAP, colour by the values of a specific feature
    plot_dimred(model, method = "UMAP", color_by = "feature_0_view_0")

[Package MOFA2 version 1.2.2 Index]