Skip to content

Instantly share code, notes, and snippets.

View lgatto's full-sized avatar

Laurent Gatto lgatto

View GitHub Profile
@lgatto
lgatto / mzdeltas.R
Last active September 2, 2021 15:19
M/Z deltas quality control
##' @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.
##'
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)
@lgatto
lgatto / insert-code-chunk.el
Last active January 7, 2021 18:28
Insert appropriate code chunk in emacs buffer
(defun insert-md-code-chunk ()
"Insert Rmd code chunk"
(interactive)
(insert "```\n\n```")
(backward-char 4))
(defun insert-rmd-code-chunk ()
"Insert Rmd code chunk"
(interactive)
(insert "```{r}\n\n```")
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
@lgatto
lgatto / annot_filter.R
Created May 12, 2019 19:05
Generic annotation filter
setClass("CharacterVariableFilter",
contains = "CharacterFilter")
setClass("NumericVariableFilter",
contains = "DoubleFilter")
VariableFilter <- function(field,
value,
condition = "==") {
if (is.numeric(value))
@lgatto
lgatto / gist:6f6facde55ab9e313753b4d92faa021a
Created November 23, 2018 10:34 — forked from ajstewartlang/gist:89dcdf01c4512a213141a16e9243626d
Hacked together code for animated raincloud plots for N=20 and N=500 where no difference exists in underlying populations
#Usimg @micahgallen's nice raincloud plot code
#and fork of benmarwick/geom_flat_violin.R code
devtools::install_github('thomasp85/gganimate')
library(tidyverse)
library(gganimate)
library(RColorBrewer)
library(plyr)
#the following is a fork of benmarwick/geom_flat_violin.R
@lgatto
lgatto / installR.sh
Created October 17, 2018 07:06
R installation script
#!/bin/bash
if [ -z "$1" ]; then
WHICH=patched
else
WHICH=$1
fi
## (1) set up variables
case $WHICH in
@lgatto
lgatto / prcomp.R
Last active December 8, 2017 16:53
All PCs and %age vars
pca <- prcomp(exprs(object), scale = TRUE, center = TRUE)
pcadata <- pca$x
vars <- (pca$sdev)^2
vars <- vars / sum(vars) * 100
@lgatto
lgatto / make_sticker.R
Created March 8, 2017 21:04
Create a Bioc-sticker.
##' This function can be used to create a hexagonal sticker following
##' the guidelines described in the BioC-sticker sticker
##' repository. The function requires the following packages: ggplot2,
##' ggforce, ggtree, showtext and grid, if lattice objects are used.
##'
##' @title Create a BioC sticker.
##' @param x The package logo. Can either be a ggplot, lattice or grob
##' object.
##' @param package Package name, to be used as label on the
##' sticker. Default is "MyPackage".