This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create a color bar and breaks that center at a specific value | |
# Source: https://stackoverflow.com/a/10986203 | |
colorbar <- function(min, max, threshold=0, palette="RdBu", palette_length=15) { | |
pal <- rev(brewer.pal(9, palette)) | |
# Get all possible breaks | |
my_breaks <- seq(min, max, length.out=palette_length) | |
# Get number of breaks above threshold and below threshold | |
above <- length(which(my_breaks > threshold)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Backup R Markdown authored HTML files to a "notebook" sub-directory and add | |
# a timestamp to the HTML file | |
# | |
# e.g. | |
# R_analysis.html -> notebook/R_analysis.2015-02-12.html | |
# | |
# If file is version controlled, then a short commit hash is also added. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from __future__ import print_function | |
from six import iteritems | |
import sys | |
import os | |
import os.path | |
import re | |
import argparse | |
import pandas as pd |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Split a data frame into k subsets | |
# | |
# Returns a list of subsetted data frames of equal (or as close to equal as | |
# possible) size. If the data frame cannot be split equally by k, then the | |
# remainder will be adding to the last k'th subset. User can also request | |
# to put the remainder in an additional k+1 subset. | |
# | |
# This is basically a wrapper around split(), but helps calculate the remainder, | |
# if necessary. | |
split_k <- function(x, k, remainder_as_additional = FALSE) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Source: http://stackoverflow.com/a/9314880 | |
color.bar <- function(lut, min, max=-min, nticks=11, ticks=seq(min, max, len=nticks), title='') { | |
scale = (length(lut))/(max-min) | |
# dev.new(width=1.75, height=5) | |
plot(c(0,10), c(min,max), type='n', bty='n', xaxt='n', xlab='', yaxt='n', ylab='', main=title) | |
axis(2, round(ticks, 2), las=1) | |
for (i in 1:(length(lut))) { | |
y = (i-1)/scale + min | |
rect(0,y,10,y+1/scale, col=lut[i], border=NA) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(readr) | |
library(dplyr) | |
library(tm) | |
library(wordcloud) | |
library(SnowballC) | |
library(RColorBrewer) | |
m <- read_csv("node_table.csv.gz") %>% | |
filter(EM1_fwer_qvalue_dataset1 < 0.5, EM1_gs_size_dataset1 > 95) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
N=4 # Chunk size | |
C=0 # Counter | |
for i in {1..12}; | |
do | |
# submitjob here... | |
echo $i | |
((C=C+1)) | |
if [[ `expr $C % $N` == 0 ]]; then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
check_exit_status() { | |
# Checks the latest exit status and exits if status is non-zero | |
# usage: check_exit_status $? "my_function" | |
EXITSTAT=$1 | |
FUNC=$2 | |
if [ "$EXITSTAT" -ne "0" ]; then | |
echo "=> ["`date`"] $FUNC failed" | |
exit $EXITSTAT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# these examples rely on the R/qtl package, www.rqtl.org | |
# install R/qtl package, within R, by typing install.packages("qtl") | |
all: knitr_example.html knitr_example_asciidoc.html knitr_example.pdf markdown_example.html | |
R_OPTS=--no-save --no-restore --no-init-file --no-site-file # vanilla, but with --environ | |
knitr_example.html: knitr_example.Rmd | |
R ${R_OPTS} -e 'library(knitr);knit2html("knitr_example.Rmd")' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#install if necessary | |
source("http://bioconductor.org/biocLite.R") | |
biocLite("seqLogo") | |
biocLite("Biostrings") | |
library(seqLogo) | |
library(Biostrings) | |
strings <- c("GATTACA", "GATAACA", "GATAAAA", "GATTAGA") |
NewerOlder