MDSmyDF: MDS Plot of Data Frame

View source: R/MultiDimScaling.R

MDSmyDFR Documentation

MDS Plot of Data Frame

Description

Performs multidimensional scaling (MDS) on a data frame and generates a plot of the results. The function uses the ggplot2 package to create a scatterplot of the MDS coordinates with colored points based on a factor variable. The ggrepel package is used to add labels to the points without overlap.

Usage

MDSmyDF(dfx, labelsDF, factorV, title = "MDS Plot", col_vector, returnMDS = F)

Arguments

dfx

A data frame with samples as rows and variables as columns.

labelsDF

A data frame with the labels for each sample in the same order as dfx.

factorV

A vector containing the factor variable to use for coloring the points.

title

A character string for the title of the plot.

col_vector

A vector of colors to use for coloring the points.

returnMDS

A logical value indicating whether to return the MDS coordinates as a data frame. Default is FALSE.

Value

If returnMDS is TRUE, returns a data frame of the MDS coordinates. Otherwise, returns a ggplot object.

Examples

data(iris)
MDSmyDF(dfx = iris[, 1:4], labelsDF = iris[, 5], factorV = iris[, 5], title = "Iris Data MDS Plot", 
  col_vector = c("#FF0000", "#00FF00", "#0000FF"))

eisascience/scCustFx documentation built on June 2, 2025, 3:59 a.m.