Saving TreeSummarizedExperiments to artifacts and back again
2026-10-29
1 Overview
The alabaster.treese package implements methods to save TreeSummarizedExperiment objects to file artifacts and load them back into R. It extends alabaster.sce, which handles everything from the SingleCellExperiment parent class. Check out the alabaster.base for more details on the motivation and concepts of the alabaster framework.
2 Quick start
Given a TreeSummarizedExperiment, we can use saveObject() to save it inside a staging directory:
# Mock up a TreeSE with a row tree and reference sequences.library(TreeSummarizedExperiment)data(tinyTree)mat <-matrix(rpois(100, 10), ncol =10)rownames(mat) <- tinyTree[["tip.label"]]colnames(mat) <- letters[1:10]tse <-TreeSummarizedExperiment(list(counts = mat), rowTree = tinyTree)tse[["stuff"]] <- LETTERS[1:10]referenceSeq(tse) <- Biostrings::DNAStringSet(rep("ACGT", nrow(tse)))tse
class: TreeSummarizedExperiment
dim: 10 10
metadata(0):
assays(1): counts
rownames(10): t2 t7 ... t5 t3
rowData names(0):
colnames(10): a b ... i j
colData names(1): stuff
reducedDimNames(0):
mainExpName: NULL
altExpNames(0):
rowLinks: a LinkDataFrame (10 rows)
rowTree: 1 phylo tree(s) (10 leaves)
colLinks: NULL
colTree: NULL
referenceSeq: a DNAStringSet (10 sequences)
# Save it into a staging directory.library(alabaster.treese)tmp <-tempfile()saveObject(tse, tmp)list.files(tmp, recursive =TRUE)
Each tree in rowTree() or colTree() is saved as a list containing the fields of its phylo object, with the edge matrix split into parent and child vectors. We do not use Newick as it does not preserve the node numbering (which is referenced by rowLinks() and colLinks()) or labels containing special characters. Users who need a Newick file for other tools can always create one with ape::write.tree(). The links themselves are saved as data frames, while the referenceSeq() is saved as FASTA via alabaster.string.