Skip to content

Instantly share code, notes, and snippets.

View DarwinAwardWinner's full-sized avatar

Ryan C. Thompson DarwinAwardWinner

View GitHub Profile
@DarwinAwardWinner
DarwinAwardWinner / Example_output.txt
Last active August 29, 2015 14:17
A script to check whether Ash is doing a Sister Claire live-write and print the URL
The latest Sister Claire live-write started 19 hours ago at Fri, 27 Mar 2015 17:41. The URL is:
https://docs.google.com/document/d/1qpj_QxQSRWMbd_S1PVHAM4aBpb-RrskMIqcMHS4i0F0/edit
@DarwinAwardWinner
DarwinAwardWinner / glmFit_CountDataSet.R
Created May 22, 2015 20:47
Using edgeR glmFit on DESeq CountDataSet
## The following two functions allow the use to edgeR's infrastructure
## to execute the DESeq method. Instead of glmFit(dge, design), use
## glmFit.CountDataSet(cds, design), then continue as with a normal
## edgeR analysis.
getOffset.CountDataSet <- function(y) {
if (any(is.na(sizeFactors(y))))
stop("Call estimateSizeFactors first")
log(sizeFactors(y)) - mean(log(sizeFactors(y))) + mean(log(colSums(counts(y))))
}
@DarwinAwardWinner
DarwinAwardWinner / python-bash-wrapper.py
Last active November 9, 2020 20:43
Put bash cluster setup code and python script in a single file
#!/bin/bash
# -*- mode:python -*-
#PBS -l nodes=1:ppn=8,mem=30gb
''''/bin/true
# This is bash code to set up the environment
echo "Hello from bash!"
echo "Args are: $@"
# Bash setup code ends here
python - "$@" <<EOF
''' # Python starts here '''
#!/bin/sh
# -*- mode:R -*-
#PBS -l nodes=1:ppn=8,mem=30gb
'\' >/dev/null 2>&1 || true
# This is bash code to set up the environment
echo "Hello from bash!"
echo "Args are: $@"
## This will allow you to use dplyr functions with Bioconductor's
## S4Vectors::DataFrame class. They simply call "as.data.frame" on
## DataFrame objects and then pass them to the methods for
## "data.frame". Note that this entails conversion of S4 vector
## columns to primitive vectors. No attempt is made to convert the
## results back to DataFrame, since such a conversion would not
## restore S4 vector columns that were converted to primitive vectors.
library(S4Vectors)
library(dplyr)
subsetListOfArrays <- function (object, i, j, IJ, IX, I, JX, J) {
len <- vapply(object, length, 0)
I <- intersect(I, names(len)[len > 1L])
J <- intersect(J, names(len)[len > 1L])
if (missing(i)) {
IX <- I <- character(0)
if (missing(j))
IJ <- character(0)
}
else {
@DarwinAwardWinner
DarwinAwardWinner / multiple-analyses-example.R
Created January 5, 2016 16:00
Example of running multiple variants of an analysis in R
#!/usr/bin/env Rscript
library(matrixStats)
library(plyr)
library(lubridate)
library(reshape2)
library(minfi)
library(limma)
library(sva)
library(celltypes450)
@DarwinAwardWinner
DarwinAwardWinner / # pcre2 - 2016-06-14_13-49-25.txt
Created June 14, 2016 20:52
pcre2 on "CentOS release 6.7 (Final)" - Homebrew build logs
Homebrew build logs for pcre2 on "CentOS release 6.7 (Final)"
Build date: 2016-06-14 13:49:25
@DarwinAwardWinner
DarwinAwardWinner / random-plot-order.Rmd
Last active February 1, 2017 21:22
Example of a Rmd file that produces 10 plots labeled A-J. They appear in random order in RStudio's notebook.
---
title: "Random Plot Order Test"
author: "Ryan C. Thompson"
date: "February 1, 2017"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

Keybase proof

I hereby claim:

  • I am darwinawardwinner on github.
  • I am rcthompson (https://keybase.io/rcthompson) on keybase.
  • I have a public key ASBVf3s3y1AIHHATFqG8c6WHdw8t4PpcbMIsc2slD2-XBwo

To claim this, I am signing this object: