plot_pca {RNAseqQC}R Documentation

Plot results of a principal component analysis

Description

Plot results of a principal component analysis

Usage

plot_pca(
  obj,
  PC_x = 1,
  PC_y = 2,
  n_feats = 500,
  scale_feats = FALSE,
  na_frac = 0.3,
  metadata = NULL,
  color_by = NULL,
  shape_by = NULL,
  point_alpha = 0.7,
  point_rel_size = 2,
  show_plot = TRUE
)

Arguments

obj

A (features x samples) matrix or SummarizedExperiment object

PC_x

The PC to show on the x-axis.

PC_y

The PC to show on the y-axis.

n_feats

Number of top-variable features to include.

scale_feats

Whether to scale the features.

na_frac

Only consider features with the stated maximum fraction of NAs or NaNs. NA/NaNs will be mean-imputed for PCA.

metadata

A data.frame used for annotating samples. rownames(metadata) must match colnames(obj).

color_by

Variable by which to color points. Must be a column in metadata or in colData(obj).

shape_by

Variable by which to color points. Must be a column in metadata or in colData(obj).

point_alpha

alpha value of geom_point()

point_rel_size

relative size of geom_point()

show_plot

Whether to show the plot or not

Details

If the metadata or colData of obj contain a column colname, this colum will be removed in the ⁠$pca_data⁠ slot, because this column contains the colnames of the data matrix. Similarly, for the ⁠$loadings⁠ slot, the column rowname is reserved for the rownames of the data matrix.

Value

The function displays the plot and returns invisible a list of the plot, the data.frame to make the plot, the vector of percentages of variance explained and the loadings matrix.

Examples

set.seed(1)
data <- matrix(rnorm(100*6), ncol=6)
data <- t(t(data)+c(-1, -1.1, -1.2, 1, 1.1, 1.2))
plot_pca(data)


[Package RNAseqQC version 0.1.4 Index]