Skip to content

Instantly share code, notes, and snippets.

@joowkim
joowkim / GetIndex.go
Created January 31, 2017 06:25
Get index from Hiseq Undetermined.fastq.gz
package main
import (
"fmt"
"log"
"os"
"bufio"
"strings"
"compress/gzip"
)
@joowkim
joowkim / example.py
Last active February 2, 2017 03:52
functional pp in python
input = "1+2+3++4+++5++++6+++7+++9+8+++10"
t = sum(map(int, (filter(bool, input.split("+")))))
import math
def fsum(f):
def apply(a, b):
@joowkim
joowkim / README.md
Created February 5, 2017 02:31 — forked from jdblischak/README.md
rnaseq-de-tutorial

Differential expression analysis with edgeR

This is a tutorial I have presented for the class Genomics and Systems Biology at the University of Chicago. In this course the students learn about study design, normalization, and statistical testing for genomic studies. This is meant to introduce them to how these ideas are implemented in practice. The specific example is a differential expression analysis with edgeR starting with a table of counts and ending with a list of differentially expressed genes.

Past versions:

@joowkim
joowkim / write_table.R
Last active February 23, 2017 07:50
write_table
write.table( res, file="/Analysis/deseq/Dox_vs_DMSO.differentialExpression.csv",row.names = TRUE,col.names = TRUE,append = FALSE, quote = FALSE, sep = "\t",eol = "\n")
write.table(res, "E_F.results.tsv", row.names=T, col.names = NA)
write.csv(as.data.frame(res),file='sim_condition_treated_results_deseq2.csv')
@joowkim
joowkim / run_deseq2.R
Last active March 6, 2017 02:21
deseq2 pairwise DEG
args = commandArgs(trailingOnly=TRUE)
if (length(args) != 2){
print("1 vs 2 DEG analysis for RSem output")
stop("USAGE :: Rscript this.R [1.genes.results] [2.genes.results]")
}
# assign file names
f1 <- args[1]
f2 <- args[2]
library(devtools)
library(sleuth)
library(dplyr)
library("biomaRt")
#load annotation from ensembl
ensembl = useMart("ENSEMBL_MART_ENSEMBL",dataset="mmusculus_gene_ensembl", host="www.ensembl.org")
t2g <- biomaRt::getBM(attributes = c("ensembl_transcript_id", "ensembl_gene_id", "external_gene_name"), mart = ensembl)
t2g <- dplyr::rename(t2g, target_id = ensembl_transcript_id, ens_gene = ensembl_gene_id, ext_gene = external_gene_name)
#change this directory as your directory
@joowkim
joowkim / biomart.py
Created March 13, 2017 01:48
biomart.py
import biomart
server = biomart.BiomartServer( "http://useast.ensembl.org/biomart" )
server.is_alive
@joowkim
joowkim / dplyr_tutorial.Rmd
Last active March 23, 2017 07:07
dplyr_tutorial.Rmd
---
layout: page
title: dplyr tutorial
---
```{r options, echo=FALSE}
library(knitr)
opts_chunk$set(fig.path=paste0("figure/", sub("(.*).Rmd","\\1",basename(knitr:::knit_concord$get('infile'))), "-"))
```
@joowkim
joowkim / heatmap.R
Created April 13, 2017 03:32
heatmap.R
library(ggplot2)
library(RColorBrewer)
library(reshape2)
data.frame to melt
# chnage columns names!
names(ac.df) <- c("A", "C")
colnames(ac.mat) <- c("A", "C")
@joowkim
joowkim / benchmark.py
Created May 1, 2017 04:07
시간재기 - 파이썬
import time
def benchmark(func):
def wrapper(*args, **kwargs):
t = time.clock()
res = func(*args, **kwargs)
print("\t%s" % func.__name__, time.clock() - t)
return res
return wrapper