knitr::opts_chunk$set(warning = FALSE, fig.width = 8, fig.height = 6)
options(rmarkdown.html_vignette.check_title = FALSE)
knitr::include_graphics("pmartR_logo_final.jpg")

library(pmartR)
library(pmartRdata)
library(ggplot2)

Overview

Graphs in pmartR are made with ggplot2 [@ggplot2], unless the interactive = TRUE argument in specified, in which case plots are generated using plotly [@plotly].

This vignette provides an overview of plot capabilities included in pmartR, describes the various arguments available in the plot functions, and the use of "custom sample names" for less cluttered graphs.

Plot functions are included for

Custom Sample Names

Sometimes the sample names in an experiment are sufficiently long that they make a plot unreadable. To assist the user in this situation, pmartR includes the ability to specify shorter sample names for use in plots only (e.g. the column names for each sample in e_data and the corresponding column in f_data remain unchanged).

Here we plot the metabData object from pmartRdata using the default sample names:

mymetab <- edata_transform(omicsData = metab_object, data_scale = "log2")
plot(mymetab, color_by = "Phenotype", order_by = "Phenotype")

If we would like shorter samples names so they don't take so much space on the graph, we can utilize the custom_sampnames function to shorten the existing sample names based on one of the following:

Examples of using each of these approaches can be found in the documentation ?custom_sampnames. Here we will use the delimeter approach. Note that there must be a unique custom sample name for each sample.

head(mymetab$f_data$SampleID)

# specify new names using delim and components arguments
mymetab_shorter_names <- custom_sampnames(omicsData = mymetab, delim = "_", components = c(1, 2))
plot(mymetab, use_VizSampNames = TRUE, color_by = "Phenotype", order_by = "Phenotype")

If we wish to obtain the plot using the original sample names, simply omit the use_VizSampNames argument to the plot function or set it to FALSE.

plot(mymetab, color_by = "Phenotype", order_by = "Phenotype")
plot(mymetab, use_VizSampNames = FALSE, color_by = "Phenotype", order_by = "Phenotype")

Common Arguments to pmartR Plot Functions

When appropriate for a given plot type, the following options are available to the user to further customize their visualizations:

Additional Plot Layers

Since pmartR utilizes ggplot2 for (non-interactive) graphs, additional plot layers can be added to pmartR plots. Note that adding plot layers may override some of the built-in pmartR plot functionality. In the example below, we see that adding theme_dark() changes the background color but also changes the orientation of the x-axis labels.

plot(mymetab, order_by = "Phenotype", color_by = "Phenotype") +
  theme_dark()

Plot Methods - Alphabetical

A number of S3 object classes are defined specifically for use in the pmartR package, and many of these have accompanying plot methods. The following list shows which objects have associated plot methods. For details, see the help pages using e.g. ?plot.corRes.

Plot Methods - Grouped by Type of S3 Data Object

Data Objects

Filters

EDA

Normalization

Statistics

References



pmartR/pmartR documentation built on May 5, 2024, 12:03 a.m.