Additional figures

Replicate dispersion {.tabset}

The following figures illustrate reproducibility by comparing compound measures (e.g. concentration) within and between groups such as different sample types and conditions in study variables (as indicated with parameter study_variables).

This analysis is based on status-preprocessed dataset 3a.

# Select dataset
biocrates <- datasets$filter_compounds_by_sample_all_mv_kept
num_compounds <- biocrates %>% pull(Compound) %>% unique() %>% length()
num_columns <- 3
fig_height_dispersion <- ceiling(num_compounds/num_columns) * 1 + 1.5

Per sample type

# Illustrate concentrations in different sample types
plot_replicate_dispersion(bcdata = biocrates,
                          grouping = "Sample.Type",
                          color = "Sample.Type")

Per study variable {.tabset}

# Concentration dispersion plots over different study variable groups
disp_plots_fun <- function(var, data, info, parent = NULL, name){
  if (is.null(parent)){
    plot <- plot_replicate_dispersion(bcdata = data,
                                      sample_types = SAMPLE_TYPE_BIOLOGICAL,
                                      grouping = var,
                                      color = var)
  } else {
    plot <- plot_replicate_dispersion(bcdata = data,
                                      sample_types = SAMPLE_TYPE_BIOLOGICAL,
                                      grouping = var,
                                      color = parent)
  }

  return(list(
    Header = paste0("\n##### ", info, var, "\n"),
    Plot = plot))
}

if (length(STUDY_VARIABLES) > 0){
  var_plots <- recursive_execution(vars = STUDY_VARIABLES,
                                   end_fun = disp_plots_fun,
                                   data = biocrates,
                                   separate_parent = FALSE)
  for (var_plot in var_plots){
    cat(var_plot$Header)
    print(var_plot$Plot)
  }
}

Concentration Profiles {.tabset}

Simple metabolite concentration profiles overlapped per sample (point and line plot) or summarized (as box plots) are created to enable a brief impression of overall sample behavior consistency (e.g. to justify later normalization).

This analysis is based on the status-preprocessed dataset 1.

# Select dataset
biocrates <- datasets$discarded
rep_variables <- c("Sample.Name")
sample_types <- c(SAMPLE_TYPE_BIOLOGICAL) # just need to indicate one type
# Calculate figure sizes
fig_sizes_points <- calc_fig_sizes_rep_rsd(
  biocrates, rep_variables, sample_types, "Compound", num_combinations = 1)
fig_sizes_box <- calc_fig_sizes_rep_rsd(
  biocrates, rep_variables, sample_types, "Compound", num_combinations = 1, legends = 1)
cat(paste0("\n#### Reference QCs\n"))
plot_sample_profiles_points(
  bcdata = biocrates, target = ENV$CONCENTRATION, sample_types = ENV$SAMPLE_TYPE_REFERENCE_QC)
plot_sample_profiles_box(
  bcdata = biocrates, target = ENV$CONCENTRATION, sample_types = ENV$SAMPLE_TYPE_REFERENCE_QC)
cat(paste0("\n#### ", SAMPLE_TYPE_POOLED_QC, "s\n"))
plot_sample_profiles_points(
  bcdata = biocrates, target = ENV$CONCENTRATION, sample_types = SAMPLE_TYPE_POOLED_QC)
plot_sample_profiles_box(
  bcdata = biocrates, target = ENV$CONCENTRATION, sample_types = SAMPLE_TYPE_POOLED_QC)

Biological samples

plot_sample_profiles_points(
  bcdata = biocrates, target = ENV$CONCENTRATION, sample_types = SAMPLE_TYPE_BIOLOGICAL)
plot_sample_profiles_box(
  bcdata = biocrates, target = ENV$CONCENTRATION, sample_types = SAMPLE_TYPE_BIOLOGICAL)
cat("#### Biological samples (normalized)\n")
plot_sample_profiles_points(
  bcdata = biocrates_normalized, target = ENV$CONCENTRATION, sample_types = SAMPLE_TYPE_BIOLOGICAL)
plot_sample_profiles_box(
  bcdata = biocrates_normalized, target = ENV$CONCENTRATION, sample_types = SAMPLE_TYPE_BIOLOGICAL)
# Remove "biocrates" dataset to ensure following sections select the dataset they need
rm(biocrates)


bihealth/metaquac documentation built on Aug. 7, 2021, 8:40 a.m.