pcaPlottly | R Documentation |
Create an interactive PCA scatter plot using Plotly from log-expression data.
pcaPlottly(logcounts, Sample, Group, title, palette, center, scale)
logcounts |
Numeric matrix of log-CPM values (genes × samples), e.g., from edgeR::cpm. |
Sample |
Character vector of sample names corresponding to the columns of "logcounts ". |
Group |
Factor or character vector denoting group/condition for each sample. |
title |
Character. Title for the PCA plot. |
palette |
Character. Name of a discrete color palette from the "paletteer" package. |
center |
Logical. If TRUE, center variables (genes) before PCA. |
scale |
Logical. If TRUE, scale variables to unit variance before PCA. |
This function performs Principal Component Analysis (PCA) on a log-count matrix and generates an interactive plot of the first two principal components via "plotly::ggplotly()".
Transposes the "logcounts " matrix so samples are rows.
Runs PCA with "stats::prcomp() ", using centering and scaling as specified.
Computes percent variance explained by PC1 and PC2.
Builds a ggplot2 scatterplot and converts it to an interactive Plotly graph.
A Plotly object ( "plotly::ggplotly ") representing the interactive PCA scatterplot.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.