require(dplyr)
require(tidyr)
require(knitr)
require(ggplot2)
require(kableExtra)
knitr::opts_chunk$set(echo = FALSE, cache = FALSE, warning = FALSE, 
                      message = TRUE, result = 'asis', 
                      fig.width = 8, fig.height = 6)

Data Preparation

Filtering Samples

Parameters selected:

sample_select_prompt_out <- switch(params$sample_select_prompt, 
                                   all = "Use all samples",
                                   include = "Include selected samples",
                                   exclude = "Exclude selected samples")

if(params$sample_select_prompt == 'all') {
  sample_select_out <- 'Not applicable'
} else {
  sample_select_out <- paste0(' ', params$sample_select, collapse="\n")
}

Samples included in analysis:

kable(params$met1) %>%
  kable_styling("striped", full_width = TRUE) %>% 
  scroll_box(width="100%", height="500px")

Aggregating Features

Parameters selected:

Aggregated Features

Aggregated Taxonomy Table

kable(params$aggregated_tax) %>%
  kable_styling("striped", full_width = TRUE) %>% 
  scroll_box(width="100%", height="500px")

Aggregated Count table

kable(params$aggregated_count) %>%
  kable_styling("striped", full_width = TRUE) %>% 
  scroll_box(width="100%", height="500px")

Filtering Features

Parameters selected:

# features to exclude from analysis
asv_select_prompt_out <- switch(params$asv_select_prompt,
                                all = 'Use all features',
                                some = 'Filter features')
# Filter features by
if(params$asv_select_prompt == 'some') {
  asv_filter_options_out <- switch(params$asv_filter_options,
                                   asv_by_count = 'read count',
                                   asv_by_select = 'selection')
} else {
  asv_filter_options_out <- 'Not applicable'
}

if(params$asv_select_prompt == 'some' & params$asv_filter_options == 'asv_by_count') {
  # Set filter cut-off by
  cutoff_method_out <- switch(
    params$cutoff_method,
    abs_count = 'Read count',
    percent_sample = 'Percent of total read count of each sample',
    percent_total = 'Percent of total read count of dataset'
  )

  # Read count cut-off
  asv_cutoff_out <- params$asv_cutoff

  # Feature prevalence
  prevalence_out <- params$prevalence

  # filter message
  asv_cutoff_msg_out <- params$asv_cutoff_msg
} else {
  cutoff_method_out <- 'Not applicable'
  asv_cutoff_out <- 'Not applicable'
  prevalence_out <- 'Not applicable'
  asv_cutoff_msg_out <- 'Features not filtered by read count'

}

r if(params$asv_select_prompt == 'some' & params$asv_filter_options == 'asv_by_count') { paste("* Filter features by:", asv_filter_options_out, sep=" ") paste("* Set filter cut-off by:", cutoff_method_out, sep=" ") paste("* Read count cut-off:", asv_cutoff_out, sep=" ") paste("* Feature prevalence (# of samples):", prevalence_out, sep=" ") "\n" asv_cutoff_msg_out }

params$prev_agg_plot
params$prev_read_plot

r if(params$asv_select_prompt == 'some' & params$asv_filter_options == 'asv_by_select') { paste("* Filter features by: ", asv_filter_options_out, sep=" ") "* Features selected to be excluded:" }

out <- params$tax1 %>% 
  filter(featureID %in% params$asv_remove) %>% 
  relocate(sequence, .after=last_col())
kable(out) %>%
  kable_styling("striped", full_width = TRUE) %>% 
  scroll_box(width="100%", height="500px")

r if(length(params$empty_sample) > 0) { sprintf("%s samples contained 0 reads after ASV filtering. The following samples have been removed:\n%s", length(params$empty_sample), paste(params$empty_sample, collapse="\n")) }

r if(length(params$empty_asv) > 0) { sprintf("%s asvs contained 0 reads in all samples after ASV filtering. The following asvs have been removed:\n%s", length(params$empty_asv), paste(params$empty_asv, collapse="\n")) }

Features included in analysis:

out <- params$tax2 %>% 
  relocate(sequence, .after=last_col())

kable(out) %>%
  kable_styling("striped", full_width = TRUE) %>% 
  scroll_box(width="100%", height="500px")

Read Count Transformation

Parameters selected

Transformation method: r params$transform_method

Transformed Counts

kable(params$asv_transform) %>%
  kable_styling("striped", full_width = TRUE) %>% 
  scroll_box(width="100%", height="500px")

r if(params$transform_method == 'percent') { sprintf( "## Sample Dissimilarity \n ### Parameters selected \n Compare sample groups: %s \n Panel by: %s \n\n Using Bray-Curtis distance metric to measure the sample-wise dissimilarity. Dissimilarity is calculated for pair-wise samples within the groups of the selected metadata variable (phenotype). \n\n %s \n\n %s \n\n", params$diss_grp, params$diss_panel, params$validation_msg, params$diss_msg ) }

params$p_diss
kable(params$diss_stat)  %>%
  kable_styling("striped", full_width = TRUE) %>% 
  scroll_box(width="100%", height="250px")
kable(params$diss_result)  %>%
  kable_styling("striped", full_width = TRUE) %>% 
  scroll_box(width="100%", height="250px")

PCOA

Parameters selected

Distance method: r params$pcoa_dist

PCOA Summary

kable(params$pcoa_summary) %>%
  kable_styling("striped", full_width = TRUE) %>% 
  scroll_box(width="100%", height="250px")

PCOA Plot

params$p_pcoa

r if(params$transform_method != 'percent') { sprintf( "## PCA \n ### Parameters selected \n PCA normalization: %s\n\n", params$pca_scale) "### PCA Summary" }

kable(params$pca_summary) %>%
  kable_styling("striped", full_width = TRUE) %>% 
  scroll_box(width="100%", height="250px")

r if(params$transform_method != 'percent') {"### PCA Scores Plot"}

params$p_score

r if(params$transform_method != 'percent') {"### PCA Loadings Plot"}

params$p_load

r if(params$transform_method != 'percent') {"### PCA Biplot"}

params$p_biplot

PERMANOVA

Parameters selected

PERMANOVA Formula

params$permanova_formula

PERMANOVA Summary

kable(params$permanova_summary) %>%
  kable_styling("striped", full_width = TRUE) %>% 
  scroll_box(width="100%", height="200px")


schyen/OCMSExplorer documentation built on Feb. 15, 2023, 4:39 p.m.