BiocStyle::markdown()
library("knitr")
opts_chunk$set(stop_on_error = 1L)
suppressPackageStartupMessages(library("MatrixQCvis"))
se_r <- params$se_r
se_n <- params$se_n
se_b <- params$se_b
se_t <- params$se_t
se_i <- params$se_i
missingValue <- params$missingValue

This is an automatically-produced report from shinyQC. The analyzed data contains r nrow(se_r) features and r ncol(se_r) samples.

Tab: Samples

Histogram

Use the settings

tbl <- hist_sample_num(se = se_r, category = params$sample_hist)
hist_sample(tbl, category = params$category_hist)

Mosaic

if (!is.null(params$sample_mosaic_f1)) {
    called <- TRUE
    sample_mosaic_f1 <- params$sample_mosaic_f1
} else {
    called <- FALSE
    sample_mosaic_f1 <- colnames(SummarizedExperiment::colData(se_r))[1]
}
if (!is.null(params$sample_mosaic_f2)) {
    sample_mosaic_f2 <- params$sample_mosaic_f2
} else {
    sample_mosaic_f2 <- colnames(SummarizedExperiment::colData(se_r))[1]
}

r if (!called) {"The mosaic plot was not called within the shiny application. Use default settings."}

Use the settings

mosaic(se = params$se_r, f1 = sample_mosaic_f1, f2 = sample_mosaic_f2)
if (shiny::isRunning())
  shiny::setProgress(0.1)

r if (missingValue) {"# Tab: Measured Values\n"}

r if (missingValue) {"## Barplot for samples\n"}

tbl <- samples_memi(se_r)
barplot_samples_memi(tbl, measured = TRUE)  

r if (missingValue) {"## Histogram Features\n"}

if (!is.null(params$mev_binwidth)) {
    called <- TRUE
    binwidth <- params$mev_binwidth
} else {
    called <- FALSE
    binwidth <- 1
}

r if (missingValue & !called) {"The 'Histogram Features' plot was not called within the shiny application. Use default settings."}

r if (missingValue) {"Use the settings"}

r if (missingValue) {"- *Binwidth =*"} r if (missingValue) paste(binwidth, ".", sep = "")

hist_feature(SummarizedExperiment::assay(se_r), measured = TRUE, 
    binwidth = binwidth)  

r if (missingValue) {"## Histogram Features along variable\n"}

if (!is.null(params$mev_binwidthC)) {
    called <- TRUE
    binwidth <- params$mev_binwidthC
    mev_hist_category <- params$mev_hist_category
} else {
    called <- FALSE
    binwidth <- 1
    mev_hist_category <- colnames(SummarizedExperiment::colData(se_r))[1]
}

r if (missingValue & !called) {"The 'Histogram Features along variable' plot was not called within the shiny application. Use default settings."}

r if (missingValue) {"Use the settings"}

r if (missingValue) {paste("- *Variable for stratification =*", mev_hist_category, "and")} r if (missingValue) {paste("- *Binwidth =* ", binwidth, ".", sep = "")}

hist_feature_category(se_r, measured = TRUE, category = mev_hist_category,
    binwidth = binwidth)

r if (missingValue) {"## Upset\n"}

if (!is.null(params$mev_upset_category)) {
    called <- TRUE
    mev_upset_category <- params$mev_upset_category
} else {
    called <- FALSE
    mev_upset_category <- colnames(SummarizedExperiment::colData(se_r))[1]
}

r if (missingValue & !called) {"The 'Upset' plot was not called within the shiny application. Use default settings."}

r if (missingValue) {"Use the settings"}

r if (missingValue) {paste("- *Variable for stratification =* ", mev_upset_category, ".", sep = "")}

upset_category(se_r, category = mev_upset_category, measured = TRUE)
if (shiny::isRunning())
  shiny::setProgress(0.2)

r if (missingValue) {"# Tab: Missing Values\n"}

r if (missingValue) {"## Barplot for samples\n"}

tbl <- samples_memi(se_r)
barplot_samples_memi(tbl, measured = FALSE)

r if (missingValue) {"## Histogram Features\n"}

if (!is.null(params$miv_binwidth)) {
    called <- TRUE
    binwidth <- params$miv_binwidth
} else {
    called <- FALSE
    binwidth <- 1
}

r if (missingValue & !called) {"The 'Histogram Features' plot was not called within the shiny application. Use default settings."}

r if (missingValue) {"Use the settings"}

r if (missingValue) {paste("- *Binwidth =* ", binwidth, ".", sep = "")}

hist_feature(SummarizedExperiment::assay(se_r), measured = FALSE, 
    binwidth = binwidth)

r if (missingValue) {"## Histogram Features along variable\n"}

if (!is.null(params$miv_binwidthC)) {
    called <- TRUE
    binwidth <- params$miv_binwidthC
    miv_hist_category <- params$miv_hist_category
} else {
    called <- FALSE
    binwidth <- 1
    miv_hist_category <- colnames(SummarizedExperiment::colData(se_r))[1]
}

r if (missingValue & !called) {"The 'Histogram Features along variable' plot was not called within the shiny application. Use default settings."}

r if (missingValue) {"Use the settings"}

r if (missingValue) {paste("- *Variable for stratification =*", miv_hist_category, "and")} r if (missingValue) {paste("- *Binwidth =* ", binwidth, ".", sep = " ")}

hist_feature_category(se_r, measured = FALSE, category = miv_hist_category,
    binwidth = binwidth)

r if (missingValue) {"## Upset\n"}

if (!is.null(params$miv_upset_category)) {
    called <- TRUE
    miv_upset_category <- params$miv_upset_category
} else {
    called <- FALSE
    miv_upset_category <- colnames(SummarizedExperiment::colData(se_r))[1]
}

r if (missingValue & !called) {"The 'Upset' plot was not called within the shiny application. Use default settings."}

r if (missingValue) {"Use the settings"}

r if (missingValue) {paste("- *Variable for stratification =* ", mev_upset_category, ".", sep = " ")}

upset_category(se_r, category = miv_upset_category, measured = FALSE)
if (shiny::isRunning())
  shiny::setProgress(0.25)

Tab: Values

Boxplot/Violin plot

if (!is.null(params$int_violin_orderCategory)) {
    called <- TRUE
    int_box_type <- int_violin <- params$int_violin
    int_violin_orderCategory <- params$int_violin_orderCategory
    int_log <- params$int_log
    int_violin <- if (int_violin == "violin") TRUE else FALSE
    int_log <- if (int_log == "log2") TRUE else FALSE
} else {
    called <- FALSE
    int_violin <- TRUE
    int_violin_orderCategory <- colnames(SummarizedExperiment::colData(se_r))[1]
    int_log <- FALSE
    int_box_type <- "violin"
}

r if (!called) {"The 'Boxplot/Violin plot' was not called within the shiny application. Use default settings."}

Use the settings

createBoxplot(se_r, orderCategory = int_violin_orderCategory, 
    title = "raw", log2 = int_log, violin = int_violin)
createBoxplot(se_n, orderCategory = int_violin_orderCategory, 
    title = "normalized", log2 = int_log, violin = int_violin)
createBoxplot(se_b, orderCategory = int_violin_orderCategory,
    title = "batch corrected", log2 = FALSE, violin = int_violin)
createBoxplot(se_t, orderCategory = int_violin_orderCategory,
    title = "transformed", log2 = FALSE, violin = int_violin)
createBoxplot(se_i, orderCategory = int_violin_orderCategory, 
    title = "imputed", log2 = FALSE, violin = int_violin)
if (shiny::isRunning())
  shiny::setProgress(0.32)

Trend/drift

if (!is.null(params$int_drift_data)) {
    called <- TRUE
    int_drift_data <- params$int_drift_data
    int_drift_aggregation <- params$int_drift_aggregation
    int_drift_category <- params$int_drift_category
    int_drift_orderCategory <- params$int_drift_orderCategory
    int_drift_level <- params$int_drift_level
    int_drift_method <- params$int_drift_method

    if (int_drift_data == "raw") {
       se_tmp <- se_r
    }
    if (int_drift_data == "normalized") {
        se_tmp <- se_n
    }
    if (int_drift_data == "batch corrected") {
        se_tmp <- se_b
    }
    if (int_drift_data == "transformed") {
        se_tmp <- se_t
    }
    if (int_drift_data == "imputed") {
        se_tmp <- se_i
    }

} else {
    called <- FALSE
    int_drift_data <- "raw"
    se_tmp <- se_r
    int_drift_aggregation <- "sum"
    int_drift_category <- colnames(SummarizedExperiment::colData(se_r))[1]
    int_drift_orderCategory <- colnames(SummarizedExperiment::colData(se_r))[1]
    int_drift_level <- "all"
    int_drift_method <- "loess"
}

r if (!called) {"The 'Trend/drift' plot was not called within the shiny application. Use default settings."}

Use the settings

driftPlot(se_tmp, aggregation = int_drift_aggregation,
    category = int_drift_category,
    orderCategory = int_drift_orderCategory,
    level = int_drift_level,
    method = params$int_drift_method)

Coefficient of variation

a_r <- SummarizedExperiment::assay(se_r)
a_n <- SummarizedExperiment::assay(se_n)
a_b <- SummarizedExperiment::assay(se_b)
a_t <- SummarizedExperiment::assay(se_t)
a_i <- SummarizedExperiment::assay(se_i)

## calculate cv values
cv_r <- cv(a_r, "raw")
cv_n <- cv(a_n, "normalized")
cv_b <- cv(a_b, "batch corrected")
cv_t <- cv(a_t, "transformed")
cv_i <- cv(a_i, "imputed")

df <- data.frame(cv_r, cv_n, cv_b, cv_t, cv_i)
plotCV(df)

Mean-sd plot

vsn::meanSdPlot(a_t)
vsn::meanSdPlot(a_i)
if (shiny::isRunning())
  shiny::setProgress(0.4)

MA plot

if (!is.null(params$int_ma_group)) {
    called <- TRUE
    int_ma_group <- params$int_ma_group
    int_ma_data <- params$int_ma_data
    int_ma_plot <- params$int_ma_plot
    int_hD_lines <- params$int_hD_lines
} else {
    called <- FALSE
    int_ma_group <- "all"
    int_ma_data <- "raw"
    int_ma_plot <- "all"
    int_hD_lines <- FALSE
}

r if (!called) {"The 'MA plot' was not called within the shiny application. Use default settings."}

Use the settings

tbl_r <- MAvalues(se_r, log2 = TRUE, group = int_ma_group)
tbl_n <- MAvalues(se_n, log2 = TRUE, group = int_ma_group)
tbl_b <- MAvalues(se_b, log2 = TRUE, group = int_ma_group)
tbl_t <- MAvalues(se_t, log2 = FALSE, group = int_ma_group)

if (shiny::isRunning())
  shiny::setProgress(0.5)

tbl_i <- MAvalues(se_i, log2 = FALSE, group = int_ma_group)

if (int_ma_data == "raw") {
    tbl <- tbl_r
}
if (int_ma_data == "normalized") {
    tbl <- tbl_n
}
if (int_ma_data == "batch corrected") {
    tbl <- tbl_b
}
if (int_ma_data == "transformed") {
    tbl <- tbl_t
}
if (int_ma_data == "imputed") {
    tbl <- tbl_i
}

MAplot(tbl, group = int_ma_group,
    plot = int_ma_plot)

d_r <- hoeffDValues(tbl_r, name = "raw")
d_n <- hoeffDValues(tbl_n, name = "normalized")
d_b <- hoeffDValues(tbl_b, name = "batch corrected")
d_t <- hoeffDValues(tbl_t, name = "transformed")

if (missingValue) {
    d_i <- hoeffDValues(tbl_i, name = "imputed")
    df <- data.frame(d_r, d_n, d_b, d_t, d_i)  
} else {
    df <- data.frame(d_r, d_n, d_b, d_t)
}

hoeffDPlot(df, lines = int_hD_lines)
if (shiny::isRunning())
  shiny::setProgress(0.55)

ECDF

if (!is.null(params$int_ecdf_sample)) {
    called <- TRUE
    int_ecdf_data <- params$int_ecdf_data
    int_ecdf_sample <- params$int_ecdf_sample
    int_ecdf_group <- params$int_ecdf_group

    if (int_ecdf_data == "raw") {
        se_tmp <- se_r
    }
    if (int_ecdf_data == "normalized") {
        se_tmp <- se_n
    }
    if (int_ecdf_data == "batch corrected") {
        se_tmp <- se_b
    }
    if (int_ecdf_data == "transformed") {
        se_tmp <- se_t
    }
    if (int_ecdf_data == "imputed") {
        se_tmp <- se_i
    }

} else {
    called <- FALSE
    int_ecdf_data <- "raw"
    int_ecdf_sample <- colnames(se_r)[1]
    int_ecdf_group <- "all"
    se_tmp <- se_r
}

r if (!called) {"The 'ECDF' plot was not called within the shiny application. Use default settings."}

Use the settings

ECDF(se_tmp, sample = int_ecdf_sample,
    group = int_ecdf_group)

Distance matrix

if (!is.null(params$int_ecdf_label)) {
    called <- TRUE
    int_dist_label <- params$int_dist_label
    int_dist_method <- params$int_dist_method
} else {
    called <- FALSE
    int_dist_label <- colnames(SummarizedExperiment::colData(se_r))[1]
    int_dist_method <- "euclidean"
}

r if (!called) {"The 'Distance matrix' plots were not called within the shiny application. Use default settings."}

Use the settings

dist_mat_r <- distShiny(a_r, method = int_dist_method)
dist_mat_n <- distShiny(a_n, method = int_dist_method)
dist_mat_b <- distShiny(a_b, method = int_dist_method)
dist_mat_t <- distShiny(a_t, method = int_dist_method)

## plotting
distSample(d = dist_mat_r, se = se_r,
    label = int_dist_label, title = "raw")
sumDistSample(dist_mat_r, title = "raw")

distSample(d = dist_mat_n, se = se_n,
    label = int_dist_label, title = "normalized")
sumDistSample(dist_mat_n, title = "normalized")

distSample(d = dist_mat_b, se = se_b,
    label = int_dist_label, title = "batch corrected")
sumDistSample(dist_mat_b, title = "batch corrected")

distSample(d = dist_mat_t, se = se_t,
    label = int_dist_label, title = "transformed")
sumDistSample(dist_mat_t, title = "transformed")

if (missingValue) {
    dist_mat_i <- distShiny(a_i, method = int_dist_method)
    distSample(d = dist_mat_i, se = se_i,
        label = int_dist_label, title = "imputed")
    sumDistSample(dist_mat_i, title = "imputed")  
}

Features

if (!is.null(params$int_feat_selectFeat)) {
    called <- TRUE
    int_feat_selectFeat <- params$int_feat_selectFeat
    int_feat_featLine <- params$int_feat_featLine
} else {
    called <- FALSE
    int_feat_selectFeat <- rownames(se_r)[1]
    int_feat_featLine <- FALSE
}

r if (!called) {"The 'Features' plots were not called within the shiny application. Use default settings."}

Use the settings

if (missingValue) {
    l_assays <- list(raw = a_r, normalized = a_n, batch.corrected = a_b,
      transformed = a_t, imputed = a_i)
} else {
    l_assays <- list(raw = a_r, normalized = a_n, batch.corrected = a_b,
      transformed = a_t)
}

df_feature <- createDfFeature(l_assays, feature = int_feat_selectFeat)

## plotting
featurePlot(df_feature)
cvFeaturePlot(l_assays, lines = int_feat_featLine)
if (shiny::isRunning())
  shiny::setProgress(0.6)

Tab: Dimension Reduction

PCA

if (!is.null(params$dr_pca_color)) {
    called <- TRUE
    dr_pca_center <- params$dr_pca_center
    dr_pca_scale <- params$dr_pca_scale
    dr_pca_color <- params$dr_pca_color
    dr_pca_x <- params$dr_pca_x
    dr_pca_y <- params$dr_pca_y
} else {
    called <- FALSE
    dr_pca_center <- TRUE
    dr_pca_scale <- TRUE
    dr_pca_color <- "none"
    dr_pca_x <- "PC1"
    dr_pca_y <- "PC2"
}

r if (!called) {"The 'PCA' plot was not called within the shiny application. Use default settings."}

Use the settings

tbl <- dimensionReduction(a_i, type = "PCA",
    params = list(center = dr_pca_center, scale = dr_pca_scale))
explainedVar <- explVar(x = a_i, 
    params = list(center = dr_pca_center, scale = dr_pca_scale))
dimensionReductionPlot(tbl = tbl, se = se_r, color = dr_pca_color,
    explainedVar = explainedVar, x_coord = dr_pca_x, y_coord = dr_pca_y)

PCoA

if (!is.null(params$dr_pcoa_color)) {
    called <- TRUE
    dr_pcoa_method <- params$dr_pcoa_method
    dr_pcoa_color <- params$dr_pcoa_color
    dr_pcoa_x <- params$dr_pcoa_x
    dr_pcoa_y <- params$dr_pcoa_y
} else {
    called <- FALSE
    dr_pcoa_method <- "euclidean"
    dr_pcoa_color <- "none"
    dr_pcoa_x <- "Axis.1"
    dr_pcoa_y <- "Axis.2"
}

r if (!called) {"The 'PCoA' plot was not called within the shiny application. Use default settings."}

Use the settings

tbl <- dimensionReduction(a_i, type = "PCoA",
    params = list(method = dr_pcoa_method))
dimensionReductionPlot(tbl = tbl, se = se_r, color = dr_pcoa_color,
    explainedVar = NULL, x_coord = dr_pcoa_x, y_coord = dr_pcoa_y)
if (shiny::isRunning())
  shiny::setProgress(0.65)

NMDS

if (!is.null(params$dr_nmds_color)) {
    called <- TRUE
    dr_nmds_method <- params$dr_pcoa_method
    dr_nmds_color <- params$dr_nmds_color
    dr_nmds_x <- params$dr_nmds_x
    dr_nmds_y <- params$dr_nmds_y
} else {
    called <- FALSE
    dr_nmds_method <- "euclidean"
    dr_nmds_color <- "none"
    dr_nmds_x <- "MDS1"
    dr_nmds_y <- "MDS2"
}

r if (!called) {"The 'NMDS' plot was not called within the shiny application. Use default settings."}

Use the settings

tbl <- dimensionReduction(a_i, type = "NMDS", 
    params = list(method = dr_nmds_method))
dimensionReductionPlot(tbl = tbl, se = se_r, color = dr_nmds_color,
    explainedVar = NULL, x_coord = dr_nmds_x, y_coord = dr_nmds_y)

tSNE

if (!is.null(params$dr_tsne_color)) {
    called <- TRUE
    dr_tsne_perplexity <- params$dr_tsne_perplexity
    dr_tsne_max_iter <- params$dr_tsne_max_iter
    dr_tsne_initial_dims <- params$dr_tsne_initial_dims
    dr_tsne_dims <- params$dr_tsne_dims
    dr_tsne_pca_center <- params$dr_tsne_pca_center
    dr_tsne_pca_scale <- params$dr_tsne_pca_scale
    dr_tsne_color <- params$dr_tsne_color
    dr_tsne_x <- params$dr_tsne_x
    dr_tsne_y <- params$dr_tsne_y
} else {
    called <- FALSE
    dr_tsne_perplexity <- 1
    dr_tsne_max_iter <- 1000
    dr_tsne_initial_dims <- 10
    dr_tsne_dims <- 3
    dr_tsne_pca_center <- TRUE
    dr_tsne_pca_scale <- TRUE
    dr_tsne_color <- "none"
    dr_tsne_x <- "X1"
    dr_tsne_y <- "X2"
}
if (shiny::isRunning())
  shiny::setProgress(0.73)

r if (!called) {"The 'tSNE' plot was not called within the shiny application. Use default settings."}

Use the settings

tbl <- dimensionReduction(a_i, type = "tSNE", 
    params = list(perplexity = dr_tsne_perplexity, 
    max_iter = dr_tsne_max_iter, initial_dims = dr_tsne_initial_dims,
    dims = dr_tsne_dims, pca_center = dr_tsne_pca_center,
    pca_scale = dr_tsne_pca_scale))
dimensionReductionPlot(tbl = tbl, se = se_r, color = dr_tsne_color,
    explainedVar = NULL, x_coord = dr_tsne_x, y_coord = dr_tsne_y)

UMAP

if (!is.null(params$dr_umap_color)) {
    called <- TRUE
    dr_umap_min_dist = params$dr_umap_min_dist
    dr_umap_n_neighbors = params$dr_umap_n_neighbors
    dr_umap_spread = params$dr_umap_spread
    dr_umap_color = params$dr_umap_color
    dr_umap_x = params$dr_umap_x
    dr_umap_y = params$dr_umap_y
} else {
    called <- FALSE
    dr_umap_min_dist = 0.1
    dr_umap_n_neighbors = min(15, ncol(se_r))
    dr_umap_spread = 1
    dr_umap_color = "none"
    dr_umap_x = "X1"
    dr_umap_y = "X2"
}

r if (!called) {"The 'UMAP' plot was not called within the shiny application. Use default settings."}

Use the settings

tbl <- dimensionReduction(a_i, type = "UMAP", 
    params = list(min_dist = dr_umap_min_dist, n_neighbors = dr_umap_n_neighbors,
        spread = dr_umap_spread))
dimensionReductionPlot(tbl = tbl, se = se_r, color = dr_umap_color,
    explainedVar = NULL, x_coord = dr_umap_x, y_coord = dr_umap_y)
if (shiny::isRunning())
  shiny::setProgress(0.87)
m_formula <- params$de_m_formula
valid_m <- if (!is.null(m_formula)) TRUE else FALSE

c_formula <- params$de_c_formula
valid_c <- if (!is.null(c_formula)) TRUE else FALSE

r if (valid_m | (valid_m & valid_c)) {"# Tab: DE\n~\n"} r if (valid_m) {"The differential expression analysis was called with the model matrix formula:"} r if (valid_m) {c_formula}

r if (valid_m & valid_c) {"The differential expression analysis was called with the contrast expression:"} r if (valid_m) {c_formula}

if (valid_m & valid_c) {
    mM <- stats::model.matrix(m_formula, data = colData(se_r))
    cM <- limma::makeContrasts(contrasts = c_formula, levels = mM)

    if (params$de_method == "limma") {
        tT <- limma::topTable(params$de_fit_ttest, number = Inf, 
            adjust.method = "fdr", p.value = 0.05)
        tT <- cbind(name = rownames(tT), tT)
        volcanoPlot(tT, type = "ttest")
    }
    if (params$de_method == "proDA") {
        tT <- proDA::test_diff(fit = params$de_fit_proDA, 
            contrast = params$de_c_formula,
            sort_by = "adj_pval")
        volcanoPlot(tT, type = "proDA")
    }
}
if (shiny::isRunning())
  shiny::setProgress(0.98)


tnaake/MatrixQCvis documentation built on June 20, 2024, 7:22 a.m.