Skip to content

Instantly share code, notes, and snippets.

@mikelove
mikelove / deseq2_curves.R
Created June 15, 2023 06:17
Drawing DESeq2 fitted spline curves on top of scaled counts
library(splines)
library(DESeq2)
# make some demo data
dds <- makeExampleDESeqDataSet(n=100, m=40)
dds$condition <- sort(runif(40))
# make one gene where expression has a curve shape (just for demo)
s_shape <- round(500 * sin(dds$condition*2*pi) + 1000 + rnorm(40,0,50))
mode(s_shape) <- "integer"
counts(dds)[1,] <- s_shape
@JosiahParry
JosiahParry / check_missing_value.R
Last active December 16, 2022 15:36
Checks if there are missing value tags in any man pages
# Function to run to check if you have any missing `\value{}` tags
check_missing_value <- function(pkg = ".") {
pkg_root <- rprojroot::find_package_root_file(path = pkg)
# find exported functions
ns <- readLines(file.path(pkg_root, "NAMESPACE"))
exports <- ns[which(grepl("export", ns))]
# https://stackoverflow.com/questions/8613237/extract-info-inside-all-parenthesis-in-r
exported_fxs <- stringr::str_extract(exports, "(?<=\\().+?(?=\\))")
# parse all man pages
@strengejacke
strengejacke / .lintr
Last active October 29, 2024 23:21
VS Code setup for R
// save to windows-user directory
linters: with_defaults(object_name_linter = NULL,
object_length_linter(50),
commented_code_linter = NULL,
object_usage_linter = NULL,
line_length_linter(120),
cyclocomp_linter = cyclocomp_linter(50))
@notheotherben
notheotherben / starship.toml
Created November 11, 2021 15:28
A Powerline configuration for Starship.rs
format = """
[\uE0B6](fg:#1C4961)[$directory](bg:#1C4961)[\uE0B0](fg:#1C4961 bg:#2F79A1)$git_branch[\uE0B0](fg:#2F79A1 bg:#3A95C7)$git_status[\uE0B0](#3A95C7 bg:#40A9E0)$time[\uE0B0](#40A9E0 bg:none) $all$character """
add_newline = true
[directory]
style = "bg:#1C4961 fg:white"
[git_branch]
format = "[ $symbol$branch ]($style)"
@obihill
obihill / Makefile-libbz2_dylib
Created April 20, 2021 12:46
Makefile to create shared library for libbz2 on MacOS
# This Makefile builds a shared version of the library,
# libbz2.dylib for MacOSX x86 (10.13.4 or higher),
# with gcc-2.96 20000731 (Red Hat Linux 7.1 2.96-98).
# It is a custom Makefile. Use at own risk.
# Run in your MacOS terminal with the following command:
# make -f Makefile-libbz2_dylib
PKG_VERSION?=1.0.8
PREFIX?=/usr/local
library(recount)
library(edgeR)
#/ Get the counts from GTEx via recount as a SummarizedExperiment
#/ => 1.3GB file
options(timeout=600)
download_study("SRP012682", type = "rse-gene")
load(file.path("SRP012682", "rse_gene.Rdata"))
#/ remove whitespaces in tissue names:
@ATpoint
ATpoint / guides_angles.R
Last active September 24, 2021 10:35
No more messing with h/vjust when rotating labels
library(ggplot2)
library(reshape2)
library(egg)
# thanks to https://stackoverflow.com/questions/1330989/rotating-and-spacing-axis-labels-in-ggplot2/60650595#60650595
dat<-reshape2::melt(data.frame(groupA=rnorm(20),
groupB=rnorm(20),
groupC=rnorm(20)))
@fkraeutli
fkraeutli / downloadGitLfsFiles.md
Last active October 10, 2024 05:29
How to download GIT LFS files

How to retrieve GIT LFS files from GitHub

Retrieving non-LFS files

Through the GitHub API it is possible to retrieve individual files from a Git repository via, e.g. curl. To do so, first retrieve the content information for the relevant file (or folder):

curl https://api.github.com/repos/{organisation}/{repository}/contents/{file or folder path}

For private repositories, authenticate using your username and a personal access token

@kelly-sovacool
kelly-sovacool / ggplot_function_reprex.R
Last active August 11, 2023 14:38
How to write a function to add multiple ggproto objects to a ggplot
#' ---
#' output:
#' md_document:
#' pandoc_args:
#' - '--from=markdown-implicit_figures'
#' - '--to=commonmark'
#' - '--wrap=preserve'
#' ---
@tekin
tekin / .gitattributes
Last active July 9, 2024 20:31
An example .gitattributes file that will configure custom hunk header patterns for some common languages and file formats. See https://tekin.co.uk/2020/10/better-git-diff-output-for-ruby-python-elixir-and-more for more details.
# Stick this in your home directory and point your Global Git config at it by running:
#
# $ git config --global core.attributesfile ~/.gitattributes
#
# See https://tekin.co.uk/2020/10/better-git-diff-output-for-ruby-python-elixir-and-more for more details
*.c diff=cpp
*.h diff=cpp
*.c++ diff=cpp
*.h++ diff=cpp