Every figure the app makes, you can make in a few lines of R, and vice versa.
library(PlotTrellis)
proj <- pt_project(project_dir = "your-folder",
samples_txt = pt_example())
pt_tracks(proj) # the tracks it has
pt_samples(proj) # the samples it hasFor your own data, give your samples.txt path instead of
pt_example().
Tracks are drawn top to bottom, in the order given.
# every track for every sample, in samples.txt order
fig <- pt_figure(proj, "Eya2", tracks = c("ATAC", "genes"))
pt_save(fig, "Eya2.pdf") # or .svg, .pngOther alterations include:
# one sample
pt_figure(proj, "Eya2", tracks = c("ATAC", "genes"), samples = "LP")
# a sample per track (NA for a track without samples)
pt_figure(proj, "Eya2", tracks = c("HIC", "genes", "HIC", "genes"),
samples = c("LP", NA, "Basal", NA))
# LP compared against Basal; the second is the reference
pt_figure(proj, "Eya2", tracks = c("ATAC", "ATAC_diff", "genes"),
comparison = c("LP", "Basal"))
# grouped by sample instead of by track
pt_figure(proj, "Eya2", tracks = c("ATAC", "H3K36me3", "genes"),
order = "sample")
# any coordinates instead of a gene
pt_figure(proj, region = "chr2:165,430,000-165,620,000",
tracks = c("ATAC", "genes"))Numbers work instead of names
(tracks = c(6, 1), samples = 2), according to the order in
samples.txt visible through pt_tracks(proj)
and pt_samples(proj).
One file per gene:
# gene symbols, or Ensembl gene IDs with or without version
de_genes <- c("Eya2", "Acot7", "Cxcl14")
for (gene in de_genes) {
fig <- pt_figure(proj, gene, tracks = c("ATAC", "genes"),
title = gene)
pt_save(fig, paste0(gene, ".pdf"))
}All in one file, with pt_stitch():
# gene symbols, or Ensembl gene IDs with or without version
de_genes <- c("Eya2", "Acot7", "Cxcl14")
figs <- list()
for (gene in de_genes)
figs[[gene]] <- pt_figure(proj, gene, tracks = c("ATAC", "genes"),
title = gene)
pt_stitch(figs, "all_genes.pdf") # stacked
pt_stitch(figs, "all_genes_2col.pdf", ncol = 2) # two columnsNote: .pdf and .svg stay vector files, with
components and text you can edit in vector graphics editors
(e.g. Illustrator)
pt_grob() turns a figure into a grid grob, making it
compatible with patchwork, cowplot, gridExtra or beside your own ggplot
(e.g. a PCA, a volcano plot).
Adding a separate plot with patchwork:
pt_script(fig, "Eya2.R") writes a
standalone R script that redraws the figure with plotgardener, for edits
the API doesn’t offer:
render_<type>() function further down
(e.g. render_bw() for coverage). Edit that one.run_plottrellis(proj) opens the same
project in the app.