Write all relevant preprocessing visualizations to pdf
Source:R/visualization_utils.R
visualizations.Rd
A wrapper around all the major visualization functions, used for visualizing data between major steps of data preprocessing. Saves all visualizations as PDFs with a set prefix on filenames.
Usage
visualizations(
object,
prefix,
format = "pdf",
perplexity = 30,
merge = FALSE,
remove_singles = FALSE,
group = NULL,
time = NULL,
id = NULL,
color = NULL,
assay.type = NULL
)
Arguments
- object
a
SummarizedExperiment
orMetaboSet
object- prefix
character, a file path prefix added to the file paths
- format
character, format in which the plots should be saved, DOES NOT support raster formats
- perplexity
perplexity for t-SNE plots
- merge
logical, whether the files should be merged to a single PDF, see Details
- remove_singles
logical, whether to remove single plot files after merging. Only used if
merge = TRUE
- group
character, name of pheno data column containing the group labels
- time
character, name of pheno data column containing timepoints
- id
character, name of pheno data column containing subject identifiers
- color
character, name of pheno data column used for coloring sample labels for dendrograms
- assay.type
character, assay to be used in case of multiple assays
Details
If merge
is TRUE
and format
is pdf
,
then a file containing all the visualizations named prefix.pdf
will
be created. NOTE: on Windows this requires installation of pdftk
(https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/)
and on Linux you need to have pdfunite installed. On MacOS, no external
software is needed. Note that at least on Windows, prefix should be a path
from the root, so that the underlying system command will find the files.
The type of visualizations to be saved depends on the type of object.
Here is a comprehensive list of the visualizations:
Distribution of quality metrics and flags
plot_quality
Boxplots of each sample in injection order
plot_sample_boxplots
PCA scores plot of samples colored by injection order
plot_pca
t-SNE plot of samples colored by injection order
plot_tsne
If the object has over 60 samples, hexbin versions of the PCA and t- SNE plots above
plot_pca_hexbin
,plot_tsne_hexbin
Dendrogram of samples ordered by hierarchical clustering, sample labels colored by group if present
plot_dendrogram
heat map of intersample distances, ordered by hierarchical clustering
plot_sample_heatmap
If the object has QC samples:
Density function of the intersample distances in both QCs and biological samples
plot_dist_density
Histograms of p-values from linear regression of features against injection order in both QCs and biological samples
plot_p_histogram
If the object has a group column:
If the object has a time column:
PCA and tSNE plots with points shaped and colored by time '
plot_pca
,plot_tsne
Dendrogram of samples ordered by hierarchical clustering, sample labels colored by time point
plot_dendrogram
If the object has a group column OR a time column:
Boxplots of samples ordered and colored by group and/or time
plot_sample_boxplots
If the object has a group column AND a time column:
If the object has a time column AND a subject column:
PCA and tSNE plots with arrows connecting the samples of each subject in time point order
plot_pca_arrows
,plot_tsne_arrows
Examples
data(example_set)
visualizations(example_set, prefix="figures/example_set", perplexity=5,
group = "Group", color = "Group", time = "Time",
id = "Subject_ID")
#> INFO [2025-06-23 22:38:34] Saved to: figures/example_set_density_plot.pdf
#> INFO [2025-06-23 22:38:34] Starting linear regression.
#> INFO [2025-06-23 22:38:35] Linear regression performed.
#> INFO [2025-06-23 22:38:35] Starting linear regression.
#> INFO [2025-06-23 22:38:36] Linear regression performed.
#> INFO [2025-06-23 22:38:36] Starting linear regression.
#> INFO [2025-06-23 22:38:36] Linear regression performed.
#> INFO [2025-06-23 22:38:37] Saved to: figures/example_set_lm_p_histograms.pdf
#>
#> Quality metrics not found, computing them now
#> INFO [2025-06-23 22:38:37] Saved to: figures/example_set_quality_metrics.pdf
#> INFO [2025-06-23 22:38:38] Saved to: figures/example_set_boxplots_injection.pdf
#> svd calculated PCA
#> Importance of component(s):
#> PC1 PC2
#> R2 0.2504 0.05641
#> Cumulative R2 0.2504 0.30681
#> INFO [2025-06-23 22:38:38] Saved to: figures/example_set_PCA_injection.pdf
#> INFO [2025-06-23 22:38:38] Saved to: figures/example_set_tSNE_injection.pdf
#> INFO [2025-06-23 22:38:38] Saved to: figures/example_set_dendrogram.pdf
#> INFO [2025-06-23 22:38:39] Saved to: figures/example_set_heatmap_samples.pdf
#> svd calculated PCA
#> Importance of component(s):
#> PC1 PC2
#> R2 0.2504 0.05641
#> Cumulative R2 0.2504 0.30681
#> INFO [2025-06-23 22:38:39] Saved to: figures/example_set_PCA_group.pdf
#> INFO [2025-06-23 22:38:39] Saved to: figures/example_set_tSNE_group.pdf
#> svd calculated PCA
#> Importance of component(s):
#> PC1 PC2
#> R2 0.2504 0.05641
#> Cumulative R2 0.2504 0.30681
#> INFO [2025-06-23 22:38:39] Saved to: figures/example_set_PCA_time.pdf
#> INFO [2025-06-23 22:38:39] Saved to: figures/example_set_tSNE_time.pdf
#> INFO [2025-06-23 22:38:39] Saved to: figures/example_set_dendrogram_time.pdf
#> INFO [2025-06-23 22:38:40] Saved to: figures/example_set_boxplots_group.pdf
#> svd calculated PCA
#> Importance of component(s):
#> PC1 PC2
#> R2 0.2504 0.05641
#> Cumulative R2 0.2504 0.30681
#> INFO [2025-06-23 22:38:40] Saved to: figures/example_set_PCA_group_time.pdf
#> INFO [2025-06-23 22:38:40] Saved to: figures/example_set_tSNE_group_time.pdf