knitr::opts_chunk$set(echo = FALSE, warning = FALSE)
options(DT.warn.size = FALSE)
library(flexdashboard)
library(DT)
input_info <- params$input_info
samples_info <- params$samples_info
pre_matrix_info <- params$pre_info
pre_stats <- params$pre_stats
pre_sharing <- params$sharing_pre
coll_info <- params$coll_info
post_info <- params$post_info
post_stats <- params$post_stats
post_sharing <- params$sharing_post
post_summary <- params$summary_post
sample_key <- params$sample_key
dynamic_cols <- params$dynamic_cols
secondary_col <-  "#ff9470"

Input info {data-orientation=rows} ===============================================================================

Row1

Distinct integration sites

valueBox(value = input_info$total_iss, color = secondary_col, icon = "fa-dna")
out <- purrr::map2_chr(input_info$quant_totals, names(input_info$quant_totals), function(val, name) {
  heading <- paste("###", name, "total")
  a1 <- knitr::knit_expand(text = heading)
  a2 <- knitr::knit_expand(text = paste0("`r valueBox(value = ", round(val, digits = 2), ")`"))
  paste(c(a1, a2), collapse = "\n")
})

r paste(knitr::knit(text = paste(out, collapse = '\n\n')))

Row2

About this page

This page contains summary information regarding the input matrix as is (no pre-processing steps applied)

Independent sample key

r sample_key

Additional info {data-orientation=rows}

venn_diag <- eulerr::venn(samples_info)

Row1 {data-height=500}

Overview of samples contained in matrix and association file

plot(venn_diag, fills = list(fill = c("gold", "navyblue"), alpha = 0.5))

About this page

Missing samples
Metadata is missing from the association file for these samples, therefore they'll be removed prior collision processing.

Additional samples
The association file contains information about these samples in the project of interest but they're not found in the matrix provided as input.

Row2 {.tabset .tabset-fade}

Missing samples

cat("*Nothing to report*")
mi_df <- params$missing_info 
num_cols <- colnames(mi_df)[colnames(mi_df) != dynamic_cols$pcr_id]
mi_df <- mi_df |>
  dplyr::mutate(dplyr::across(
    dplyr::all_of(num_cols),
    ~ round(.x, digits = 2)
  ))
datatable(mi_df, 
              class = "stripe",
              colnames = stringr::str_replace_all(colnames(params$missing_info),
                                                  "_", " "),
              filter = "top",
          options = list(scrollY = 350))

Additional samples

cat("*Nothing to report*")
ai_df <- params$additional_info 
DT::datatable(ai_df, 
              class = "stripe",
              colnames = stringr::str_replace_all(colnames(ai_df),
                                                  "_", " "),
              filter = "top",
              options = list(scrollY = 350))

Pre-processing {data-orientation=rows}

Row1

Number of distinct integration sites

valueBox(value = pre_matrix_info$total_iss, color = secondary_col, icon = "fa-dna")
out <- purrr::map2_chr(pre_matrix_info$quant_totals, names(pre_matrix_info$quant_totals), function(val, name) {
  heading <- paste("###", name, "total")
  a1 <- knitr::knit_expand(text = heading)
  a2 <- knitr::knit_expand(text = paste0("`r valueBox(value = ", round(val, digits = 2), ")`"))
  paste(c(a1, a2), collapse = "\n")
})

r paste(knitr::knit(text = paste(out, collapse = '\n\n')))

Row2

Number of distinct integration sites with respect to input matrix

int_ratio <- round((pre_matrix_info$total_iss / input_info$total_iss) * 100, digits = 1)
gauge(int_ratio, min = 0, max = 100, symbol = "%", gaugeSectors(
  success = c(85, 100), warning = c(40, 84), danger = c(0, 39)))
out <- purrr::map2_chr(pre_matrix_info$quant_totals, names(pre_matrix_info$quant_totals), function(val, name) {
  heading <- paste("###", name, "total with respect to input matrix")
  ratio <- round((val / input_info$quant_totals[[name]]) * 100, digits = 1)
  a1 <- knitr::knit_expand(text = heading)
  a2 <- knitr::knit_expand(text = paste0("`r gauge(", ratio, ", min = 0, max = 100, symbol = '%', gaugeSectors(
  success = c(85, 100), warning = c(40, 84), danger = c(0, 39)))`"))
  paste(c(a1, a2), collapse = "\n")
})

r paste(knitr::knit(text = paste(out, collapse = '\n\n')))

Row3

Per pool stats {style="width: 95% !important"}

datatable(pre_stats, class = "stripe",
              colnames = stringr::str_replace_all(colnames(pre_stats),
                                                  "_", " "),
              filter = "top", rownames = FALSE,
              options = list(scrollY = 350)) |>
formatRound(columns = colnames(pre_stats)[colnames(pre_stats) !=
                                            dynamic_cols$pool], digits = 2)

Row4 {data-height=800 .tabset .tabset-fade}

IS sharing: absolute values

cat("*Heatmaps saved as separate files for size issues*")
pre_sharing$absolute

IS sharing: relative values on x

cat("*Heatmaps saved as separate files for size issues*")
pre_sharing$on_g1 |>
  plotly::layout(title = list(text = "IS sharing - percentages on x"))

IS sharing: relative values on union

cat("*Heatmaps saved as separate files for size issues*")
pre_sharing$on_union |>
  plotly::layout(title = list(text = "IS sharing - percentages on union"))

How to read the plots

How to read relative heatmaps

Relative heatmap on x values
Each value in a row from left to right corresponds to the amount of shared integration sites between x and y divided by the IS observed in the group on the x axis.

Relative heatmap on union
This plot is symmetric with respect to the diagonal. Each cell contains the amount of shared integration sites normalized by the cardinality of the union of the 2 groups x and y.

Collision info {data-orientation=columns}

Col1


Collisions identified

valueBox(value = coll_info$coll_n, color = secondary_col)

Collisions identified (% on pre-processing matrix)

coll_id_ratio <- round((coll_info$coll_n / pre_matrix_info$total_iss) * 100, digits = 2)
gauge(coll_id_ratio, min = 0, max = 100, symbol = "%", gaugeSectors(
  success = c(0, 30), warning = c(31, 40), danger = c(41, 100)))

Col2

Collisions re-assigned

valueBox(value = coll_info$reassigned, icon = "fa-recycle")

Collisions re-assigned (% on pre-processing matrix)

ra_ratio_pre <- round((coll_info$reassigned / pre_matrix_info$total_iss) * 100, digits = 2)
gauge(ra_ratio_pre, min = 0, max = 100, symbol = "%")

Collisions re-assigned (% on collisions)

ra_ratio_coll <- round((coll_info$reassigned / coll_info$coll_n) * 100, digits = 2)
gauge(ra_ratio_coll, min = 0, max = 100, symbol = "%")

Col3

Collisions removed

valueBox(value = coll_info$removed, icon = "fa-trash")

Collisions removed (% on pre-processing matrix)

rem_ratio_pre <- round((coll_info$removed / pre_matrix_info$total_iss) * 100, digits = 2)
gauge(rem_ratio_pre, min = 0, max = 100, symbol = "%")

Collisions removed (% on collisions)

rem_ratio_coll <- round((coll_info$removed / coll_info$coll_n) * 100, digits = 2)
gauge(rem_ratio_coll, min = 0, max = 100, symbol = "%")

Post-processing {data-orientation=rows}

Row1

Number of distinct integration sites

valueBox(value = post_info$total_iss, color = secondary_col, icon = "fa-dna")
out <- purrr::map2_chr(post_info$quant_totals, names(post_info$quant_totals), function(val, name) {
  heading <- paste("###", name, "total")
  a1 <- knitr::knit_expand(text = heading)
  a2 <- knitr::knit_expand(text = paste0("`r valueBox(value = ", round(val, digits = 2), ")`"))
  paste(c(a1, a2), collapse = "\n")
})

r paste(knitr::knit(text = paste(out, collapse = '\n\n')))

Row2

Number of distinct integration sites with respect to pre-processing matrix

int_ratio_post <- round((post_info$total_iss / pre_matrix_info$total_iss) * 100, digits = 1)
gauge(int_ratio_post, min = 0, max = 100, symbol = "%", gaugeSectors(
  success = c(85, 100), warning = c(40, 84), danger = c(0, 39)))
out <- purrr::map2_chr(post_info$quant_totals, names(post_info$quant_totals), function(val, name) {
  heading <- paste("###", name, "total with respect to pre-processing matrix")
  ratio <- round((val / pre_matrix_info$quant_totals[[name]]) * 100, digits = 1)
  a1 <- knitr::knit_expand(text = heading)
  a2 <- knitr::knit_expand(text = paste0("`r gauge(", ratio, ", min = 0, max = 100, symbol = '%', gaugeSectors(
  success = c(85, 100), warning = c(40, 84), danger = c(0, 39)))`"))
  paste(c(a1, a2), collapse = "\n")
})

r paste(knitr::knit(text = paste(out, collapse = '\n\n')))

Row3

Per pool stats {style="width: 95% !important"}

datatable(post_stats, class = "stripe",
              colnames = stringr::str_replace_all(colnames(post_stats),
                                                  "_", " "),
              filter = "top", rownames = FALSE,
              options = list(scrollY = 350)) |>
formatRound(columns = colnames(post_stats)[colnames(post_stats) !=
                                             dynamic_cols$pool], digits = 2)

Row4

Per patient summary {style="width: 95% !important"}

datatable(post_summary, class = "stripe",
          colnames = stringr::str_replace_all(colnames(post_summary),
                                                  "_", " "),
              filter = "top", rownames = FALSE,
              options = list(scrollY = 350))

Row5 {data-height=800 .tabset .tabset-fade}

IS sharing: absolute values

cat("*Heatmaps saved as separate files for size issues*")
post_sharing$absolute

IS sharing: relative values on x

cat("*Heatmaps saved as separate files for size issues*")
post_sharing$on_g1 |>
  plotly::layout(title = list(text = "IS sharing - percentages on x"))

IS sharing: relative values on union

cat("*Heatmaps saved as separate files for size issues*")
post_sharing$on_union |>
  plotly::layout(title = list(text = "IS sharing - percentages on union"))

How to read the plots

How to read relative heatmaps

Relative heatmap on x values
Each value in a row from left to right corresponds to the amount of shared integration sites between x and y divided by the IS observed in the group on the x axis.

Relative heatmap on union
This plot is symmetric with respect to the diagonal. Each cell contains the amount of shared integration sites normalized by the cardinality of the union of the 2 groups x and y.

Reproducibility {data-orientation=rows}

Row1 {data-height=600}

Session info {style="width: 95% !important"}

sessionInfo()


calabrialab/ISAnalytics documentation built on Nov. 2, 2023, 8:57 p.m.