Skip to content

Instantly share code, notes, and snippets.

View stephenturner's full-sized avatar

Stephen Turner stephenturner

View GitHub Profile
@stephenturner
stephenturner / deploy.sh
Created June 9, 2016 17:51 — forked from klmr/deploy.sh
Deploy a generated GitHub page (`_site` subfolder)
#!/usr/bin/env bash
# Configuration
remote_target=master
destination=_site
get-working-branch() {
git status | head -n 1 | awk '{ print $NF }'
}
@stephenturner
stephenturner / gh-pages-deploy.md
Created June 9, 2016 17:44 — forked from cobyism/gh-pages-deploy.md
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](http://yeoman.io).

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).

# The hook
```{r}
library(knitr)
knitr::knit_hooks$set(source = function(x, options){
if (!is.null(options$verbatim) && options$verbatim){
opts = gsub(",\\s*verbatim\\s*=\\s*TRUE\\s*", "", options$params.src)
bef = sprintf('\n\n ```{r %s}\n', opts, "\n")
stringr::str_c(
bef,
@stephenturner
stephenturner / txt
Last active November 25, 2017 15:43
Uses the http://textbelt.com/ API to send a text message.
#!/bin/bash
# Uses the http://textbelt.com/ API to send a text message.
# The PHONE environment variable must be set, e.g., in your .bashrc., e.g.
# export PHONE=1234567890
# Usage: txt "<a text message to send>"
# Example 1
# When long_running_command is done successfully, this command
@stephenturner
stephenturner / tucr.grch38.bed.tsv
Last active June 10, 2016 04:34
Translated Ultra Conserved Regions (TUCRs) lifted to GRCh38 from data at http://ucbase.unimore.it/
1 10537640 10537846 uc.1
1 10672486 10672692 uc.2
1 10691108 10691332 uc.3
1 10698192 10698550 uc.4
1 10721294 10721507 uc.5
1 10735064 10735364 uc.6
1 10776076 10776331 uc.7
1 10791761 10791976 uc.8
1 10865353 10865554 uc.9
1 108697806 108698069 uc.36
library(rvest)
library(dplyr)
library(readr)
# How many pages do you want to harvest (currently over 10,000 available)
npages <- 5
for (i in 1:npages) {
# If first time through the loop, initialize list to hold results
if (i==1) d <- list()
# Report progress
> library(dplyr)
>
> d1 <- data_frame(gene=c("g1", "g2", "g3"), expr=c(10, 20, 30))
> d1
Source: local data frame [3 x 2]
gene expr
(chr) (dbl)
1 g1 10
2 g2 20
@stephenturner
stephenturner / mergett.r
Created January 19, 2016 21:26
# Function to merge topTable output with original expression values
# Function to merge topTable output with original expression values
mergett <- function(tt, eset) {
if (class(tt)!="data.frame") stop("tt should be a data.frame")
if (class(eset)!="ExpressionSet") stop("eset should be an ExpressionSet")
exprset <- data.frame(exprs(eset))
exprset$ID <- rownames(exprset)
rownames(exprset) <- NULL
print(paste("nrow(tt):", nrow(tt)))
print(paste("nrow(exprset):", nrow(exprset)))
if (nrow(tt)==nrow(exprset)) {
@stephenturner
stephenturner / ensembl_to_all_symbols.R
Created January 15, 2016 20:05
gets gene symbols for all ensembl gene ids
library(dplyr)
library(AnnotationDbi)
library(org.Mm.eg.db)
ls("package:org.Mm.eg.db")
entrez2alias <- org.Mm.egALIAS2EG %>%
as.list %>%
unlist %>%
data_frame(entrez=., alias=names(.))
head(entrez2alias)
human mouse
A1BG A1bg
A1CF A1cf
A2LD1 A2ld1
A2M A2m
A4GALT A4galt
A4GNT A4gnt
AAAS Aaas
AACS Aacs
AADAC Aadac