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)
}
dt <- copy(evidence)

setnames(dt, "experiment", "condition")
dt[is.na(condition), condition := "Library"]
dt[condition == "Library" & is.na(Replicate), Replicate := .GRP, by = .(`raw file`)]


if (!("fraction" %in% colnames(expdes))) {
  dt <- unique(dt[, .(sequence, condition, Replicate, fraction, `raw file`)])[, .N, by = .(condition, Replicate, fraction, `raw file`)]
  dt[, Run := str_c(condition, Replicate, fraction, sep = " - ")]
  xlabel = "Condition - Replicate - Fraction"
} else {
  dt <- unique(dt[, .(sequence, condition, Replicate, `raw file`)])[, .N, by = .(condition, Replicate, `raw file`)]
  dt[, Run := str_c(condition, Replicate, sep = " - ")]
  xlabel = "Condition - Replicate"
}

p <- ggplot(dt, aes(x = as.factor(Run), y = N, color = condition, label=`raw file`)) +
  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(xlabel) +
  scale_y_continuous("# Peptide") +
  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 evidence.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.