Skip to contents

Plot MA plot from a geneda object. Requires that you have ran SetDEGs on your object following differential expression in DESeq2.

Usage

PlotMA(object, assay, alpha, l2fc, title = NULL)

Arguments

object

A geneda object containing DEGs from SetDEGs method

assay

The DEG slot to use for visualization

alpha

Threshold for adjusted p-values (padj column from DESeq2)

l2fc

Absolute value log2Fold-change magnitude threshold (log2FoldChange column)

title

Optional character vector of what plot should be titled.

Value

A ggplot2 object

Details

Thresholds are inclusive (padj <= alpha, |log2FoldChange| >= l2fc), matching FilterDEGs().

Examples

data(Snail1KO)
counts <- as.matrix(Snail1KO$rawCounts)
counts <- counts[rowSums(counts >= 10) >= 3, ]
meta <- Snail1KO$metadata
rownames(meta) <- meta$Sample
meta$Genotype <- factor(meta$Genotype, levels = c("WT", "Snai1_KO"))
norm <- log2(t(t(counts) / colSums(counts)) * 1e6 + 1)
obj <- GenEDA(normalized = norm, metadata = meta, counts = counts)

# Differential expression with DESeq2 (Snai1_KO vs WT)
dds <- DESeq2::DESeqDataSetFromMatrix(counts, meta, design = ~Genotype)
dds <- DESeq2::DESeq(dds, quiet = TRUE)
res <- as.data.frame(DESeq2::results(dds))
obj <- SetDEGs(obj, res, assay = "KO_vs_WT")
PlotMA(obj, assay = "KO_vs_WT", alpha = 0.05, l2fc = 1)
#> Scale for size is already present.
#> Adding another scale for size, which will replace the existing scale.
#> Warning: Removed 5 rows containing missing values or values outside the scale range
#> (`geom_point()`).