knitr::opts_chunk$set(fig.cap = NULL, fig.path = params$output_figure) library(data.table) library(ggplot2) library(ggrepel) library(GGally) library(umap) library(FactoMineR) library(factoextra) library(corrplot) library(viridis) library(ggpubr) library(Hmisc) library(plotly) library(stringr) library(bit64) num_files <- expdes[, .N] run_per_condition <- expdes[, .(countRepMax = .N), by = .(experiment)] setnames(run_per_condition, "experiment", "condition") # for fractions, create file name from mqExperiment and Fraction if (!("file_name" %in% colnames(expdes))){ expdes$file_name = paste(expdes$experiment, " - ", expdes$Replicate) } mod_pept_int_rep <- merge( run_per_condition, mod_pept_int[Imputed == 0, .(Repcount = .N), by = .(id, condition)], by = c("condition") ) mod_pept_int_rep[, repPC := Repcount/countRepMax] mod_pept_id_in_a_cond <- mod_pept_int_rep[repPC >= 0.5, unique(id)] mod_pept_int[, Valid := 0L] mod_pept_int[id %in% mod_pept_id_in_a_cond, Valid := 1L] rm(mod_pept_id_in_a_cond, mod_pept_int_rep) pept_int_rep <- merge( run_per_condition, pept_int[Imputed == 0, .(Repcount = .N), by = .(id, condition)], by = c("condition") ) pept_int_rep[, repPC := Repcount/countRepMax] pept_id_in_a_cond <- pept_int_rep[repPC >= 0.5, unique(id)] pept_int[, Valid := 0L] pept_int[id %in% pept_id_in_a_cond, Valid := 1L] rm(pept_id_in_a_cond, pept_int_rep) prot_int_rep <- merge( run_per_condition, prot_int[Imputed == 0, .(Repcount = .N), by = .(id, condition)], by = c("condition") ) prot_int_rep[, repPC := Repcount/countRepMax] prot_id_in_a_cond <- prot_int_rep[repPC >= 0.5, unique(id)] prot_int[, Valid := 0L] prot_int[id %in% prot_id_in_a_cond, Valid := 1L] rm(prot_id_in_a_cond, prot_int_rep)
pca_dt <- pept_int[Valid == 1, .( id, condition, Replicate, log2NInt, run_id )] pca_dt <- dcast(pca_dt, condition + Replicate ~ id, value.var = "log2NInt") num_dimensions = min(pca_dt[, .N-1], 10) res.pca <- PCA(pca_dt[, 3:ncol(pca_dt)], graph = FALSE, ncp = num_dimensions) eig.val <- get_eigenvalue(res.pca) eig.val <- data.table(dims = rownames(eig.val), eig.val)
scree_plot <- ggplot(eig.val[1:num_dimensions], aes(x=reorder(dims, -`variance.percent`), y=`variance.percent`)) + geom_bar(stat="identity", fill = "skyblue2") + theme_minimal() + geom_text_repel(aes(label=(round(`variance.percent`,1))), direction = 'y') + scale_x_discrete("PCA components") + scale_y_continuous("% Variance") + ggtitle("Peptides - PCA Screeplot") ggplotly(scree_plot, tooltip = c("y")) %>% config(displayModeBar = T, modeBarButtons = list(list('toImage')), displaylogo = F)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.