```{css, echo=FALSE}
.toggle { height: 2em; overflow-y: hidden; } .toggle.open { height: auto; }
```r # Store passed-along data standards <- params$all_data$standards data <- params$all_data$data # different sized plots in the same chunk subchunkify <- function(g, fig_height=6, fig_width=8) { g_deparsed <- paste0(deparse( function() {g} ), collapse = '') sub_chunk <- paste0("`","``{r sub_chunk_", floor(runif(1) * 10000), ", fig.height=", fig_height, ", fig.width=", fig_width, ", echo=FALSE}", "\n(", g_deparsed , ")()", "\n`","`` ") cat(trimws(knitr::knit(text = knitr::knit_expand(text = sub_chunk), quiet = TRUE))) }
The following plots provide a quick inspection on the proportional response of the standards across all cytokines examined. The summary boxplot is presented on a log y axis in order to observe this response across serial dilutions.
standards |> render_standards_graph() + ggplot2::scale_y_log10(labels = function(x) format(x, scientific = FALSE)) standards |> process_std() |> render_standards_cv_graph() standards |> process_std() |> render_std_table(height = "300px") shiny::incProgress()
The following tables list the amount of replicates detected in the datafile.
fulldatapoints <- length(unique(data$Cytokine)) data |> dplyr::group_by(Name, Day, Dilution) |> dplyr::summarise( n = dplyr::n() / fulldatapoints ) |> dplyr::arrange(Name, Day, Dilution) |> dplyr::mutate(n = ifelse(n == round(n, 0), n, kableExtra::cell_spec(n, color = "black", background = "yellow", bold = TRUE))) |> magrittr::set_names(c("Sample Name", "Day Sampled", "Dilution Ratio", "Average Replicate Points")) |> kableExtra::kbl(digits = 2, format = "html", align = "c", caption = "Data Table", table.attr = "style=\'float: left\'") |> kableExtra::kable_styling(position = "center", bootstrap_options = c("striped", "hover", "condensed"), full_width = TRUE) |> kableExtra::scroll_box(height = "250px") data |> dplyr::group_by(Cytokine) |> dplyr::summarise( n = dplyr::n() ) |> magrittr::set_names(c("Cytokine", "Datapoints")) |> kableExtra::kbl(digits = 2, format = "html", align = "c", caption = "Data Table", table.attr = "style=\'float: left\'") |> kableExtra::kable_styling(position = "center", bootstrap_options = c("striped", "hover", "condensed"), full_width = TRUE) |> kableExtra::scroll_box(height = "250px") shiny::incProgress()
These plots provide quick inspection into the variations of the technical replicates being analysed.
data |> render_var_graph() + ggplot2::ggtitle("Variations across samples/cytokines") data |> calculate_var_table_data() |> render_var_table(height = "300px") shiny::incProgress()
This plot investigates associations between different cytokine levels across all samples. This might be meaningless depending on how different the samples analysed are. Use the web app interface for better exploration of individual samples or timepoints.
data |> render_cor_graph()
Warning: These plots should be very carefully interpreted. Seek data sciency help if in doubt.
pca_data <- data |> calculate_pca_data() shiny::incProgress() pca_data |> render_pca_summary_graph() pca_data |> render_pca_biplot_graph() pca_data |> render_pca_scree_graph() shiny::incProgress()
The following groups of plots investigate further details between timepoints and within-sample cytokine comparisons.
sample_names <- unique(data$Name) if (length(sample_names) >= 1) { for (i in sample_names) { cat(paste0("#### Analysis of Sample: ", i)) f_data <- data |> dplyr::filter(Name == i) day_names <- as.numeric(as.character(unique(f_data$Day))) message("Total Days: ", length(day_names), " for Sample: ", i) p <- f_data |> render_samples_graph() + ggplot2::ggtitle(paste("Timeline overview for sample:", i)) + ggplot2::scale_y_log10(labels = function(x) format(x, scientific = FALSE)) print(p) if (length(day_names) > 1) { cat("\n\n") q <- f_data |> ggplot2::ggplot( ggplot2::aes(x = Day, y = Value, color = Dilution) ) + ggplot2::geom_point(position = ggplot2::position_jitterdodge(.1, 0, .25), alpha = 1/3) + ggplot2::geom_boxplot(position = ggplot2::position_dodge2(.25)) + ggplot2::facet_wrap(. ~ Cytokine, ncol = 6) + ggplot2::theme_classic() + ggplot2::scale_color_viridis_d(end = .85, name = "Dilution:") + ggplot2::xlab("Day") + ggplot2::ylab("Value") + ggplot2::scale_y_log10(limits = c(1, NA), labels = function(x) format(x, scientific = FALSE)) + ggplot2::ggtitle(paste("Timepoint analysis for sample", i)) + ggplot2::theme( axis.text.x = ggplot2::element_text(face = "bold"), legend.position = "bottom" ) subchunkify(q, 12, 8) cat("\n\n") } else { cat("\n\n ###### Report Warning [001]: Sample ", i, " does not have more than one timepoint. Did you label the data properly?") } shiny::incProgress(.3/length(sample_names)) } } else { cat("\n##### Report Error [001]: Names not parsed properly") }
This plot provides a quick insight into each cytokine's level for each sample side by side.
data |> ggplot2::ggplot( ggplot2::aes(x = Sample_day, y = Value, color = Dilution) ) + ggplot2::geom_point(position = ggplot2::position_jitterdodge(.1, 0, .25), alpha = 1/3) + ggplot2::geom_boxplot(position = ggplot2::position_dodge2(.25)) + ggplot2::facet_wrap(. ~ Cytokine, ncol = 6) + ggplot2::theme_classic() + ggplot2::scale_color_viridis_d(end = .85, name = "Dilution:") + ggplot2::ylab("Value") + ggplot2::scale_y_log10(limits = c(1, NA), labels = function(x) format(x, scientific = FALSE)) + ggplot2::ggtitle(paste("Cytokine level comparison across samples")) + ggplot2::theme( legend.position = "bottom", axis.title.x = ggplot2::element_blank(), axis.text.x = ggplot2::element_text(angle = 45, face = "bold", hjust = 1, vjust = 1) ) shiny::incProgress()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.