Extract genes with highest loadings

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)
#> class: DESeqDataSet 
#> dim: 20 12 
#> metadata(1): version
#> assays(1): counts
#> rownames(20): gene300 gene88 ... gene961 gene444
#> rowData names(4): trueIntercept trueBeta_condition trueBeta_tissue
#>   trueDisp
#> colnames(12): sample1 sample2 ... sample11 sample12
#> colData names(2): condition tissue
hi_loadings(pcaobj, topN = 10, exprTable = counts(dds))
#>         sample1 sample2 sample3 sample4 sample5 sample6 sample7 sample8 sample9
#> gene300      16       6      10       2       0       1    1351     526    1211
#> gene88       30      77      24      46       8      37    8591    6193   11330
#> gene427      45      64      42      76      60     124    4956    3260    2321
#> gene415     109     129      49      51     125     130   19543   18247   13509
#> gene305       1       5       0       0       0       0    1732     321      19
#> gene838      27       5      10       7       7       7    2112    4368    3959
#> gene239       9       6       3       1       1       0     903    3410      74
#> gene758      49      13      39      30      38      58    8797   12405    3412
#> gene917      15      21      33      32      14       5   12829   27023   14151
#> gene766       3       6      16       8      10       4    3819    3015    3545
#> gene496     347     297     299     398     258     374       0       3       2
#> gene4        90      53      27     102     152      72       0       0       0
#> gene558     233      71     211     170     126      90       3       1       0
#> gene361      42      29      31      88      61     196       0       0       0
#> gene795     172     162      79     186     146      60       1       5       0
#> gene124     105      39      57     143      81     182       0       3       0
#> gene54       39      82      63      39      27      67       1       0       0
#> gene204      47      62     116      81     125      84       1       1       1
#> gene961      71      91      89      79     129      93       0       2       1
#> gene444      13      35      56      80      62      15       0       0       0
#>         sample10 sample11 sample12
#> gene300      441      227      449
#> gene88      2797      542     3383
#> gene427    19699    18154    24313
#> gene415     4508    11323    10913
#> gene305       81      219       14
#> gene838      430     1477     1446
#> gene239      158      346     3642
#> gene758    17233    16278    10338
#> gene917     6588     1753      730
#> gene766     1388     3942     2556
#> gene496        4        5        2
#> gene4          1        0        0
#> gene558        1        2        1
#> gene361        0        1        0
#> gene795        1        2        1
#> gene124        1        1        1
#> gene54         0        0        0
#> gene204        0        1        2
#> gene961        2        1        2
#> gene444        1        0        1