vic3_plotPCA: PCA plot

Description Usage Arguments Details Examples

View source: R/plots.R

Description

vic3_plotPCA returns PCA plot for normalized counts output by DESeq2.

Usage

1
vic3_plotPCA(counts, group_vector, ntop = 500, returnData = FALSE)

Arguments

counts

Counts table output assay(x) or matrix.

group_vector

Column name in DESeq2 colData(x).

ntop

Numeric. Number of top genes with most variance.

returnData

Logical (default FALSE). Return PC1 and PC2 data.frame.

Details

The function works similarly to DESeq2 plotPCA. It accepts count tables which could be accessed with assay function.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
## Load SE dataset
se <- readRDS(system.file("extdata", "se_vic3_2020.RData", package = "vic3PCD"))

## DESeq dataset
dds <- DESeqDataSet(se, design = ~ condition)

## DESeq analysis
dds <- DESeq(dds)
## Filter genes with more than 10 aligned reads
keep <- rowSums(counts(dds)) >= 10
dds <- dds[keep,]
## Normised counts
rld <- rlog(dds, blind = F)

## Manual color
clr = c("dodgerblue3", "coral3")
names(clr) <- unique(colData(rld)[,"condition"])

vic3_plotPCA(counts = assay(rld), group_vector = colData(rld)[,"condition"]) +
scale_colour_manual(values=clr, name = "Condition:") +
geom_text(label = colData(rld)[,"exset"], size = 3, colour = "black", fontface = "italic", hjust = 0, nudge_x = 3) +
xlim(-20,60) +
ylim(-25,25)

anabeloff/vic3PCD documentation built on Dec. 2, 2020, 11:03 a.m.