| Title: | Genomic Exploratory Data Analysis |
|---|---|
| Description: | Provides a unified and reproducible framework for performing genomic exploratory data analysis (EDA). Highly repetitive functions and analyses have been collated into an easy-to-use S4 object that produces quick results and customizable visualizations to assess variation in your data. See <https://github.com/mikemartinez99/RGenEDA>. |
| Authors: | Michael Martinez [aut, cre] |
| Maintainer: | Michael Martinez <[email protected]> |
| License: | GPL-3 |
| Version: | 0.99.0 |
| Built: | 2026-10-30 02:15:07 UTC |
| Source: | https://github.com/BiocStaging/RGenEDA |
Builds a geneda object from a SummarizedExperiment, including
DESeqDataSet objects from DESeq2 and DESeqTransform objects returned by
DESeq2::vst() or DESeq2::rlog(). Raw counts, normalized values, and
sample metadata (colData) are carried over, so the object is ready for
FindVariableFeatures(), RunPCA(), and the plotting functions.
as.geneda(x, ...) ## S4 method for signature 'SummarizedExperiment' as.geneda( x, normalized = NULL, counts = "counts", transform = c("vst", "logcpm"), DEGs = NULL, ... )as.geneda(x, ...) ## S4 method for signature 'SummarizedExperiment' as.geneda( x, normalized = NULL, counts = "counts", transform = c("vst", "logcpm"), DEGs = NULL, ... )
x |
A |
... |
Not used. |
normalized |
Where the normalized values come from. One of:
|
counts |
Name or index of the raw counts assay in |
transform |
Normalization used when |
DEGs |
Optional named list of DEG tables ( |
Sample metadata are taken from colData(x) and converted to a
data.frame. Columns added by DESeq2, such as sizeFactor, are kept and
can be tested with PlotEigenCorr() like any other covariate.
Assays stored as sparse or delayed matrices are converted to base
matrices with as.matrix().
A geneda object.
GenEDA() to build a geneda object from matrices.
data(Snail1KO) counts <- as.matrix(Snail1KO$rawCounts) counts <- counts[rowSums(counts >= 10) >= 3, ] meta <- Snail1KO$metadata rownames(meta) <- meta$Sample se <- SummarizedExperiment::SummarizedExperiment( assays = list(counts = counts), colData = meta ) obj <- as.geneda(se, transform = "logcpm") obj # From a DESeqDataSet, with VST-normalized values and DEGs if (requireNamespace("DESeq2", quietly = TRUE)) { meta$Genotype <- factor(meta$Genotype, levels = c("WT", "Snai1_KO")) dds <- DESeq2::DESeqDataSetFromMatrix(counts, meta, design = ~Genotype) dds <- DESeq2::DESeq(dds, quiet = TRUE) obj <- as.geneda(dds, normalized = DESeq2::vst(dds), DEGs = list(KO_vs_WT = DESeq2::results(dds)) ) obj }data(Snail1KO) counts <- as.matrix(Snail1KO$rawCounts) counts <- counts[rowSums(counts >= 10) >= 3, ] meta <- Snail1KO$metadata rownames(meta) <- meta$Sample se <- SummarizedExperiment::SummarizedExperiment( assays = list(counts = counts), colData = meta ) obj <- as.geneda(se, transform = "logcpm") obj # From a DESeqDataSet, with VST-normalized values and DEGs if (requireNamespace("DESeq2", quietly = TRUE)) { meta$Genotype <- factor(meta$Genotype, levels = c("WT", "Snai1_KO")) dds <- DESeq2::DESeqDataSetFromMatrix(counts, meta, design = ~Genotype) dds <- DESeq2::DESeq(dds, quiet = TRUE) obj <- as.geneda(dds, normalized = DESeq2::vst(dds), DEGs = list(KO_vs_WT = DESeq2::results(dds)) ) obj }
Generate a multi-panel differential expression dashboard for a single
assay in a geneda object.
The dashboard includes:
P-value histogram
MA plot
Volcano plot
DEDashboard(object, assay, alpha = 0.05, l2fc = 1, num = NULL, den = NULL)DEDashboard(object, assay, alpha = 0.05, l2fc = 1, num = NULL, den = NULL)
object |
A |
assay |
Character. Name of the assay to visualize. |
alpha |
Numeric. Significance threshold for highlighting p-values and DEGs (default 0.05). |
l2fc |
Numeric. Log2 fold-change threshold for MA and volcano plots. |
num |
Character. Name of the numerator group for volcano plot labeling.
If |
den |
Character. Name of the denominator group for volcano plot
labeling.
If |
A patchwork object combining plots.
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") db <- DEDashboard(obj, assay = "KO_vs_WT", alpha = 0.05, l2fc = 1, num = "Snai1_KO", den = "WT" ) # The dashboard needs a large device, e.g. # ggplot2::ggsave("dashboard.png", db, width = 14, height = 10) class(db)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") db <- DEDashboard(obj, assay = "KO_vs_WT", alpha = 0.05, l2fc = 1, num = "Snai1_KO", den = "WT" ) # The dashboard needs a large device, e.g. # ggplot2::ggsave("dashboard.png", db, width = 14, height = 10) class(db)
Access DEGs container
DEGs(object, assay)DEGs(object, assay)
object |
A |
assay |
The name of the DEGs slot to return |
The DEG data.frame stored under assay, or NULL if it is not set
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") head(DEGs(obj, "KO_vs_WT"))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") head(DEGs(obj, "KO_vs_WT"))
Access dimensional reduction results list
DimReduction(object)DimReduction(object)
object |
A |
List with Loadings, Eigenvectors, percent_var
data(Snail1KO) counts <- as.matrix(Snail1KO$rawCounts) counts <- counts[rowSums(counts >= 10) >= 3, ] meta <- Snail1KO$metadata rownames(meta) <- meta$Sample norm <- log2(t(t(counts) / colSums(counts)) * 1e6 + 1) obj <- GenEDA(normalized = norm, metadata = meta, counts = counts) obj <- FindVariableFeatures(obj, nfeatures = 1000) obj <- RunPCA(obj) pca <- DimReduction(obj) names(pca) head(pca$Scores[, 1:3])data(Snail1KO) counts <- as.matrix(Snail1KO$rawCounts) counts <- counts[rowSums(counts >= 10) >= 3, ] meta <- Snail1KO$metadata rownames(meta) <- meta$Sample norm <- log2(t(t(counts) / colSums(counts)) * 1e6 + 1) obj <- GenEDA(normalized = norm, metadata = meta, counts = counts) obj <- FindVariableFeatures(obj, nfeatures = 1000) obj <- RunPCA(obj) pca <- DimReduction(obj) names(pca) head(pca$Scores[, 1:3])
Extract gene-level Eigen-vectors for PCs of interest and calculate percent variance.
extractEigen(object, component)extractEigen(object, component)
object |
A |
component |
Principal component to use (i.e., PC1) |
A data-frame containing gene loading information and percent variation per gene
data(Snail1KO) counts <- as.matrix(Snail1KO$rawCounts) counts <- counts[rowSums(counts >= 10) >= 3, ] meta <- Snail1KO$metadata rownames(meta) <- meta$Sample norm <- log2(t(t(counts) / colSums(counts)) * 1e6 + 1) obj <- GenEDA(normalized = norm, metadata = meta, counts = counts) obj <- FindVariableFeatures(obj, nfeatures = 1000) obj <- RunPCA(obj) pc1 <- extractEigen(obj, component = "PC1") head(pc1[order(-abs(pc1$EigenVector)), ])data(Snail1KO) counts <- as.matrix(Snail1KO$rawCounts) counts <- counts[rowSums(counts >= 10) >= 3, ] meta <- Snail1KO$metadata rownames(meta) <- meta$Sample norm <- log2(t(t(counts) / colSums(counts)) * 1e6 + 1) obj <- GenEDA(normalized = norm, metadata = meta, counts = counts) obj <- FindVariableFeatures(obj, nfeatures = 1000) obj <- RunPCA(obj) pc1 <- extractEigen(obj, component = "PC1") head(pc1[order(-abs(pc1$EigenVector)), ])
This function extracts PCA loadings stored in the DimReduction slot of a
geneda object and combines them with the associated metadata. It ensures
that the metadata has valid rownames and aligns the PCA loadings accordingly.
ExtractPCA(object)ExtractPCA(object)
object |
A |
The function performs several checks:
Ensures the input object is of class geneda.
Verifies that the DimReduction slot contains PCA loadings.
Confirms that the metadata has valid rownames.
Reorders the PCA loadings to match the order of metadata rows.
If metadata rownames are missing or invalid, the function throws an error.
A data.frame combining PCA loadings and sample metadata, where rows
correspond
to samples and columns include principal component loadings and metadata
fields.
data(Snail1KO) counts <- as.matrix(Snail1KO$rawCounts) counts <- counts[rowSums(counts >= 10) >= 3, ] meta <- Snail1KO$metadata rownames(meta) <- meta$Sample norm <- log2(t(t(counts) / colSums(counts)) * 1e6 + 1) obj <- GenEDA(normalized = norm, metadata = meta, counts = counts) obj <- FindVariableFeatures(obj, nfeatures = 1000) obj <- RunPCA(obj) pca_df <- ExtractPCA(obj) head(pca_df[, c("PC1", "PC2", "Genotype")])data(Snail1KO) counts <- as.matrix(Snail1KO$rawCounts) counts <- counts[rowSums(counts >= 10) >= 3, ] meta <- Snail1KO$metadata rownames(meta) <- meta$Sample norm <- log2(t(t(counts) / colSums(counts)) * 1e6 + 1) obj <- GenEDA(normalized = norm, metadata = meta, counts = counts) obj <- FindVariableFeatures(obj, nfeatures = 1000) obj <- RunPCA(obj) pca_df <- ExtractPCA(obj) head(pca_df[, c("PC1", "PC2", "Genotype")])
Filters the unfiltered DEGs in DEGs[[assay]] and stores the filtered
results
in a new named slot DEGs[[saveAssay]]. Multiple filtered result sets can
be stored with different assay names.
FilterDEGs(object, assay, alpha = 0.05, l2fc = 1, saveAssay)FilterDEGs(object, assay, alpha = 0.05, l2fc = 1, saveAssay)
object |
A |
assay |
The DEG slot to filter |
alpha |
Adjusted p-value threshold (<=) |
l2fc |
Absolute log2 fold change threshold (>=) |
saveAssay |
Character name for the filtered result set (e.g., "padj05_lfc1") |
Updated geneda object with filtered results stored in
DEGs[[saveAssay]]
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") obj <- FilterDEGs(obj, assay = "KO_vs_WT", alpha = 0.05, l2fc = 1, saveAssay = "KO_vs_WT_filtered" ) nrow(DEGs(obj, "KO_vs_WT_filtered"))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") obj <- FilterDEGs(obj, assay = "KO_vs_WT", alpha = 0.05, l2fc = 1, saveAssay = "KO_vs_WT_filtered" ) nrow(DEGs(obj, "KO_vs_WT_filtered"))
Looks for DEGs after filtering that overlap with HVGs.
FindHVDEGs(object, assay, direction = c("positive", "negative", "both"))FindHVDEGs(object, assay, direction = c("positive", "negative", "both"))
object |
A |
assay |
The DEG slot to pull results from (typically a result of
|
direction |
One of positive, negative, or both (indicating the direction of DEG fold change to intersect with HVGs) |
For direction = "positive" or "negative", a character vector of
gene IDs that are both DEGs in that direction and HVGs. For
direction = "both", a list with elements positive, negative, and
both (all overlapping genes).
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") obj <- FilterDEGs(obj, assay = "KO_vs_WT", saveAssay = "KO_vs_WT_filtered") obj <- FindVariableFeatures(obj, nfeatures = 1000) hv <- FindHVDEGs(obj, assay = "KO_vs_WT_filtered", direction = "both") lengths(hv)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") obj <- FilterDEGs(obj, assay = "KO_vs_WT", saveAssay = "KO_vs_WT_filtered") obj <- FindVariableFeatures(obj, nfeatures = 1000) hv <- FindHVDEGs(obj, assay = "KO_vs_WT_filtered", direction = "both") lengths(hv)
Computes per-feature variance on normalized(object), ranks genes by
decreasing variance, and stores the top nfeatures gene IDs into the HVGs
slot. Returns the updated object.
FindVariableFeatures(object, nfeatures)FindVariableFeatures(object, nfeatures)
object |
A |
nfeatures |
Number of HVGs to store |
Updated geneda object
data(Snail1KO) counts <- as.matrix(Snail1KO$rawCounts) counts <- counts[rowSums(counts >= 10) >= 3, ] meta <- Snail1KO$metadata rownames(meta) <- meta$Sample norm <- log2(t(t(counts) / colSums(counts)) * 1e6 + 1) obj <- GenEDA(normalized = norm, metadata = meta, counts = counts) obj <- FindVariableFeatures(obj, nfeatures = 1000) length(HVGs(obj))data(Snail1KO) counts <- as.matrix(Snail1KO$rawCounts) counts <- counts[rowSums(counts >= 10) >= 3, ] meta <- Snail1KO$metadata rownames(meta) <- meta$Sample norm <- log2(t(t(counts) / colSums(counts)) * 1e6 + 1) obj <- GenEDA(normalized = norm, metadata = meta, counts = counts) obj <- FindVariableFeatures(obj, nfeatures = 1000) length(HVGs(obj))
Construct a geneda object
GenEDA(normalized, metadata, counts = NULL, DEGs = NULL)GenEDA(normalized, metadata, counts = NULL, DEGs = NULL)
normalized |
Normalized expression matrix (features x samples). |
metadata |
Sample metadata |
counts |
Optional counts matrix (features x samples). |
DEGs |
Optional named list of DEG tables ( |
This constructor does not compute HVGs or PCA. Use
FindVariableFeatures() and RunPCA() afterward.
A geneda object.
data(Snail1KO) counts <- as.matrix(Snail1KO$rawCounts) counts <- counts[rowSums(counts >= 10) >= 3, ] meta <- Snail1KO$metadata rownames(meta) <- meta$Sample norm <- log2(t(t(counts) / colSums(counts)) * 1e6 + 1) obj <- GenEDA(normalized = norm, metadata = meta, counts = counts) objdata(Snail1KO) counts <- as.matrix(Snail1KO$rawCounts) counts <- counts[rowSums(counts >= 10) >= 3, ] meta <- Snail1KO$metadata rownames(meta) <- meta$Sample norm <- log2(t(t(counts) / colSums(counts)) * 1e6 + 1) obj <- GenEDA(normalized = norm, metadata = meta, counts = counts) obj
An S4 container for exploratory genomic data analysis. Stores optional raw counts, normalized data, sample metadata, highly variable genes (HVGs), and PCA dimensionality reduction results.
countsOptional counts matrix (features x samples). Can be NULL.
normalizedNormalized expression matrix (features x samples).
metadataSample-level metadata data.frame (rows = samples).
HVGsCharacter vector of selected highly variable gene IDs (row names).
DimReductionList for PCA results with Scores, Eigenvectors,
percent_var.
DEGsList container for differential expression results.
data(Snail1KO) counts <- as.matrix(Snail1KO$rawCounts) counts <- counts[rowSums(counts >= 10) >= 3, ] meta <- Snail1KO$metadata rownames(meta) <- meta$Sample norm <- log2(t(t(counts) / colSums(counts)) * 1e6 + 1) obj <- GenEDA(normalized = norm, metadata = meta, counts = counts) is(obj, "geneda")data(Snail1KO) counts <- as.matrix(Snail1KO$rawCounts) counts <- counts[rowSums(counts >= 10) >= 3, ] meta <- Snail1KO$metadata rownames(meta) <- meta$Sample norm <- log2(t(t(counts) / colSums(counts)) * 1e6 + 1) obj <- GenEDA(normalized = norm, metadata = meta, counts = counts) is(obj, "geneda")
Generate principal component analysis data that can be used in downstream analyses.
generatePCs(mat, vars, nFeatures)generatePCs(mat, vars, nFeatures)
mat |
A data matrix where rows are features and columns are samples |
vars |
A vector of gene variances (can calculate using RGenEDA::plotVariance) or gene names |
nFeatures |
Number of top features to generate principal components on. |
A list consisting of 3 slots: Loadings, Eigenvectors, and percent_var
data(Snail1KO) counts <- as.matrix(Snail1KO$rawCounts) counts <- counts[rowSums(counts >= 10) >= 3, ] meta <- Snail1KO$metadata rownames(meta) <- meta$Sample norm <- log2(t(t(counts) / colSums(counts)) * 1e6 + 1) obj <- GenEDA(normalized = norm, metadata = meta, counts = counts) vars <- apply(norm, 1, var) pcs <- generatePCs(norm, vars, nFeatures = 1000) pcs$percent_vardata(Snail1KO) counts <- as.matrix(Snail1KO$rawCounts) counts <- counts[rowSums(counts >= 10) >= 3, ] meta <- Snail1KO$metadata rownames(meta) <- meta$Sample norm <- log2(t(t(counts) / colSums(counts)) * 1e6 + 1) obj <- GenEDA(normalized = norm, metadata = meta, counts = counts) vars <- apply(norm, 1, var) pcs <- generatePCs(norm, vars, nFeatures = 1000) pcs$percent_var
Saves a pheatmap derived RGenEDA heatmap object to a file in various
formats
including PNG, JPEG, TIFF, BMP, PDF, and SVG.
GenSave( pheatmap_obj, filename, width = 8, height = 6, units = "in", res = 300, ... )GenSave( pheatmap_obj, filename, width = 8, height = 6, units = "in", res = 300, ... )
pheatmap_obj |
A |
filename |
Character string specifying the path and filename where the heatmap should be saved. |
width |
Numeric, the width of the output image. Default is 8. |
height |
Numeric, the height of the output image. Default is 6. |
units |
Character, units for width and height: one of "in", "cm", "mm", or "px". Default is "in". Values are converted to inches for PDF and SVG output. |
res |
Numeric, the resolution (in dpi) for raster images. Default is 300. |
... |
Additional arguments passed to the graphics device function. |
This function is similar in spirit to ggsave() but works specifically
with pheatmap objects.
Invisibly returns the filename of the saved heatmap.
data(Snail1KO) counts <- as.matrix(Snail1KO$rawCounts) counts <- counts[rowSums(counts >= 10) >= 3, ] meta <- Snail1KO$metadata rownames(meta) <- meta$Sample norm <- log2(t(t(counts) / colSums(counts)) * 1e6 + 1) obj <- GenEDA(normalized = norm, metadata = meta, counts = counts) dists <- PlotDistances(obj, meta_cols = "Genotype") out <- tempfile(fileext = ".png") GenSave(dists, out, width = 6, height = 5) file.exists(out)data(Snail1KO) counts <- as.matrix(Snail1KO$rawCounts) counts <- counts[rowSums(counts >= 10) >= 3, ] meta <- Snail1KO$metadata rownames(meta) <- meta$Sample norm <- log2(t(t(counts) / colSums(counts)) * 1e6 + 1) obj <- GenEDA(normalized = norm, metadata = meta, counts = counts) dists <- PlotDistances(obj, meta_cols = "Genotype") out <- tempfile(fileext = ".png") GenSave(dists, out, width = 6, height = 5) file.exists(out)
Access counts matrix (avoid name clash with DESeq2::counts)
getCounts(object)getCounts(object)
object |
A |
Matrix or NULL
data(Snail1KO) counts <- as.matrix(Snail1KO$rawCounts) counts <- counts[rowSums(counts >= 10) >= 3, ] meta <- Snail1KO$metadata rownames(meta) <- meta$Sample norm <- log2(t(t(counts) / colSums(counts)) * 1e6 + 1) obj <- GenEDA(normalized = norm, metadata = meta, counts = counts) getCounts(obj)[1:5, ]data(Snail1KO) counts <- as.matrix(Snail1KO$rawCounts) counts <- counts[rowSums(counts >= 10) >= 3, ] meta <- Snail1KO$metadata rownames(meta) <- meta$Sample norm <- log2(t(t(counts) / colSums(counts)) * 1e6 + 1) obj <- GenEDA(normalized = norm, metadata = meta, counts = counts) getCounts(obj)[1:5, ]
Access metadata (avoid name clash with S4 generics)
getMetadata(object)getMetadata(object)
object |
A |
data.frame
data(Snail1KO) counts <- as.matrix(Snail1KO$rawCounts) counts <- counts[rowSums(counts >= 10) >= 3, ] meta <- Snail1KO$metadata rownames(meta) <- meta$Sample norm <- log2(t(t(counts) / colSums(counts)) * 1e6 + 1) obj <- GenEDA(normalized = norm, metadata = meta, counts = counts) getMetadata(obj)data(Snail1KO) counts <- as.matrix(Snail1KO$rawCounts) counts <- counts[rowSums(counts >= 10) >= 3, ] meta <- Snail1KO$metadata rownames(meta) <- meta$Sample norm <- log2(t(t(counts) / colSums(counts)) * 1e6 + 1) obj <- GenEDA(normalized = norm, metadata = meta, counts = counts) getMetadata(obj)
Access normalized matrix (avoid name clash with generics)
getNormalized(object)getNormalized(object)
object |
A |
Matrix
data(Snail1KO) counts <- as.matrix(Snail1KO$rawCounts) counts <- counts[rowSums(counts >= 10) >= 3, ] meta <- Snail1KO$metadata rownames(meta) <- meta$Sample norm <- log2(t(t(counts) / colSums(counts)) * 1e6 + 1) obj <- GenEDA(normalized = norm, metadata = meta, counts = counts) getNormalized(obj)[1:5, ]data(Snail1KO) counts <- as.matrix(Snail1KO$rawCounts) counts <- counts[rowSums(counts >= 10) >= 3, ] meta <- Snail1KO$metadata rownames(meta) <- meta$Sample norm <- log2(t(t(counts) / colSums(counts)) * 1e6 + 1) obj <- GenEDA(normalized = norm, metadata = meta, counts = counts) getNormalized(obj)[1:5, ]
Access HVG IDs
HVGs(object)HVGs(object)
object |
A |
Character vector
data(Snail1KO) counts <- as.matrix(Snail1KO$rawCounts) counts <- counts[rowSums(counts >= 10) >= 3, ] meta <- Snail1KO$metadata rownames(meta) <- meta$Sample norm <- log2(t(t(counts) / colSums(counts)) * 1e6 + 1) obj <- GenEDA(normalized = norm, metadata = meta, counts = counts) obj <- FindVariableFeatures(obj, nfeatures = 500) head(HVGs(obj))data(Snail1KO) counts <- as.matrix(Snail1KO$rawCounts) counts <- counts[rowSums(counts >= 10) >= 3, ] meta <- Snail1KO$metadata rownames(meta) <- meta$Sample norm <- log2(t(t(counts) / colSums(counts)) * 1e6 + 1) obj <- GenEDA(normalized = norm, metadata = meta, counts = counts) obj <- FindVariableFeatures(obj, nfeatures = 500) head(HVGs(obj))
Generates violin plots with embedded boxplots showing the distribution
of normalized or VST-transformed RNA-Seq counts for each sample in a
geneda object. Optionally, plots can be faceted by a metadata variable.
PlotCountDist(object, split_by = NULL)PlotCountDist(object, split_by = NULL)
object |
A |
split_by |
Character. Optional column name from |
A ggplot2 object displaying the distribution of counts per sample.
data(Snail1KO) counts <- as.matrix(Snail1KO$rawCounts) counts <- counts[rowSums(counts >= 10) >= 3, ] meta <- Snail1KO$metadata rownames(meta) <- meta$Sample norm <- log2(t(t(counts) / colSums(counts)) * 1e6 + 1) obj <- GenEDA(normalized = norm, metadata = meta, counts = counts) PlotCountDist(obj) PlotCountDist(obj, split_by = "Genotype")data(Snail1KO) counts <- as.matrix(Snail1KO$rawCounts) counts <- counts[rowSums(counts >= 10) >= 3, ] meta <- Snail1KO$metadata rownames(meta) <- meta$Sample norm <- log2(t(t(counts) / colSums(counts)) * 1e6 + 1) obj <- GenEDA(normalized = norm, metadata = meta, counts = counts) PlotCountDist(obj) PlotCountDist(obj, split_by = "Genotype")
Compute a sample-by-sample distance matrix from a geneda
object and plot a ggplot2 heatmap. Optionally subset metadata columns and
reorder rows/columns by hierarchical clustering.
PlotDistances( object, method = "euclidean", reorder = TRUE, meta_cols = NULL, palettes = NULL, return = c("object", "plot") )PlotDistances( object, method = "euclidean", reorder = TRUE, meta_cols = NULL, palettes = NULL, return = c("object", "plot") )
object |
A |
method |
Distance method for stats::dist (default "euclidean") |
reorder |
Logical; if TRUE, reorder rows/cols by hclust on the distance matrix. Default TRUE |
meta_cols |
Optional character vector of metadata columns to display in the title/subtitle for quick reference (no annotation strips are drawn). |
palettes |
Optional named list of color vectors that can be used downstream (returned) if the caller wants to annotate elsewhere. |
return |
One of c("object", "plot"). If "plot", draws the heatmap immediately via grid and still returns the result list. Default "object". |
A list with elements: dist_matrix, order (character vector of sample names), heatmap (pheatmap object), palettes (as passed through)
data(Snail1KO) counts <- as.matrix(Snail1KO$rawCounts) counts <- counts[rowSums(counts >= 10) >= 3, ] meta <- Snail1KO$metadata rownames(meta) <- meta$Sample norm <- log2(t(t(counts) / colSums(counts)) * 1e6 + 1) obj <- GenEDA(normalized = norm, metadata = meta, counts = counts) colorList <- list(Genotype = c(WT = "grey40", Snai1_KO = "firebrick3")) dists <- PlotDistances(obj, meta_cols = "Genotype", palettes = colorList, return = "plot" )data(Snail1KO) counts <- as.matrix(Snail1KO$rawCounts) counts <- counts[rowSums(counts >= 10) >= 3, ] meta <- Snail1KO$metadata rownames(meta) <- meta$Sample norm <- log2(t(t(counts) / colSums(counts)) * 1e6 + 1) obj <- GenEDA(normalized = norm, metadata = meta, counts = counts) colorList <- list(Genotype = c(WT = "grey40", Snai1_KO = "firebrick3")) dists <- PlotDistances(obj, meta_cols = "Genotype", palettes = colorList, return = "plot" )
Calculate Eigen-correlations from a geneda object and plot a
publication-quality heatmap using ggplot2 with numeric labels and
significance stars. For continuous variables, Pearson correlation is used.
P values follow this convention: p < 0.001, p < 0.01, p < 0.05 = three, two,
one stars, respectively.
Two-level categorical variables are coded by factor level order, so the sign of the correlation follows the level order. Categorical variables with more than two levels are summarized by the multiple correlation R (the square root of R^2 from a one-way linear model, score ~ variable). R is unsigned (0 to 1) and its p-value comes from the model F-test, so results do not depend on how levels are labelled. Variables that cannot be tested (a single level, constant values, or no residual degrees of freedom, e.g. a sample ID column) are dropped.
Requires PCA scores in DimReduction(object); does not recompute PCA.
PlotEigenCorr(object, num_pcs = 10, meta_cols = NULL)PlotEigenCorr(object, num_pcs = 10, meta_cols = NULL)
object |
A |
num_pcs |
Number of principal components to correlate. |
meta_cols |
Optional character vector of metadata column names to include. Defaults to all metadata columns. |
A list with elements: cor_matrix, pval_matrix, stars, plot (ggplot)
data(Snail1KO) counts <- as.matrix(Snail1KO$rawCounts) counts <- counts[rowSums(counts >= 10) >= 3, ] meta <- Snail1KO$metadata rownames(meta) <- meta$Sample norm <- log2(t(t(counts) / colSums(counts)) * 1e6 + 1) obj <- GenEDA(normalized = norm, metadata = meta, counts = counts) obj <- FindVariableFeatures(obj, nfeatures = 1000) obj <- RunPCA(obj) ec <- PlotEigenCorr(obj, num_pcs = 5, meta_cols = "Genotype") ec$plotdata(Snail1KO) counts <- as.matrix(Snail1KO$rawCounts) counts <- counts[rowSums(counts >= 10) >= 3, ] meta <- Snail1KO$metadata rownames(meta) <- meta$Sample norm <- log2(t(t(counts) / colSums(counts)) * 1e6 + 1) obj <- GenEDA(normalized = norm, metadata = meta, counts = counts) obj <- FindVariableFeatures(obj, nfeatures = 1000) obj <- RunPCA(obj) ec <- PlotEigenCorr(obj, num_pcs = 5, meta_cols = "Genotype") ec$plot
Generates a pheatmap of the top genes contributing to a specific principal
component from a geneda object. Genes are selected by absolute eigenvector
loading for the chosen PC, and expression values are Z-score scaled per gene.
Optionally annotate columns with metadata variables and add row annotations
showing gene-level percent variance.
PlotEigenHeatmap( object, pc = "PC1", n = 25, annotate_by = NULL, annotate_colors = NULL, return = c("object", "plot") )PlotEigenHeatmap( object, pc = "PC1", n = 25, annotate_by = NULL, annotate_colors = NULL, return = c("object", "plot") )
object |
A |
pc |
Character. Principal component to visualize (e.g., "PC1"). |
n |
Integer. Number of genes to select by absolute loading (default: 25). |
annotate_by |
Character vector of metadata column names for column annotations (optional). |
annotate_colors |
Named list of color vectors for metadata columns.
Names should match |
return |
One of c("object","plot"). If "plot", draws the heatmap via grid. |
A list with topGenes (data.frame with EigenVector and PctVar),
expression (scaled matrix), and heatmap (pheatmap object)
data(Snail1KO) counts <- as.matrix(Snail1KO$rawCounts) counts <- counts[rowSums(counts >= 10) >= 3, ] meta <- Snail1KO$metadata rownames(meta) <- meta$Sample norm <- log2(t(t(counts) / colSums(counts)) * 1e6 + 1) obj <- GenEDA(normalized = norm, metadata = meta, counts = counts) obj <- FindVariableFeatures(obj, nfeatures = 1000) obj <- RunPCA(obj) res <- PlotEigenHeatmap(obj, pc = "PC1", n = 25, annotate_by = "Genotype", annotate_colors = list(Genotype = c( WT = "grey40", Snai1_KO = "firebrick3" )), return = "plot" )data(Snail1KO) counts <- as.matrix(Snail1KO$rawCounts) counts <- counts[rowSums(counts >= 10) >= 3, ] meta <- Snail1KO$metadata rownames(meta) <- meta$Sample norm <- log2(t(t(counts) / colSums(counts)) * 1e6 + 1) obj <- GenEDA(normalized = norm, metadata = meta, counts = counts) obj <- FindVariableFeatures(obj, nfeatures = 1000) obj <- RunPCA(obj) res <- PlotEigenHeatmap(obj, pc = "PC1", n = 25, annotate_by = "Genotype", annotate_colors = list(Genotype = c( WT = "grey40", Snai1_KO = "firebrick3" )), return = "plot" )
Plot variance for all genes (features) on a geneda object
using ggplot2.
PlotHVGVariance(object, transform = NULL, dropTopN = 0)PlotHVGVariance(object, transform = NULL, dropTopN = 0)
object |
A |
transform |
One of c("log") to log-transform variance, or NULL for none. Default = NULL |
dropTopN |
Number of top-most variable genes to drop prior to plotting. Default = 0 |
A ggplot2 object visualizing the variance of HVGs
data(Snail1KO) counts <- as.matrix(Snail1KO$rawCounts) counts <- counts[rowSums(counts >= 10) >= 3, ] meta <- Snail1KO$metadata rownames(meta) <- meta$Sample norm <- log2(t(t(counts) / colSums(counts)) * 1e6 + 1) obj <- GenEDA(normalized = norm, metadata = meta, counts = counts) PlotHVGVariance(obj, transform = "log")data(Snail1KO) counts <- as.matrix(Snail1KO$rawCounts) counts <- counts[rowSums(counts >= 10) >= 3, ] meta <- Snail1KO$metadata rownames(meta) <- meta$Sample norm <- log2(t(t(counts) / colSums(counts)) * 1e6 + 1) obj <- GenEDA(normalized = norm, metadata = meta, counts = counts) PlotHVGVariance(obj, transform = "log")
Plot MA plot from a geneda object. Requires that you have ran
SetDEGs on your object following differential expression in DESeq2.
PlotMA(object, assay, alpha, l2fc, title = NULL)PlotMA(object, assay, alpha, l2fc, title = NULL)
object |
A |
assay |
The DEG slot to use for visualization |
alpha |
Threshold for adjusted p-values (padj column from |
l2fc |
Absolute value log2Fold-change magnitude threshold (log2FoldChange column) |
title |
Optional character vector of what plot should be titled. |
Thresholds are inclusive (padj <= alpha, |log2FoldChange| >= l2fc),
matching FilterDEGs().
A ggplot2 object
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)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)
Calculate correlations between NMDS ordination axes (from beta diversity distances) and metadata, and plot a ggplot2 heatmap with numeric labels and significance stars.
For continuous variables, Pearson correlation is used. P values follow this convention: p < 0.001, p < 0.01, p < 0.05 = three, two, one stars, respectively.
Two-level categorical variables are coded by factor level order, so the sign of the correlation follows the level order. Categorical variables with more than two levels are summarized by the multiple correlation R (the square root of R^2 from a one-way linear model, score ~ variable). R is unsigned (0 to 1) and its p-value comes from the model F-test, so results do not depend on how levels are labelled. Variables that cannot be tested (a single level, constant values, or no residual degrees of freedom, e.g. a sample ID column) are dropped.
Default num_mds is 10, but function will internally set max number of NMDS to be n-1 where n is your number of samples.
PlotOrdCorr(object, num_mds = 10, meta_cols = NULL, distance = "bray")PlotOrdCorr(object, num_mds = 10, meta_cols = NULL, distance = "bray")
object |
A |
num_mds |
Number of NMDS axes to correlate. Default = 10 |
meta_cols |
Optional character vector of metadata column names to include. Defaults to all metadata columns. |
distance |
Distance metric for |
A list with elements: cor_matrix, pval_matrix, stars, plot (ggplot), and variance explained (squared correlations between ordination distances and observed dissimilarities.)
data(Snail1KO) counts <- as.matrix(Snail1KO$rawCounts) counts <- counts[rowSums(counts >= 10) >= 3, ] meta <- Snail1KO$metadata rownames(meta) <- meta$Sample norm <- log2(t(t(counts) / colSums(counts)) * 1e6 + 1) obj <- GenEDA(normalized = norm, metadata = meta, counts = counts) set.seed(42) oc <- PlotOrdCorr(obj, num_mds = 3, meta_cols = "Genotype") oc$plotdata(Snail1KO) counts <- as.matrix(Snail1KO$rawCounts) counts <- counts[rowSums(counts >= 10) >= 3, ] meta <- Snail1KO$metadata rownames(meta) <- meta$Sample norm <- log2(t(t(counts) / colSums(counts)) * 1e6 + 1) obj <- GenEDA(normalized = norm, metadata = meta, counts = counts) set.seed(42) oc <- PlotOrdCorr(obj, num_mds = 3, meta_cols = "Genotype") oc$plot
Visualize principal component analysis (PCA) results stored within a
GenEDA object. This function extracts PCA data via ExtractPCA
and provides a flexible ggplot2-based visualization interface.
PlotPCA( object, x = 1, y = 2, color_by, colors = NULL, split_by = NULL, shape_by = NULL, return_data = FALSE )PlotPCA( object, x = 1, y = 2, color_by, colors = NULL, split_by = NULL, shape_by = NULL, return_data = FALSE )
object |
A |
x |
Numeric or character. The principal component to plot on the x-axis (e.g., 1 or "PC1"). |
y |
Numeric or character. The principal component to plot on the y-axis (e.g., 2 or "PC2"). |
color_by |
Character. Column name in the metadata used to color points. |
colors |
Vector. Custom colors to use for plotting |
split_by |
Character (optional). Column name in metadata used for faceting (creates separate panels). |
shape_by |
Character (optional). Column name in metadata used to control point shape. |
return_data |
Logical (default = FALSE), whether or not to return pca dataframe for more custom plotting. |
A ggplot object displaying the PCA scatter plot, or a list of
pca_df and plot if return_data = TRUE
data(Snail1KO) counts <- as.matrix(Snail1KO$rawCounts) counts <- counts[rowSums(counts >= 10) >= 3, ] meta <- Snail1KO$metadata rownames(meta) <- meta$Sample norm <- log2(t(t(counts) / colSums(counts)) * 1e6 + 1) obj <- GenEDA(normalized = norm, metadata = meta, counts = counts) obj <- FindVariableFeatures(obj, nfeatures = 1000) obj <- RunPCA(obj) PlotPCA(obj, x = 1, y = 2, color_by = "Genotype", colors = c(WT = "grey40", Snai1_KO = "firebrick3") )data(Snail1KO) counts <- as.matrix(Snail1KO$rawCounts) counts <- counts[rowSums(counts >= 10) >= 3, ] meta <- Snail1KO$metadata rownames(meta) <- meta$Sample norm <- log2(t(t(counts) / colSums(counts)) * 1e6 + 1) obj <- GenEDA(normalized = norm, metadata = meta, counts = counts) obj <- FindVariableFeatures(obj, nfeatures = 1000) obj <- RunPCA(obj) PlotPCA(obj, x = 1, y = 2, color_by = "Genotype", colors = c(WT = "grey40", Snai1_KO = "firebrick3") )
Generate a p-value histogram from a DEG table inside a
geneda object.
This function uses raw p-values only and highlights p-values below a given
threshold (default 0.05).
PlotPValHist(object, assay, bins = 40, alpha = 0.05, title = NULL)PlotPValHist(object, assay, bins = 40, alpha = 0.05, title = NULL)
object |
A |
assay |
The name of the DEG table to use (must contain a "pvalue" column). |
bins |
Number of histogram bins (default 40). |
alpha |
Significance threshold (default 0.05). Bars representing p-values < alpha will be highlighted. |
title |
Optional title for the plot. |
A ggplot2 object
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") PlotPValHist(obj, assay = "KO_vs_WT")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") PlotPValHist(obj, assay = "KO_vs_WT")
Generate a scree plot
PlotScree(object)PlotScree(object)
object |
A |
A ggplot2 object
data(Snail1KO) counts <- as.matrix(Snail1KO$rawCounts) counts <- counts[rowSums(counts >= 10) >= 3, ] meta <- Snail1KO$metadata rownames(meta) <- meta$Sample norm <- log2(t(t(counts) / colSums(counts)) * 1e6 + 1) obj <- GenEDA(normalized = norm, metadata = meta, counts = counts) obj <- FindVariableFeatures(obj, nfeatures = 1000) obj <- RunPCA(obj) PlotScree(obj)data(Snail1KO) counts <- as.matrix(Snail1KO$rawCounts) counts <- counts[rowSums(counts >= 10) >= 3, ] meta <- Snail1KO$metadata rownames(meta) <- meta$Sample norm <- log2(t(t(counts) / colSums(counts)) * 1e6 + 1) obj <- GenEDA(normalized = norm, metadata = meta, counts = counts) obj <- FindVariableFeatures(obj, nfeatures = 1000) obj <- RunPCA(obj) PlotScree(obj)
Plot volcano plot from a geneda object. Requires that you
have ran
SetDEGs on your object following differential expression in DESeq2.
PlotVolcano(object, assay, alpha, l2fc, den = NULL, num = NULL, title = NULL)PlotVolcano(object, assay, alpha, l2fc, den = NULL, num = NULL, title = NULL)
object |
A |
assay |
The DEG slot to use for visualization |
alpha |
Threshold for adjusted p-values (padj column from |
l2fc |
Absolute value log2Fold-change magnitude threshold (log2FoldChange column) |
den |
Denominator (reference level for comparison, num vs. den).
If |
num |
Numerator (numerator level for comparison, num vs. den).
If |
title |
Optional character vector of what plot should be titled. |
Thresholds are inclusive (padj <= alpha, |log2FoldChange| >= l2fc),
matching FilterDEGs(). Genes with a missing log2FoldChange or padj
are not plotted.
A ggplot2 object
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") PlotVolcano(obj, assay = "KO_vs_WT", alpha = 0.05, l2fc = 1, den = "WT", num = "Snai1_KO" )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") PlotVolcano(obj, assay = "KO_vs_WT", alpha = 0.05, l2fc = 1, den = "WT", num = "Snai1_KO" )
DimReduction
Uses generatePCs() under the hood.
If HVGs are empty, selects HVGs via FindVariableFeatures(object, nfeatures)
with default nfeatures = 2000. If HVGs are present, the PCA uses
NFEATURES = length(HVGs(object)). This aligns the PCA feature count with
the
HVG selection while allowing an explicit override of nfeatures when empty.
RunPCA(object, nfeatures = 2000)RunPCA(object, nfeatures = 2000)
object |
A |
nfeatures |
Number of features to use when HVGs are empty. Default = 2000 |
Updated geneda object with DimReduction filled
data(Snail1KO) counts <- as.matrix(Snail1KO$rawCounts) counts <- counts[rowSums(counts >= 10) >= 3, ] meta <- Snail1KO$metadata rownames(meta) <- meta$Sample norm <- log2(t(t(counts) / colSums(counts)) * 1e6 + 1) obj <- GenEDA(normalized = norm, metadata = meta, counts = counts) obj <- RunPCA(obj, nfeatures = 1000) DimReduction(obj)$percent_vardata(Snail1KO) counts <- as.matrix(Snail1KO$rawCounts) counts <- counts[rowSums(counts >= 10) >= 3, ] meta <- Snail1KO$metadata rownames(meta) <- meta$Sample norm <- log2(t(t(counts) / colSums(counts)) * 1e6 + 1) obj <- GenEDA(normalized = norm, metadata = meta, counts = counts) obj <- RunPCA(obj, nfeatures = 1000) DimReduction(obj)$percent_var
Set unfiltered DEGs on the object
SetDEGs(object, deg_table, assay)SetDEGs(object, deg_table, assay)
object |
A |
deg_table |
A data.frame of DESeq2-like results containing at least
columns |
assay |
What to name the DEG slot |
Updated geneda object with DEGs[[assay]] set
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") objdata(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") obj
Prints a short summary of a geneda object: the number of features,
samples, and HVGs, whether PCA results and counts are present, and the
names of stored DEG tables.
## S4 method for signature 'geneda' show(object)## S4 method for signature 'geneda' show(object)
object |
A |
Invisibly returns object; called for its printed summary.
data(Snail1KO) counts <- as.matrix(Snail1KO$rawCounts) counts <- counts[rowSums(counts >= 10) >= 3, ] meta <- Snail1KO$metadata rownames(meta) <- meta$Sample norm <- log2(t(t(counts) / colSums(counts)) * 1e6 + 1) obj <- GenEDA(normalized = norm, metadata = meta, counts = counts) obj <- RunPCA(obj, nfeatures = 1000) show(obj)data(Snail1KO) counts <- as.matrix(Snail1KO$rawCounts) counts <- counts[rowSums(counts >= 10) >= 3, ] meta <- Snail1KO$metadata rownames(meta) <- meta$Sample norm <- log2(t(t(counts) / colSums(counts)) * 1e6 + 1) obj <- GenEDA(normalized = norm, metadata = meta, counts = counts) obj <- RunPCA(obj, nfeatures = 1000) show(obj)
Dataset from Maturi, et al. 2018, (ENA:ERP019920, E-MTAB-5244)
data(Snail1KO)data(Snail1KO)
A list containing raw counts and metadata
A dataframe of raw counts expression matrix
A dataframe of associated metadata
Maturi et al., 2018; ENA: ERP019920; E-MTAB-5244
data(Snail1KO) dim(Snail1KO$rawCounts) Snail1KO$metadatadata(Snail1KO) dim(Snail1KO$rawCounts) Snail1KO$metadata
Summarizes the number of DEGs in each assay of a geneda object according
to thresholds
for adjusted p-value and log2 fold-change, separately reporting
upregulated and downregulated genes.
Thresholds are inclusive (padj <= alpha, |log2FoldChange| >= lfc),
matching FilterDEGs().
Genes with a missing log2FoldChange or padj are not counted; missing
values in
other columns (e.g., gene annotations) are ignored.
SummarizeDEGs(object, alpha = 0.05, lfc1 = 1, lfc2 = 2, assays = NULL)SummarizeDEGs(object, alpha = 0.05, lfc1 = 1, lfc2 = 2, assays = NULL)
object |
A |
alpha |
Numeric; adjusted p-value threshold. Default is 0.05. |
lfc1 |
Numeric; lower log2 fold-change threshold. Default is 1. |
lfc2 |
Numeric; higher log2 fold-change threshold. Default is 2. |
assays |
Optional character vector of assay names to summarize.
Defaults to all assays in |
A data.frame of DEG counts by assay and criteria.
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") SummarizeDEGs(obj, alpha = 0.05, lfc1 = 1, lfc2 = 2)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") SummarizeDEGs(obj, alpha = 0.05, lfc1 = 1, lfc2 = 2)