README.md

Jam SummarizedExperiment Stats (jamses)

This package is under active development, these functions make up a core set of methods currently used across active Omics analysis projects. A summary of goals and relevant features are described below.

Full jamses command reference

Goals of jamses

The core goal is to make data analysis and visualization of SummarizedExperiment objects straightforward for common scenarios. It also accepts SingleCellExperiment and Seurat objects.

Approach for Statistical Contrasts

The Limma User’s Guide (LUG) is an amazing resource which describes alternate approaches for one-way and two-way contrasts, which are mathematically equivalent. For a more thorough discussion please review these approaches to confirm that ~0 + x is mathematically identical to ~ x, and only differs in how estimates are reported.

It compares (treated-control) with factor level A unchanged. However, an invalid one-way contrast is shown below:

  (A_treated - B_control) # not a valid one-way contrast

It is invalid because allows two factor changes: treated-control and A-B.

Design and contrasts - SEDesign

SEDesign S4 Object Details

SEDesign is an S4 object that contains the following slots:

Example SEDesign object

The example below uses a character vector of group names per sample, with two factors separated by underscore "_". The same data can be provided as a data.frame with two columns.

library(jamses)
library(kableExtra)

igroups <- jamba::nameVector(paste(rep(c("WT", "KO"), each=6),
   rep(c("Control", "Treated"), each=3),
   sep="_"),
   suffix="_rep");
igroups <- factor(igroups, levels=unique(igroups));
# jamba::kable_coloring(color_cells=FALSE,
#    format="markdown",
#    caption="Sample to group association",
#    data.frame(groups=igroups))
knitr::kable(data.frame(groups=igroups))

| | groups | |:----------------|:-----------| | WT_Control_rep1 | WT_Control | | WT_Control_rep2 | WT_Control | | WT_Control_rep3 | WT_Control | | WT_Treated_rep1 | WT_Treated | | WT_Treated_rep2 | WT_Treated | | WT_Treated_rep3 | WT_Treated | | KO_Control_rep1 | KO_Control | | KO_Control_rep2 | KO_Control | | KO_Control_rep3 | KO_Control | | KO_Treated_rep1 | KO_Treated | | KO_Treated_rep2 | KO_Treated | | KO_Treated_rep3 | KO_Treated |

The resulting design and contrasts matrices are shown below:

sedesign <- groups_to_sedesign(igroups);
jamba::kable_coloring(
# knitr::kable(
   colorSub=c(`-1`="dodgerblue", `1`="firebrick"),
   caption="Design matrix output from design(sedesign).",
   data.frame(check.names=FALSE, design(sedesign)));
Design matrix output from design(sedesign). WT_Control WT_Treated KO_Control KO_Treated WT_Control_rep1 1 0 0 0 WT_Control_rep2 1 0 0 0 WT_Control_rep3 1 0 0 0 WT_Treated_rep1 0 1 0 0 WT_Treated_rep2 0 1 0 0 WT_Treated_rep3 0 1 0 0 KO_Control_rep1 0 0 1 0 KO_Control_rep2 0 0 1 0 KO_Control_rep3 0 0 1 0 KO_Treated_rep1 0 0 0 1 KO_Treated_rep2 0 0 0 1 KO_Treated_rep3 0 0 0 1

# knitr::kable(
jamba::kable_coloring(
   colorSub=c(`-1`="dodgerblue", `1`="firebrick"),
   caption="Contrast matrix output from contrasts(sedesign).",
   data.frame(check.names=FALSE, contrasts(sedesign)));
Contrast matrix output from contrasts(sedesign). KO_Control-WT_Control KO_Treated-WT_Treated WT_Treated-WT_Control KO_Treated-KO_Control (KO_Treated-WT_Treated)-(KO_Control-WT_Control) WT_Control -1 0 -1 0 1 WT_Treated 0 -1 1 0 -1 KO_Control 1 0 0 -1 -1 KO_Treated 0 1 0 1 1

For convenience, SEDesign can be visualized using plot_sedesign():

# plot the design and contrasts
plot_sedesign(sedesign);
title(main="plot_sedesign(sedesign)\noutput:")

Data normalization

SummarizedExperiment objects are normalized using:

Normalization can be reviewed with MA-plots, recommended by using jamma::jammaplot(). See Github repository "jmw86069/jamma".

Statistical comparisons

se_contrast_stats() is the central function

Heatmaps

heatmap_se() is a wrapper for the amazing ComplexHeatmap::Heatmap(), intended to automate frequently-used options that represent repetitive work.

Common rules:

Common arguments:

Future work:



jmw86069/jamses documentation built on Nov. 4, 2024, 9:25 p.m.