Title: | R for High-Dimensional Omic Data |
---|---|
Description: | Represents high-dimensional data as tables of features, samples and measurements, and a design list for tracking the meaning of individual variables. Using this format, filtering, normalization, and other transformations of a dataset can be carried out in a flexible manner. 'romic' takes advantage of these transformations to create interactive 'shiny' apps for exploratory data analysis such as an interactive heatmap. |
Authors: | Sean Hackett [aut, cre]
|
Maintainer: | Sean Hackett <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.1.3 |
Built: | 2025-02-12 05:12:19 UTC |
Source: | https://github.com/cran/romic |
Add Principal Components Analysis Loadings to a tidy or triple omics dataset.
add_pcs( tomic, value_var = NULL, center_rows = TRUE, npcs = NULL, missing_val_method = "drop_samples", label_percent_varex = TRUE, verbose = TRUE )
add_pcs( tomic, value_var = NULL, center_rows = TRUE, npcs = NULL, missing_val_method = "drop_samples", label_percent_varex = TRUE, verbose = TRUE )
tomic |
Either a |
value_var |
An abundance value to use with |
center_rows |
center rows before performing PCA |
npcs |
number of principal component loadings to add to samples (default is number of samples) |
missing_val_method |
Approach to remove missing values:
|
label_percent_varex |
If true then PCs will be labelled by the percent of variability they explain. |
verbose |
extra reporting messages |
A tomic
object with principal components added to samples.
add_pcs(brauer_2008_triple, npcs = 5)
add_pcs(brauer_2008_triple, npcs = 5)
Using shiny
comb through datasets by iterating between
plotting steps, and lassoing steps to select points of interest.
app_flow(tomic)
app_flow(tomic)
tomic |
Either a |
A shiny
app
if (interactive()) { # library(reactlog) # reactlog_enable() app_flow(brauer_2008_triple) # shiny::reactlogShow() }
if (interactive()) { # library(reactlog) # reactlog_enable() app_flow(brauer_2008_triple) # shiny::reactlogShow() }
Generate a shiny
interactive heatmap that allows for on demand
filtering, ordering and faceting by variables of interest.
app_heatmap(tomic)
app_heatmap(tomic)
tomic |
Either a |
A shiny
app
if (interactive()) { app_heatmap(brauer_2008_tidy) }
if (interactive()) { app_heatmap(brauer_2008_tidy) }
Generate a Shiny interactive scatter plot which allows visualization of features, measurements, and samples (with principal components added).
app_pcs(tomic)
app_pcs(tomic)
tomic |
Either a |
A shiny
app
if (interactive()) { app_pcs(brauer_2008_tidy) }
if (interactive()) { app_pcs(brauer_2008_tidy) }
An RNA expression (microarray) dataset looking at how yeast gene expression changes as nutrient sources and nutrient richness changes.
brauer_2008
formatted as a tidy_omic object
brauer_2008
formatted as a triple_omic object
brauer_2008 brauer_2008_tidy brauer_2008_triple
brauer_2008 brauer_2008_tidy brauer_2008_triple
A tibble with 18,000 rows and 8 columns:
Common gene name
Gene ontology biological process of the gene
Gene ontology molecular function of the gene
Sample name
Which nutrient limits growth (Glucose, Nitrogen, Phosphorous, Sulfur, Uracil, Leucine
Dilution rate of the culture - basically how fast the cells are growing
Expression level of the gene, log2 observation relative to a replicate of G0.3
An object of class tidy_omic
(inherits from tomic
, general
) of length 2.
An object of class triple_omic
(inherits from tomic
, general
) of length 4.
This version of the dataset contains only 500 genes randomly selected from the ~6K genes in the complete dataset.
https://pubmed.ncbi.nlm.nih.gov/17959824/
Center each measurement by subtracting the mean.
center_tomic(tomic, measurement_vars = "all")
center_tomic(tomic, measurement_vars = "all")
tomic |
Either a |
measurement_vars |
measurement variables to center |
A tomic
object where one or more measurements have
been centered on a feature-by-feature basis.
center_tomic(brauer_2008_tidy)
center_tomic(brauer_2008_tidy)
Check a tidy omic dataset for consistency between the data and design and
validate that the dataset follows the tidy_omic
/tomic
specification.
check_tidy_omic(tidy_omic, fast_check = TRUE)
check_tidy_omic(tidy_omic, fast_check = TRUE)
tidy_omic |
an object of class tidy_omic produced by
|
fast_check |
if TRUE then skip some checks which are slow and that are
generally only needed when a |
0 invisibly
Check a tidy or triple 'omic object for common pathologies, such as a mismatch between data and schema and non-uniqueness of primary keys.
check_tomic(tomic, fast_check = TRUE)
check_tomic(tomic, fast_check = TRUE)
tomic |
Either a |
fast_check |
if TRUE then skip some checks which are slow and that are
generally only needed when a |
0 invisibly
check_tomic(brauer_2008_triple)
check_tomic(brauer_2008_triple)
Check a triple omic dataset for consistency between the data and design and
validate that the dataset follows the triple_omic
/tomic
specification.
check_triple_omic(triple_omic, fast_check = TRUE)
check_triple_omic(triple_omic, fast_check = TRUE)
triple_omic |
an object of class triple_omic produced by
|
fast_check |
if TRUE then skip some checks which are slow and that are
generally only needed when a |
0 invisibly
Convert a wide dataset of species' abundances (gene product, metabolites, lipids, ...) into a triple_omic dataset (one observation per row)
convert_wide_to_tidy_omic( wide_df, feature_pk, feature_vars = NULL, sample_var = "sample", measurement_var = "abundance", omic_type_tag = "general", verbose = TRUE )
convert_wide_to_tidy_omic( wide_df, feature_pk, feature_vars = NULL, sample_var = "sample", measurement_var = "abundance", omic_type_tag = "general", verbose = TRUE )
wide_df |
a data.frame (or tibble) containing 1+ columns of feature attributes and many columns of samples |
feature_pk |
A unique identifier for features |
feature_vars |
a character vector of additional feature-level variables (or NULL if there are no additional variables) |
sample_var |
variable name to use for samples |
measurement_var |
variable name to use for measurements |
omic_type_tag |
an optional subtype of omic data: metabolomics, lipidomics, proteomics, genomics, general |
verbose |
extra reporting messages |
A tidy_omic
object as produced by create_tidy_omic
.
library(dplyr) wide_measurements <- brauer_2008_triple[["measurements"]] %>% tidyr::spread(sample, expression) wide_df <- brauer_2008_triple[["features"]] %>% left_join(wide_measurements, by = "name") convert_wide_to_tidy_omic(wide_df, feature_pk = "name", feature_vars = c("BP", "MF", "systematic_name") )
library(dplyr) wide_measurements <- brauer_2008_triple[["measurements"]] %>% tidyr::spread(sample, expression) wide_df <- brauer_2008_triple[["features"]] %>% left_join(wide_measurements, by = "name") convert_wide_to_tidy_omic(wide_df, feature_pk = "name", feature_vars = c("BP", "MF", "systematic_name") )
A tidy omics object contains a formatted dataset and a summary of the experimental design.
create_tidy_omic( df, feature_pk, feature_vars = NULL, sample_pk, sample_vars = NULL, omic_type_tag = "general", verbose = TRUE )
create_tidy_omic( df, feature_pk, feature_vars = NULL, sample_pk, sample_vars = NULL, omic_type_tag = "general", verbose = TRUE )
df |
a data.frame (or tibble) containing some combination of feature, sample and observation-level variables |
feature_pk |
A unique identifier for features |
feature_vars |
a character vector of additional feature-level variables (or NULL if there are no additional variables) |
sample_pk |
A unique identifier for samples |
sample_vars |
a character vector of additional sample-level variables (or NULL if there are no additional variables) |
omic_type_tag |
an optional subtype of omic data: metabolomics, lipidomics, proteomics, genomics, general |
verbose |
extra reporting messages |
An S3 tidy_omic
/tomic
object built on a list
:
A tibble with one row per measurement (i.e., features x samples)
A list which organized the dataset's meta-data:
variable specifying a unique feature
variable specifying a unique sample
tibble of feature attributes
tibble of sample attributes
tibble of measurement attributes
library(dplyr) measurement_df <- tidyr::expand_grid( feature_id = 1:10, sample_id = LETTERS[1:5] ) %>% dplyr::mutate(value = rnorm(n())) feature_df <- tibble( feature_id = 1:10, feature_group = rep(c("a", "b"), each = 5) ) sample_df <- tibble( sample_id = LETTERS[1:5], sample_group = c("a", "a", "b", "b", "b") ) triple_omic <- create_triple_omic( measurement_df, feature_df, sample_df, "feature_id", "sample_id" ) raw_tidy_omic <- triple_to_tidy(triple_omic)$data create_tidy_omic(raw_tidy_omic, feature_pk = "feature_id", feature_vars = "feature_group", sample_pk = "sample_id", sample_vars = "sample_group" )
library(dplyr) measurement_df <- tidyr::expand_grid( feature_id = 1:10, sample_id = LETTERS[1:5] ) %>% dplyr::mutate(value = rnorm(n())) feature_df <- tibble( feature_id = 1:10, feature_group = rep(c("a", "b"), each = 5) ) sample_df <- tibble( sample_id = LETTERS[1:5], sample_group = c("a", "a", "b", "b", "b") ) triple_omic <- create_triple_omic( measurement_df, feature_df, sample_df, "feature_id", "sample_id" ) raw_tidy_omic <- triple_to_tidy(triple_omic)$data create_tidy_omic(raw_tidy_omic, feature_pk = "feature_id", feature_vars = "feature_group", sample_pk = "sample_id", sample_vars = "sample_group" )
A triple omics class contains three data.frames, one for features, one for samples, and one for abundances. This is a good format when there is a large amount of meta data associated with features or samples.
create_triple_omic( measurement_df, feature_df = NULL, sample_df = NULL, feature_pk, sample_pk, omic_type_tag = "general" )
create_triple_omic( measurement_df, feature_df = NULL, sample_df = NULL, feature_pk, sample_pk, omic_type_tag = "general" )
measurement_df |
A data.frame (or tibble) of measurements - one row for each combination of feature and sample |
feature_df |
A data.frame (or tibble) of features - one row per feature |
sample_df |
A data.frame (or tibble) of samples - one row per sample |
feature_pk |
A unique identifier for features |
sample_pk |
A unique identifier for samples |
omic_type_tag |
an optional subtype of omic data: metabolomics, lipidomics, proteomics, genomics, general |
for now primary keys are unique (rather than allowing for a multi-index)
An S3 triple_omic
/tomic
object built on a list
:
A tibble of feature meta-data (one row per feature)
A tibble of sample meta-data (one row per sample)
A tibble with one row per measurement (i.e., features x samples)
A list which organized the dataset's meta-data:
variable specifying a unique feature
variable specifying a unique sample
tibble of feature attributes
tibble of sample attributes
tibble of measurement attributes
library(dplyr) measurement_df <- tidyr::expand_grid( feature_id = 1:10, sample_id = LETTERS[1:5] ) %>% dplyr::mutate(value = rnorm(n())) feature_df <- tibble( feature_id = 1:10, feature_group = rep(c("a", "b"), each = 5) ) sample_df <- tibble( sample_id = LETTERS[1:5], sample_group = c("a", "a", "b", "b", "b") ) triple_omic <- create_triple_omic( measurement_df, feature_df, sample_df, "feature_id", "sample_id" )
library(dplyr) measurement_df <- tidyr::expand_grid( feature_id = 1:10, sample_id = LETTERS[1:5] ) %>% dplyr::mutate(value = rnorm(n())) feature_df <- tibble( feature_id = 1:10, feature_group = rep(c("a", "b"), each = 5) ) sample_df <- tibble( sample_id = LETTERS[1:5], sample_group = c("a", "a", "b", "b", "b") ) triple_omic <- create_triple_omic( measurement_df, feature_df, sample_df, "feature_id", "sample_id" )
Combine rows to speed up rendering of large heatmaps
downsample_heatmap( tidy_data, value_var, design, max_display_features = 1000, verbose = TRUE )
downsample_heatmap( tidy_data, value_var, design, max_display_features = 1000, verbose = TRUE )
tidy_data |
The data frame from a |
value_var |
which variable in "measurements" to use for quantification. |
design |
a list summarizing the design of the tidy dataset |
max_display_features |
aggregate and downsample distinct feature to this number to speed to up heatmap rendering. |
verbose |
extra reporting messages |
tidy_data with rows collapsed if the number of distinct features is
greater than max_display_features
Export a data table including all fields from features, samples and measurements.
export_tomic_as_tidy(tomic, dir_path, name_preamble, verbose = TRUE)
export_tomic_as_tidy(tomic, dir_path, name_preamble, verbose = TRUE)
tomic |
Either a |
dir_path |
path to save outputs |
name_preamble |
start of output file name |
verbose |
extra reporting messages |
Export one table which is one row per peak, which includes all feature and sample attributes.
if (interactive()) { export_tomic_as_tidy(brauer_2008_triple, "/tmp", "brauer") }
if (interactive()) { export_tomic_as_tidy(brauer_2008_triple, "/tmp", "brauer") }
Export features, samples and measurements tables
export_tomic_as_triple(tomic, dir_path, name_preamble, verbose = TRUE)
export_tomic_as_triple(tomic, dir_path, name_preamble, verbose = TRUE)
tomic |
Either a |
dir_path |
path to save outputs |
name_preamble |
start of output file name |
verbose |
extra reporting messages |
Export three tables:
features: one row per features measured (i.e., a metabolite)
sample: one row per sample
measurements: one row per measurement (i.e., one metabolite in one sample)
if (interactive()) { export_tomic_as_triple(brauer_2008_triple, "/tmp", "brauer") }
if (interactive()) { export_tomic_as_triple(brauer_2008_triple, "/tmp", "brauer") }
abundances form a matrix with metabolites as rows and samples as columns. Use transpose to treat samples as rows filename
export_tomic_as_wide( tomic, dir_path, name_preamble, value_var = NULL, transpose = FALSE, verbose = TRUE )
export_tomic_as_wide( tomic, dir_path, name_preamble, value_var = NULL, transpose = FALSE, verbose = TRUE )
tomic |
Either a |
dir_path |
path to save outputs |
name_preamble |
start of output file name |
value_var |
measurement variable to use for the matrix |
transpose |
if TRUE then samples will be stored as rows |
verbose |
extra reporting messages |
Export one table which contains metabolites as rows and samples as columns.
if (interactive()) { export_tomic_as_wide(brauer_2008_triple, "/tmp", "brauer") }
if (interactive()) { export_tomic_as_wide(brauer_2008_triple, "/tmp", "brauer") }
Filter a tidy or triple omic to entries of interest.
filter_tomic( tomic, filter_type, filter_table, filter_value, filter_variable = NULL )
filter_tomic( tomic, filter_type, filter_table, filter_value, filter_variable = NULL )
tomic |
Either a |
filter_type |
|
filter_table |
table where the filter should be applied |
filter_value |
values to filter based on |
filter_variable |
variable to apply the filter to |
A tomic
object where a subset of features, samples or
measurmenets have been filtered.
filter_tomic( brauer_2008_triple, filter_type = "category", filter_table = "features", filter_variable = "BP", filter_value = c("biological process unknown", "vacuolar acidification") ) filter_tomic( brauer_2008_triple, filter_type = "category", filter_table = "samples", filter_variable = "DR", filter_value = 0.05 ) filter_tomic( brauer_2008_tidy, filter_type = "range", filter_table = "samples", filter_variable = "DR", filter_value = c(0, 0.2) ) filter_tomic( brauer_2008_triple, filter_type = "quo", filter_table = "features", filter_value = rlang::quo(BP == "biological process unknown") )
filter_tomic( brauer_2008_triple, filter_type = "category", filter_table = "features", filter_variable = "BP", filter_value = c("biological process unknown", "vacuolar acidification") ) filter_tomic( brauer_2008_triple, filter_type = "category", filter_table = "samples", filter_variable = "DR", filter_value = 0.05 ) filter_tomic( brauer_2008_tidy, filter_type = "range", filter_table = "samples", filter_variable = "DR", filter_value = c(0, 0.2) ) filter_tomic( brauer_2008_triple, filter_type = "quo", filter_table = "features", filter_value = rlang::quo(BP == "biological process unknown") )
UI components for the filter module.
filterInput(id, filter_table)
filterInput(id, filter_table)
id |
An ID string that corresponds with the ID used to call the module's UI function. |
filter_table |
table to filter |
A shiny
UI
Server components for the filter module.
filterServer(id, tidy_omic, filter_table)
filterServer(id, tidy_omic, filter_table)
id |
An ID string that corresponds with the ID used to call the module's UI function. |
tidy_omic |
an object of class tidy_omic produced by
|
filter_table |
table to filter |
A tidy_omic
with some features and/or samples filtered.
Wrap long names over multiple lines so that they will look better on plots.
format_names_for_plotting(chars, width = 40, truncate_at = 80)
format_names_for_plotting(chars, width = 40, truncate_at = 80)
chars |
a character vector (or a variable that can be converted to one) |
width |
Positive integer giving target line width (in number of characters). A width less than or equal to 1 will put each word on its own line. |
truncate_at |
max character length |
a reformatted character vector of the same length as the input.
chars <- "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer ac arcu semper erat porttitor egestas. Etiam sagittis, sapien at mattis." format_names_for_plotting(chars)
chars <- "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer ac arcu semper erat porttitor egestas. Etiam sagittis, sapien at mattis." format_names_for_plotting(chars)
Get a tabular summary of all variables.
get_design_tbl(tomic)
get_design_tbl(tomic)
tomic |
Either a |
a tibble reflecting the tomic
object's design.
get_design_tbl(brauer_2008_triple)
get_design_tbl(brauer_2008_triple)
Extract one of the specific tables from a tomic object
get_tomic_table(tomic, table_type)
get_tomic_table(tomic, table_type)
tomic |
Either a |
table_type |
The type of table to extract from the
|
a tibble matching the table_type
of the tomic
object
get_tomic_table(brauer_2008_triple, "samples") get_tomic_table(brauer_2008_tidy, "features")
get_tomic_table(brauer_2008_triple, "samples") get_tomic_table(brauer_2008_tidy, "features")
UI components for the ggBivariate module.
ggBivOutput(id, return_brushed_points = FALSE)
ggBivOutput(id, return_brushed_points = FALSE)
id |
An ID string that corresponds with the ID used to call the module's UI function. |
return_brushed_points |
Return values selected on the plot |
A shiny
UI
Server components for the ggBivariate module.
ggBivServer(id, tomic, plot_table, return_brushed_points = FALSE)
ggBivServer(id, tomic, plot_table, return_brushed_points = FALSE)
id |
An ID string that corresponds with the ID used to call the module's UI function. |
tomic |
Either a |
plot_table |
table containing the data to be plotted |
return_brushed_points |
Return values selected on the plot |
a tomic_table if return_brushed_points is TRUE, and 0 otherwise
UI components for the ggplot module.
ggplotOutput( id, default_data_type = "samples", default_plot_type = "univariate" )
ggplotOutput( id, default_data_type = "samples", default_plot_type = "univariate" )
id |
An ID string that corresponds with the ID used to call the module's UI function. |
default_data_type |
Default data type selection |
default_plot_type |
Default plot type selection |
A shiny
UI
Server components for the ggplot module.
ggplotServer(id, tomic, return_brushed_points = FALSE)
ggplotServer(id, tomic, return_brushed_points = FALSE)
id |
An ID string that corresponds with the ID used to call the module's UI function. |
tomic |
Either a |
return_brushed_points |
Return values selected on the plot |
a tibble
of selected observations if
return_brushed_points
is TRUE. Otherwise, returns NULL.
UI components for the ggUnivariate module.
ggUnivOutput(id, return_brushed_points = FALSE)
ggUnivOutput(id, return_brushed_points = FALSE)
id |
An ID string that corresponds with the ID used to call the module's UI function. |
return_brushed_points |
Return values selected on the plot |
A shiny
UI
Server components for the ggUnivariate module
ggUnivServer(id, tomic, plot_table, return_brushed_points = FALSE)
ggUnivServer(id, tomic, plot_table, return_brushed_points = FALSE)
id |
An ID string that corresponds with the ID used to call the module's UI function. |
tomic |
Either a |
plot_table |
table containing the data to be plotted |
return_brushed_points |
Return values selected on the plot |
a tomic_table if return_brushed_points is TRUE, and 0 otherwise.
Format and hierarchically cluster a data.frame. If hclust could not normally be produced (usually because no samples are in common for a feature) pad the matrix with zeros and still calculate the distance
hclust_order( df, feature_pk, sample_pk, value_var, cluster_dim, distance_measure = "dist", hclust_method = "ward.D2" )
hclust_order( df, feature_pk, sample_pk, value_var, cluster_dim, distance_measure = "dist", hclust_method = "ward.D2" )
df |
data.frame to cluster |
feature_pk |
variable uniquely defining a row |
sample_pk |
variable uniquely defining a sample |
value_var |
An abundance value to use with |
cluster_dim |
rows, columns, or both |
distance_measure |
variable to use for computing dis-similarity
|
hclust_method |
method from stats::hclust to use for clustering |
a list containing a hierarchically clustered set of rows and/or columns
library(dplyr) df <- tidyr::crossing(letters = LETTERS, numbers = 1:10) %>% mutate(noise = rnorm(n())) hclust_order(df, "letters", "numbers", "noise", "rows")
library(dplyr) df <- tidyr::crossing(letters = LETTERS, numbers = 1:10) %>% mutate(noise = rnorm(n())) hclust_order(df, "letters", "numbers", "noise", "rows")
Impute missing values using K-nearest neighbors imputation
impute_missing_values( tomic, impute_var_name = "imputed", value_var = NULL, ... )
impute_missing_values( tomic, impute_var_name = "imputed", value_var = NULL, ... )
tomic |
Either a |
impute_var_name |
variable to create for imputed measurements |
value_var |
An abundance value to use with |
... |
additional arguments to pass to impute.knn |
A tomic
object with imputed measurements.
impute_missing_values(brauer_2008_triple)
impute_missing_values(brauer_2008_triple)
From a tomic_table, choose whether it reflects features, samples or measurements
infer_tomic_table_type(tomic, tomic_table)
infer_tomic_table_type(tomic, tomic_table)
tomic |
Either a |
tomic_table |
A table taken from a tidy (i.e., augmented measurements) or triple omic dataset |
features, samples or measurements
UI components for the lasso module.
lassoInput(id)
lassoInput(id)
id |
An ID string that corresponds with the ID used to call the module's UI function. |
A shiny
UI
Take a subset of entries from a tomic table (generally selected using the lasso function) and then either filter a tomic object to these entries or tag the entries of interest with a user-specified variable.
lassoServer(id, tomic, tomic_table)
lassoServer(id, tomic, tomic_table)
id |
An ID string that corresponds with the ID used to call the module's UI function. |
tomic |
Either a |
tomic_table |
A table taken from a tidy (i.e., augmented measurements) or triple omic dataset |
A tomic
object amended based on the lasso selection.
UI components for the organize input module.
organizeInput(id)
organizeInput(id)
id |
An ID string that corresponds with the ID used to call the module's UI function. |
A shiny
UI
Server components for the organize input module.
organizeServer(id, tidy_omic, feature_vars, sample_vars, value_var)
organizeServer(id, tidy_omic, feature_vars, sample_vars, value_var)
id |
An ID string that corresponds with the ID used to call the module's UI function. |
tidy_omic |
an object of class tidy_omic produced by
|
feature_vars |
variables available for arranging features |
sample_vars |
variables available for arrange samples |
value_var |
An abundance value to use with |
A tomic
with sorted features and/or samples.
Create a scatter or boxplot from a tomic dataset.
plot_bivariate( tomic_table, x_var, y_var, color_var = NULL, shape_var = NULL, alpha_var = NULL, size_var = NULL )
plot_bivariate( tomic_table, x_var, y_var, color_var = NULL, shape_var = NULL, alpha_var = NULL, size_var = NULL )
tomic_table |
A table taken from a tidy (i.e., augmented measurements) or triple omic dataset |
x_var |
x-axis variable |
y_var |
y-axis variable |
color_var |
coloring variable (NULL to suppress coloring) |
shape_var |
shape variable (NULL to suppress shape) |
alpha_var |
alpha variable or numeric for constant alpha (NULL to suppress alpha) |
size_var |
size variable or integer/numeric for constant size (NULL to suppress size) |
a ggplot2 grob
library(dplyr) brauer_augmented <- brauer_2008_tidy %>% add_pcs(npcs = 5) %>% tomic_to("triple_omic") tomic_table <- brauer_augmented$samples plot_bivariate(tomic_table, "PC1", "PC2", "nutrient", "nutrient", 0.5, 10) plot_bivariate(tomic_table, "PC1", "PC2", NULL) plot_bivariate(tomic_table, "nutrient", "PC2", "nutrient")
library(dplyr) brauer_augmented <- brauer_2008_tidy %>% add_pcs(npcs = 5) %>% tomic_to("triple_omic") tomic_table <- brauer_augmented$samples plot_bivariate(tomic_table, "PC1", "PC2", "nutrient", "nutrient", 0.5, 10) plot_bivariate(tomic_table, "PC1", "PC2", NULL) plot_bivariate(tomic_table, "nutrient", "PC2", "nutrient")
Generate a heatmap visualization of a features x samples matrix of measurements.
plot_heatmap( tomic, feature_var = NULL, sample_var = NULL, value_var = NULL, cluster_dim = "both", distance_measure = "dist", hclust_method = "ward.D2", change_threshold = Inf, plot_type = "grob", max_display_features = 800, x_label = NULL, y_label = NULL, colorbar_label = NULL )
plot_heatmap( tomic, feature_var = NULL, sample_var = NULL, value_var = NULL, cluster_dim = "both", distance_measure = "dist", hclust_method = "ward.D2", change_threshold = Inf, plot_type = "grob", max_display_features = 800, x_label = NULL, y_label = NULL, colorbar_label = NULL )
tomic |
Either a |
feature_var |
variable from "features" to use as a unique feature label. |
sample_var |
variable from "samples" to use as a unique sample label. |
value_var |
which variable in "measurements" to use for quantification. |
cluster_dim |
rows, columns, or both |
distance_measure |
variable to use for computing dis-similarity
|
hclust_method |
method from stats::hclust to use for clustering |
change_threshold |
values with a more extreme absolute change will be thresholded to this value. |
plot_type |
plotly (for interactivity) or grob (for a static ggplot) |
max_display_features |
aggregate and downsample distinct feature to this number to speed to up heatmap rendering. |
x_label |
label for x-axis (if NULL then use |
y_label |
label for y-axis (if NULL then use |
colorbar_label |
label for color-bar; default is log2 abundance |
a ggplot2 grob
library(dplyr) tomic <- brauer_2008_triple %>% filter_tomic( filter_type = "category", filter_table = "features", filter_variable = "BP", filter_value = c( "protein biosynthesis", "rRNA processing", "response to stress" ) ) plot_heatmap( tomic = tomic, value_var = "expression", change_threshold = 5, cluster_dim = "rows", plot_type = "grob", distance_measure = "corr" )
library(dplyr) tomic <- brauer_2008_triple %>% filter_tomic( filter_type = "category", filter_table = "features", filter_variable = "BP", filter_value = c( "protein biosynthesis", "rRNA processing", "response to stress" ) ) plot_heatmap( tomic = tomic, value_var = "expression", change_threshold = 5, cluster_dim = "rows", plot_type = "grob", distance_measure = "corr" )
Create a histogram from a tomic dataset.
plot_univariate(tomic_table, x_var, color_var = NULL)
plot_univariate(tomic_table, x_var, color_var = NULL)
tomic_table |
A table taken from a tidy (i.e., augmented measurements) or triple omic dataset |
x_var |
x-axis variable |
color_var |
coloring variable (NULL to suppress coloring) |
A ggplot2 grob
library(dplyr) brauer_augmented <- brauer_2008_tidy %>% add_pcs(npcs = 5) %>% tomic_to("triple_omic") plot_univariate(brauer_augmented$samples, "PC1", "nutrient") plot_univariate(brauer_augmented$measurements, "expression", NULL)
library(dplyr) brauer_augmented <- brauer_2008_tidy %>% add_pcs(npcs = 5) %>% tomic_to("triple_omic") plot_univariate(brauer_augmented$samples, "PC1", "nutrient") plot_univariate(brauer_augmented$measurements, "expression", NULL)
UI components for the plot saver module.
plotsaverInput(id, ui_format = "tall")
plotsaverInput(id, ui_format = "tall")
id |
An ID string that corresponds with the ID used to call the module's UI function. |
ui_format |
Set UI appearance
|
a shiny
UI
Server components for the plot saver module.
plotsaverServer(id, grob, filename = "grob.png")
plotsaverServer(id, grob, filename = "grob.png")
id |
An ID string that corresponds with the ID used to call the module's UI function. |
grob |
a ggplot2 plot |
filename |
filename for saving plot. The extension will be respected by ggsave. |
None
Format example datasets and add them to the package.
prepare_example_datasets(seed = 1234)
prepare_example_datasets(seed = 1234)
seed |
a seed value used to reproducibly sample random genes. |
None; used for side-effects.
If some samples, feature or measurements have been dropped; update other tables.
reconcile_triple_omic(triple_omic)
reconcile_triple_omic(triple_omic)
triple_omic |
an object of class triple_omic produced by
|
a triple_omic object
Account for missing values by dropping features, samples or using imputation.
remove_missing_values( tomic, value_var = NULL, missing_val_method = "drop_samples", verbose = TRUE )
remove_missing_values( tomic, value_var = NULL, missing_val_method = "drop_samples", verbose = TRUE )
tomic |
Either a |
value_var |
An abundance value to use with |
missing_val_method |
Approach to remove missing values:
|
verbose |
extra reporting messages |
A tomic
object where missing values have been accounted
for.
remove_missing_values(brauer_2008_triple)
remove_missing_values(brauer_2008_triple)
Tests the shiny filter module as a stand-alone application.
shiny_filter_test(tidy_omic, filter_table = "features")
shiny_filter_test(tidy_omic, filter_table = "features")
tidy_omic |
an object of class tidy_omic produced by
|
filter_table |
table to filter |
A shiny
app
if (interactive()) { shiny_filter_test(brauer_2008_tidy) }
if (interactive()) { shiny_filter_test(brauer_2008_tidy) }
Test the shiny ggBivariate module as a stand-alone application.
shiny_ggbiv_test(tomic, plot_table = "samples")
shiny_ggbiv_test(tomic, plot_table = "samples")
tomic |
Either a |
plot_table |
table containing the data to be plotted |
a shiny
app
if (interactive()) { shiny_ggbiv_test( add_pcs(brauer_2008_triple, npcs = 5), plot_table = "samples" ) shiny_ggbiv_test( brauer_2008_triple, plot_table = "measurements" ) }
if (interactive()) { shiny_ggbiv_test( add_pcs(brauer_2008_triple, npcs = 5), plot_table = "samples" ) shiny_ggbiv_test( brauer_2008_triple, plot_table = "measurements" ) }
Test the shiny ggplot module as a stand-alone application.
shiny_ggplot_test(tomic)
shiny_ggplot_test(tomic)
tomic |
Either a |
A shiny
app
if (interactive()) { shiny_ggplot_test(add_pcs(brauer_2008_triple, npcs = 5)) shiny_ggplot_test(brauer_2008_triple) }
if (interactive()) { shiny_ggplot_test(add_pcs(brauer_2008_triple, npcs = 5)) shiny_ggplot_test(brauer_2008_triple) }
Test the shiny ggUnivariate module as a stand-alone application.
shiny_gguniv_test(tomic, plot_table = "samples")
shiny_gguniv_test(tomic, plot_table = "samples")
tomic |
Either a |
plot_table |
table containing the data to be plotted |
A shiny
app
if (interactive()) { shiny_gguniv_test( add_pcs(brauer_2008_triple, npcs = 5), plot_table = "samples" ) shiny_gguniv_test(brauer_2008_triple, plot_table = "measurements") shiny_gguniv_test(brauer_2008_triple, plot_table = "features") }
if (interactive()) { shiny_gguniv_test( add_pcs(brauer_2008_triple, npcs = 5), plot_table = "samples" ) shiny_gguniv_test(brauer_2008_triple, plot_table = "measurements") shiny_gguniv_test(brauer_2008_triple, plot_table = "features") }
Tests the shiny lasso module as a stand-alone application.
shiny_lasso_test(tomic, tomic_table)
shiny_lasso_test(tomic, tomic_table)
tomic |
Either a |
tomic_table |
A table taken from a tidy (i.e., augmented measurements) or triple omic dataset |
A shiny
app
if (interactive()) { tomic <- brauer_2008_triple tomic_table <- tomic[["samples"]] %>% dplyr::filter(nutrient == "G") shiny_lasso_test(tomic, tomic_table) }
if (interactive()) { tomic <- brauer_2008_triple tomic_table <- tomic[["samples"]] %>% dplyr::filter(nutrient == "G") shiny_lasso_test(tomic, tomic_table) }
Tests the shiny lasso module as a stand-alone application when the
tomic
is a reativeVal
.
shiny_lasso_test_reactval(tomic, tomic_table)
shiny_lasso_test_reactval(tomic, tomic_table)
tomic |
Either a |
tomic_table |
A table taken from a tidy (i.e., augmented measurements) or triple omic dataset |
A shiny
app
if (interactive()) { tomic <- brauer_2008_triple tomic_table <- tomic[["samples"]] %>% dplyr::filter(nutrient == "G") shiny_lasso_test_reactval(tomic, tomic_table) tomic_table <- tomic[["measurements"]] %>% dplyr::filter(expression < -3) shiny_lasso_test_reactval(tomic, tomic_table) }
if (interactive()) { tomic <- brauer_2008_triple tomic_table <- tomic[["samples"]] %>% dplyr::filter(nutrient == "G") shiny_lasso_test_reactval(tomic, tomic_table) tomic_table <- tomic[["measurements"]] %>% dplyr::filter(expression < -3) shiny_lasso_test_reactval(tomic, tomic_table) }
Tests the shiny organization module as stand-alone application.
shiny_organize_test(tidy_omic, feature_vars, sample_vars, value_var)
shiny_organize_test(tidy_omic, feature_vars, sample_vars, value_var)
tidy_omic |
an object of class tidy_omic produced by
|
feature_vars |
variables available for arranging features |
sample_vars |
variables available for arrange samples |
value_var |
An abundance value to use with |
a shiny
app
if (interactive()) { shiny_organize_test( brauer_2008_tidy, feature_vars = c("BP", "MF"), sample_vars = c("sample", "nutrient", "DR"), value_var = "expression" ) }
if (interactive()) { shiny_organize_test( brauer_2008_tidy, feature_vars = c("BP", "MF"), sample_vars = c("sample", "nutrient", "DR"), value_var = "expression" ) }
Test the shiny plotsaver module as a stand-alone application.
shiny_plotsaver_test()
shiny_plotsaver_test()
a shiny
app
if (interactive()) { shiny_plotsaver_test() }
if (interactive()) { shiny_plotsaver_test() }
Test the shiny sorting module as a stand-alone app.
shiny_sort_test(triple_omic, valid_sort_vars, value_var)
shiny_sort_test(triple_omic, valid_sort_vars, value_var)
triple_omic |
an object of class triple_omic produced by
|
valid_sort_vars |
variables available for categorical arranging |
value_var |
An abundance value to use with |
a shiny
app
if (interactive()) { shiny_sort_test(brauer_2008_triple, valid_sort_vars = c("sample", "nutrient", "DR"), value_var = "expression" ) }
if (interactive()) { shiny_sort_test(brauer_2008_triple, valid_sort_vars = c("sample", "nutrient", "DR"), value_var = "expression" ) }
Sort a dataset's features or samples
sort_tomic( tomic, sort_type, sort_table, sort_variables = NULL, value_var = NULL )
sort_tomic( tomic, sort_type, sort_table, sort_variables = NULL, value_var = NULL )
tomic |
Either a |
sort_type |
|
sort_table |
samples or features |
sort_variables |
A set of attributes in sort_table to sort with in
|
value_var |
An abundance value to use with |
sort_tomic
supports the reordering of features or samples using
either hierarchical clustering or based on the levels of other variables.
Sorting occurs by turning either the feature or sample primary key
into a factor whose levels reflect the sort.
A tomic
object where feature or sample primary keys have
been turned into a factor reflecting how they are sorted.
library(dplyr) sort_tomic(brauer_2008_triple, sort_type = "arrange", sort_table = "samples", sort_variables = c("nutrient", "DR") ) %>% sort_tomic( sort_type = "hclust", sort_table = "features", value_var = "expression" )
library(dplyr) sort_tomic(brauer_2008_triple, sort_type = "arrange", sort_table = "samples", sort_variables = c("nutrient", "DR") ) %>% sort_tomic( sort_type = "hclust", sort_table = "features", value_var = "expression" )
Sort a triple_omic
object based on the values of one or more
variables.
sort_triple_arrange(triple_omic, sort_table, sort_variables)
sort_triple_arrange(triple_omic, sort_table, sort_variables)
triple_omic |
an object of class triple_omic produced by
|
sort_table |
samples or features |
sort_variables |
A set of attributes in sort_table to sort with in
|
A triple_omic
with sorted features or samples.
Sort a triple_omic
object using hierarchical clustering
sort_triple_hclust(triple_omic, sort_table, value_var)
sort_triple_hclust(triple_omic, sort_table, value_var)
triple_omic |
an object of class triple_omic produced by
|
sort_table |
samples or features |
value_var |
An abundance value to use with |
A triple_omic
with clustered features or samples.
UI components for the sort module.
sortInput(id, sort_table)
sortInput(id, sort_table)
id |
An ID string that corresponds with the ID used to call the module's UI function. |
sort_table |
table to sort |
A shiny
UI
Server components for the sort module.
sortServer(id, tomic, sort_table, valid_sort_vars = NULL, value_var = NULL)
sortServer(id, tomic, sort_table, valid_sort_vars = NULL, value_var = NULL)
id |
An ID string that corresponds with the ID used to call the module's UI function. |
tomic |
Either a |
sort_table |
samples or features |
valid_sort_vars |
variables available for categorical arranging |
value_var |
An abundance value to use with |
A sorted tomic
object.
Convert a tidy_omic
object into a triple_omic
object.
tidy_to_triple(tidy_omic)
tidy_to_triple(tidy_omic)
tidy_omic |
an object of class tidy_omic produced by
|
The data
table will be converted into features
,
samples
, and measurements
tables using the design
to determine which variables belong in each table. The design
will be preserved as-is.
A triple_omic
object as created by
create_triple_omic
tidy_to_triple(brauer_2008_tidy)
tidy_to_triple(brauer_2008_tidy)
Determine whether features &/or samples have been sorted and stored as ordered_featureId and ordered_sampleId.
tomic_sort_status(tomic)
tomic_sort_status(tomic)
tomic |
Either a |
length 1 character string indicating whether the tomic
is sorted.
tomic_sort_status(brauer_2008_tidy)
tomic_sort_status(brauer_2008_tidy)
Takes in any romic
reprsentation of a dataset and returns a specific
representation.
tomic_to(tomic, to_class)
tomic_to(tomic, to_class)
tomic |
Either a |
to_class |
The class to return, either |
tomic transformed to to_class
class (or un-transformed if
it started that way).
tomic_to(brauer_2008_tidy, "triple_omic")
tomic_to(brauer_2008_tidy, "triple_omic")
Convert a triple_omic
object into a tidy_omic
oobject.
triple_to_tidy(triple_omic)
triple_to_tidy(triple_omic)
triple_omic |
an object of class triple_omic produced by
|
Features, samples and measurements will be merged into a single data
table, and the design
will be preserved as-is.
A tidy_omic
object as created by
create_tidy_omic
.
library(dplyr) measurement_df <- tidyr::expand_grid( feature_id = 1:10, sample_id = LETTERS[1:5] ) %>% dplyr::mutate(value = rnorm(n())) feature_df <- tibble( feature_id = 1:10, feature_group = rep(c("a", "b"), each = 5) ) sample_df <- tibble( sample_id = LETTERS[1:5], sample_group = c("a", "a", "b", "b", "b") ) triple_omic <- create_triple_omic( measurement_df, feature_df, sample_df, "feature_id", "sample_id" ) triple_to_tidy(triple_omic)
library(dplyr) measurement_df <- tidyr::expand_grid( feature_id = 1:10, sample_id = LETTERS[1:5] ) %>% dplyr::mutate(value = rnorm(n())) feature_df <- tibble( feature_id = 1:10, feature_group = rep(c("a", "b"), each = 5) ) sample_df <- tibble( sample_id = LETTERS[1:5], sample_group = c("a", "a", "b", "b", "b") ) triple_omic <- create_triple_omic( measurement_df, feature_df, sample_df, "feature_id", "sample_id" ) triple_to_tidy(triple_omic)
This function wraps brushedPoints in a try statement to catch cases where the brushing is out-of-sync with the df that is selected.
try_brushedPoints(...)
try_brushedPoints(...)
... |
args to pass to brushedPoints |
a df of brushed points
Update a Tidy 'Omics data and schema to reflect newly added fields.
update_tidy_omic(tidy_omic, updated_tidy_data, new_variable_tables = c())
update_tidy_omic(tidy_omic, updated_tidy_data, new_variable_tables = c())
tidy_omic |
an object of class tidy_omic produced by
|
updated_tidy_data |
a tibble of data to use to update |
new_variable_tables |
a named character vector of newly added variables
in |
a tidy_omic
object with an updated schema and/or data.
library(dplyr) tidy_omic <- brauer_2008_tidy updated_tidy_data <- tidy_omic$data %>% mutate(new_sample_var = "foo") %>% select(-DR) new_variable_tables <- c("new_sample_var" = "samples")
library(dplyr) tidy_omic <- brauer_2008_tidy updated_tidy_data <- tidy_omic$data %>% mutate(new_sample_var = "foo") %>% select(-DR) new_variable_tables <- c("new_sample_var" = "samples")
Provide an updated features, samples or measurements table to a
tomic
.
update_tomic(tomic, tomic_table)
update_tomic(tomic, tomic_table)
tomic |
Either a |
tomic_table |
A table taken from a tidy (i.e., augmented measurements) or triple omic dataset |
A tomic
object with updated features, samples or measurements.
library(dplyr) updated_features <- brauer_2008_triple$features %>% dplyr::filter(BP == "biological process unknown") %>% dplyr::mutate(chromosome = purrr::map_int(systematic_name, function(x) { which(LETTERS == stringr::str_match(x, "Y([A-Z])")[2]) })) update_tomic(brauer_2008_triple, updated_features)
library(dplyr) updated_features <- brauer_2008_triple$features %>% dplyr::filter(BP == "biological process unknown") %>% dplyr::mutate(chromosome = purrr::map_int(systematic_name, function(x) { which(LETTERS == stringr::str_match(x, "Y([A-Z])")[2]) })) update_tomic(brauer_2008_triple, updated_features)
Partial string matching of a provided variable to the variables available in a table
var_partial_match(x, df)
var_partial_match(x, df)
x |
a variable name or regex match to a variable name |
df |
a data.frame or tibble |
a single variable from df