This file contains 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 the hadleyverse | |
install.packages(c("dplyr","tidyr","stringr", "ggplot2", "reshape2", "httr", "readxl"), repos = 'http://cran.us.r-project.org') | |
# Other useful R Packages | |
install.packages(c("rio", "data.table", "knitr", "RColorBrewer", "RCurl", "readr"), repos = 'http://cran.us.r-project.org') | |
# Install bioconductor | |
source("http://bioconductor.org/biocLite.R") | |
biocLite() |
This file contains 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
# I am trying to make R a little easier by adding a few helper functions. Most of these mimic functionality seen in Stata. | |
# This function attempts to mimic the order command in Stata; | |
# Usage: | |
# df <- corder(df,<list of columns>) | |
# Order variables in a data frame. | |
corder <- function(df,...) { | |
cols <-as.vector(eval(substitute((alist(...)))),mode="character") |
This file contains 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
wget 'ftp://ftp.ncbi.nih.gov/pub/HomoloGene/current/homologene.data' | |
egrep "\t9606\t" homologene.data | sort | cut -f 1,3,4 > human.txt | |
egrep "\t6239\t" homologene.data | sort | cut -f 1,3,4 > celegans.txt | |
join -1 1 -2 1 -t $'\t' human.txt celegans.txt | cut -f 2,3,4,5 | sort | echo -e "Human_Entrez\tHuman_Symbol\tElegans_Entrez\tElegans_Symbol\n$(cat -)" > orthologs.txt | |
rm human.txt celegans.txt homologene.data |
This file contains 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/python | |
import re | |
from itertools import groupby as g | |
import subprocess | |
import sys | |
from collections import OrderedDict | |
def most_common(L): | |
return max(g(sorted(L)), key=lambda(x, v):(len(list(v)),-L.index(x)))[0] |
This file contains 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
function SRX_fetch_fastq() { | |
sra_set=`esearch -db sra -query $1 | efetch -format docsum | xtract -element Run@acc` | |
echo "Downloading Run $1:" | |
echo ${sra_set} | |
echo "-------" | |
for SRA in $sra_set; do | |
echo "Downloading $SRA" | |
fastq-dump $SRA | |
done; | |
} |
This file contains 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(stringr) | |
library(dplyr) | |
""" | |
# Generate concatenated worm_track data using the following | |
for folder in `ls -d *\/`; do | |
for file in `ls $folder/worm*`; do | |
cat $file | awk -v file=$file '{print file","$1}' >> worm_track_all.txt | |
done; | |
done; | |
""" |
This file contains 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
import os, subprocess, uuid, re | |
import vcf.filters | |
class bcf(file): | |
def __init__(self, file): | |
# Start by storing basic information about the vcf/bcf | |
self.file = file | |
self.ops = [] |
This file contains 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(RISmed) | |
library(parallel) | |
library(ggplot2) | |
# Given two lists of terms, lets see how 'hot' they are together | |
set1 <- c("ebola","autoimmune","Diabetes","HIV","Glioblastoma","Asthma","Schizophrenia") | |
set2 <- c("C. elegans","D. Melanogaster","C. japonica", "M. Musculus","S. Cerevisiae") | |
# Generate all possible pairs | |
pairs <- expand.grid(set1, set2, stringsAsFactors=F) |
This file contains 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
/** | |
* Get a user's name, by accessing contacts. | |
* | |
* @returns {String} FullName, or UserID | |
* if record not found in contacts. | |
*/ | |
function getUserName(email){ | |
var user = ContactsApp.getContact(email); | |
// If user in contacts, return their name |
This file contains 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/usr/python | |
''' | |
Heterozygote Polarization Script | |
usage: | |
bcftools view -M 2 <filename> | python het_polarization.py | bcftools view -O b > <filename.het.polarized.bcf> | |
Tags variants 'pushed' to ref or alt as follows: | |
AA - Pushed towards reference | |
AB - Kept as het |
OlderNewer