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)
}


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)
dt <- copy(pept_int[Imputed == 0])

dt[is.na(condition), condition := "Library"]


dt <- dt[, .N, by = .(condition, Replicate)]
dt[, Run := str_c(condition, Replicate, sep = " - ")]

p <- ggplot(dt, aes(x = as.factor(Run), y = N, color = condition, label=Replicate)) +
  geom_segment( aes(x=as.factor(Run), xend=as.factor(Run), y=0, yend=N), color="skyblue") +
  geom_point(size=2, alpha=0.9) +
  coord_flip() +
  theme_minimal() +
  scale_x_discrete("Condition - Replicate") +
  scale_y_continuous("# Peptides") +
  theme(axis.text.x = element_text(angle = 90, vjust = 0.2),
        panel.grid.major.y = element_blank(),
        panel.border = element_blank(),
        axis.ticks.y = element_blank()
        ) +
  ggtitle("Peptides - Number of identifications from peptides.txt")


ggplotly(p, tooltip = c("label","y")) %>% config(displayModeBar = T, 
                                               modeBarButtons = list(list('toImage')),
                                               displaylogo = F)


MassDynamics/lfq_processing documentation built on May 4, 2023, 11:20 p.m.