ordplots: Generate Ordination Plots

ordplotsR Documentation

Generate Ordination Plots

Description

This function creates ordination plots based on the provided data and metadata. It supports multiple ordination methods and can generate plots for various metadata variables.

Usage

ordplots(
  data,
  metadata,
  output,
  outputname = NA,
  method = "pcoa",
  index = "bray/curtis"
)

Arguments

data

A matrix or data frame containing the main data, with samples as rows and features as columns.

metadata

A data frame containing metadata for the samples. Row names should match those in 'data'.

output

A character string specifying the directory where output files will be saved.

outputname

A character string for the name of the output file. If NA, the method name will be used.

method

A character string specifying the ordination method. Options are "tsne", "pcoa", or "pca". Default is "pcoa".

index

A character string specifying the distance index to use for PCoA. Default is "bray/curtis".

Details

The function performs the following steps: 1. Aligns the data and metadata based on common row names. 2. Performs the specified ordination method on the data. 3. Creates a PDF file containing ordination plots for each metadata variable. 4. Returns a list of the generated ggplot objects.

Ordination plots are not generated for metadata variables with less than 2 or more than 100 unique values.

Value

A list of ggplot objects, one for each metadata variable plotted.

Examples

## Not run: 
data <- matrix(rnorm(1000), ncol = 10)
metadata <- data.frame(group = rep(c("A", "B"), each = 50))
rownames(data) <- rownames(metadata) <- paste0("Sample", 1:100)
plots <- ordplots(data, metadata, output = "results", method = "pcoa")

## End(Not run)


omicsEye/omicsArt documentation built on Oct. 8, 2024, 5:46 p.m.