Skip to content

Instantly share code, notes, and snippets.

Avatar

Laurent Gatto lgatto

View GitHub Profile
@lgatto
lgatto / R4MS_install.R
Last active May 27, 2023 12:00
RforMassSpectrometry book installation script
View R4MS_install.R
## Installation instructions for the R for Mass Spectrometry tutorial
## https://rformassspectrometry.github.io/docs/
## Install packages
if (!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("tidyverse", ask = FALSE)
BiocManager::install("factoextra", ask = FALSE)
@lgatto
lgatto / pull_many.el
Last active January 11, 2023 18:39
Pulls and pushes a few github repos in bash and elisp
View pull_many.el
;; Pulls and pushes a few github repos from emacs
;; Laurent Gatto (https://github.com/lgatto)
;; Thanks to Stephen J. Eglen for his help in redirecting to a
;; dedicated buffer (https://github.com/sje30)
(setq git-dirs '(
"~/wd"
"~/bin"
"~/Documents/org"
"~/Documents/roam"
View aggregation_quant.R
library(tidyverse)
library(scp)
## Read the data table
x <- read.delim("data/02ng/Task2-SearchTask/AllQuantifiedPeptides.tsv") |>
select(-18) |> ## column 18 is all NAs
janitor::clean_names() |>
rename_with(~ gsub("intensity_ex_auto_", "int_", .x, fixed = TRUE)) |>
rename_with(~ gsub("detection_type_ex_auto_", "det_", .x, fixed = TRUE))
@lgatto
lgatto / app.R
Created March 6, 2022 13:57
DEP::run_app("LFQ")
View app.R
library(dplyr)
library(tibble)
library(SummarizedExperiment)
library(DEP)
library(shiny)
library(shinydashboard)
ui <- shinyUI(
dashboardPage(
dashboardHeader(title = "DEP - LFQ"),
@lgatto
lgatto / ggPlotMzDelta.R
Created September 2, 2021 20:23
ggPlotMzDelta
View ggPlotMzDelta.R
ggPlotMzDelta <- function(delta, aaLabels = TRUE) {
stopifnot(require("ggplot2"))
## from PSM::getAminoAcids()
amino_acids <-
structure(list(AA = c("peg", "A", "R", "N", "D", "C", "E", "Q",
"G", "H", "I", "L", "K", "M", "F", "P", "S",
"T", "W", "Y", "V"),
ResidueMass = c(44, 71.03711, 156.10111, 114.04293,
115.02694, 103.00919, 129.04259,
128.05858, 57.02146, 137.05891,
@lgatto
lgatto / mzdeltas.R
Last active September 2, 2021 15:19
M/Z deltas quality control
View mzdeltas.R
##' @title Compute the MZ deltas
##'
##' @description
##'
##' The M/Z delta plot illustrates the suitability of MS2 spectra for
##' identification by plotting the M/Z differences of the most intense
##' peaks. The resulting histogram should optimally shown outstanding
##' bars at amino acid residu masses. The plots have been described in
##' Foster et al. 2011.
##'
View rprot_ex.R
library(magrittr)
library(ggplot2)
library(rpx)
rpx:::apply_fix_issue_5(FALSE)
## https://www.ebi.ac.uk/pride/archive/projects/PXD022816
## RawBeans: A Simple, Vendor-Independent, Raw-Data Quality-Control
## Tool (10.1021/acs.jproteome.0c00956)
View spur-cor
set.seed(123)
max_corrs <- function(d, n = 60, n_iter = 1000)
replicate(n_iter, {
m <- matrix(rnorm(n * d), ncol = d)
max(cor(m)[-1, 1])
})
r1 <- data.frame(d = 800, r = max_corrs(800))
r2 <- data.frame(d = 6400, r = max_corrs(6400))
r <- rbind(r1, r2)
@lgatto
lgatto / csama-open-repro.md
Created July 22, 2019 16:41
Notes for the CSAMA 2019 discussion on open and reproducible research
View csama-open-repro.md
@lgatto
lgatto / annot_filter.R
Created May 12, 2019 19:05
Generic annotation filter
View annot_filter.R
setClass("CharacterVariableFilter",
contains = "CharacterFilter")
setClass("NumericVariableFilter",
contains = "DoubleFilter")
VariableFilter <- function(field,
value,
condition = "==") {
if (is.numeric(value))