Skip to content

Instantly share code, notes, and snippets.

View lgatto's full-sized avatar

Laurent Gatto lgatto

View GitHub Profile
@lgatto
lgatto / R4MS_install.R
Last active March 13, 2024 07:23
RforMassSpectrometry book installation script
## Installation instructions for the R for Mass Spectrometry tutorial
## https://rformassspectrometry.github.io/book/
## Install packages
if (!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("tidyverse", ask = FALSE)
BiocManager::install("factoextra", ask = FALSE)
@lgatto
lgatto / gird.R
Last active February 18, 2024 10:43
Reproducing The Grid exhibition poster
## See https://lgatto.github.io/the-grid-in-r/
plotSquare <- function(x, y, width) {
x1 <- x - (width / 2)
y1 <- y - (width / 2)
x2 <- x1 + width
y2 <- y1 + width
rect(x1, y1, x2, y2)
}
@lgatto
lgatto / yank-bibtex-from-doi.el
Created January 27, 2024 16:22
Create and yank bibtex entry from a DOI
(defun yank-bibtex-from-doi ()
"Create and yank bibtex entry from a DOI."
(interactive)
;; read the doi from minibuffer
(setq doi (read-from-minibuffer "doi: "))
;; define the curl shell command
(setq cmd
(concat
"curl -LH \"Accept: application/x-bibtex\" "
"https://doi.org/"
@lgatto
lgatto / rnw2rmd.pl
Last active December 18, 2023 05:03
Convert Rnw to Rmd
#!/usr/bin/perl
## Based on convert.txt by Mike Love
## https://gist.github.com/mikelove/5618f935ace6e389d3fbac03224860cd
## The script ignores labels and references, un-numbered sections
## (section*), quotes and probably a couple of more. It won't deal
## with the pre-amble, bibliography and document tags either. Still
## useful, though.
;; grep -h X-Key */*/cur/* | sed -e 's/X-Keywords: //; s/, /\n/g' | sort | uniq > xkeys.txt
(setq mu4e-xkeys "~/Maildir/xkeys.txt")
(defun read-lines (f)
"Return a list of lines of a file at f."
(with-temp-buffer
(insert-file-contents f)
(split-string (buffer-string) "\n" t)))
@lgatto
lgatto / pull_many.el
Last active January 11, 2023 18:39
Pulls and pushes a few github repos in bash and elisp
;; 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"
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 / keybase.md
Last active December 30, 2022 18:30

Keybase proof

I hereby claim:

  • I am lgatto on github.
  • I am lgatto (https://keybase.io/lgatto) on keybase.
  • I have a public key whose fingerprint is 3228 0F50 8589 B085 9E3D A828 0C03 2B80 46E2 E38A

To claim this, I am signing this object:

@lgatto
lgatto / app.R
Created March 6, 2022 13:57
DEP::run_app("LFQ")
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
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,