hi_loadings: Extract genes with highest loadings

View source: R/hi_loadings.R

hi_loadingsR Documentation

Extract genes with highest loadings

Description

Extract genes with highest loadings

Usage

hi_loadings(
  pcaobj,
  whichpc = 1,
  topN = 10,
  exprTable = NULL,
  annotation = NULL,
  title = "Top/bottom loadings"
)

Arguments

pcaobj

A prcomp object

whichpc

An integer number, corresponding to the principal component of interest

topN

Integer, number of genes with top and bottom loadings

exprTable

A matrix object, e.g. the counts of a DESeqDataSet. If not NULL, returns the counts matrix for the selected genes

annotation

A data.frame object, with row.names as gene identifiers (e.g. ENSEMBL ids) and a column, gene_name, containing e.g. HGNC-based gene symbols

title

The title of the plot

Value

A ggplot2 object, or a matrix, if exprTable is not null

Examples

dds <- makeExampleDESeqDataSet_multifac(betaSD = 3, betaSD_tissue = 1)
rlt <- DESeq2::rlogTransformation(dds)
pcaobj <- prcomp(t(SummarizedExperiment::assay(rlt)))
hi_loadings(pcaobj, topN = 20)
hi_loadings(pcaobj, topN = 10, exprTable = dds)
hi_loadings(pcaobj, topN = 10, exprTable = counts(dds))


federicomarini/pcaExplorer documentation built on April 8, 2024, 3:15 a.m.