dim_reduce: Dimensionality reduction and visualization.

Description Usage Arguments Value Author(s) Examples

View source: R/dim_red.R

Description

Reduce dimensionality with a method in {tsne, umap, pca}.

Usage

1
2
3
dim_reduce(data, method = "pca", annot1 = NULL,
  annot1.name = "annot1", annot2 = NULL, annot2.name = "annot2",
  levels = NULL)

Arguments

data

A normalized dataframe or matrix with no missing data to be reduced in dimension.

method

A character string as the name of the method. Available values are "pca" (the default), "tsne", "umap".

annot1

A vector of continuous or factor values to color samples in the resulted plot (the order of values should be the same as the order of rows in data). Default to NULL.

annot1.name

The name of the variable indicating annot1 vector. Defaults to "annot1".

annot2

A vector of factor values indicating sample shapes to plot (the order of values should be the same as the order of rows in data). Default to NULL.

annot2.name

The name of the variable indicating annot2 vector. Defaults to "annot2".

levels

An integer value indicating the maximum number of levels of a categorical variable. To be used to distinguish the categorical variable. Defaults to NULL because it is supposed that data has been preprocessed using data_preproc and the categorical variables are specified. If it is set, first will run data_preproc to specify categorical and continuous variables.

Value

A plot of data points in the 2 dimensional space.

Author(s)

Elyas Heidari

Examples

1
2
3
4
5
6
7
8
data("NHANES")

## Using different methods on the raw data
df <- NHANES[sample(nrow(NHANES), 500), ]
plt_pca <- dim_reduce(df, method = "pca", levels = 15)
plt_tsne <- dim_reduce(df, method = "tsne", annot1 = df$BMXBMI, annot1.name = "BMI", levels = 15)
plt_umap <- dim_reduce(df, method = "umap", annot1 = df$LBXTC, annot1.name = "Total Cholesterol",
annot2 = as.factor(df$RIAGENDR), annot2.name = "Gender", levels = 15)

bAIo-lab/Questools documentation built on Nov. 9, 2019, 3:59 a.m.