library(BiocStyle)
The r Rpackage("SEtools")
package is a set of convenience functions for the Bioconductor class r Biocpkg("SummarizedExperiment")
. It facilitates merging, melting, and plotting SummarizedExperiment
objects.
NOTE that the heatmap-related and melting functions have been moved to a standalone package, r Biocpkg("sechm")
.
The old sehm
function of SEtools
should be considered deprecated, and most SEtools
functions are conserved for legacy/reproducibility reasons (or until they find a better home).
if (!requireNamespace("BiocManager", quietly = TRUE)) install.packages("BiocManager") BiocManager::install("SEtools")
Or, to install the latest development version:
BiocManager::install("plger/SEtools")
To showcase the main functions, we will use an example object which contains (a subset of) whole-hippocampus RNAseq of mice after different stressors:
suppressPackageStartupMessages({ library(SummarizedExperiment) library(SEtools) }) data("SE", package="SEtools") SE
This is taken from Floriou-Servou et al., Biol Psychiatry 2018.
se1 <- SE[,1:10] se2 <- SE[,11:20] se3 <- mergeSEs( list(se1=se1, se2=se2) ) se3
All assays were merged, along with rowData and colData slots.
By default, row z-scores are calculated for each object when merging. This can be prevented with:
se3 <- mergeSEs( list(se1=se1, se2=se2), do.scale=FALSE)
If more than one assay is present, one can specify a different scaling behavior for each assay:
se3 <- mergeSEs( list(se1=se1, se2=se2), use.assays=c("counts", "logcpm"), do.scale=c(FALSE, TRUE))
Differences to the cbind
method include prefixes added to column names, optional scaling, handling of metadata (e.g. for sechm
)
It is also possible to merge by rowData columns, which are specified through the mergeBy
argument.
In this case, one can have one-to-many and many-to-many mappings, in which case two behaviors are possible:
aggFun
, the features of each object will by aggregated by mergeBy
using this function before merging.rowData(se1)$metafeature <- sample(LETTERS,nrow(se1),replace = TRUE) rowData(se2)$metafeature <- sample(LETTERS,nrow(se2),replace = TRUE) se3 <- mergeSEs( list(se1=se1, se2=se2), do.scale=FALSE, mergeBy="metafeature", aggFun=median) sechm::sechm(se3, features=row.names(se3))
A single SE can also be aggregated by using the aggSE
function:
se1b <- aggSE(se1, by = "metafeature") se1b
If the aggregation function(s) are not specified, aggSE
will try to guess decent aggregation functions from the assay names.
This is similar to scuttle::sumCountsAcrossFeatures
, but preserves other SE slots.
Calculate an assay of log-foldchanges to the controls:
SE <- log2FC(SE, fromAssay="logcpm", controls=SE$Condition=="Homecage")
sessionInfo()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.