Skip to content

Instantly share code, notes, and snippets.

View al2na's full-sized avatar
💭
fishing 🎣

Altuna Akalin al2na

💭
fishing 🎣
View GitHub Profile
p300.url="http://hgdownload.cse.ucsc.edu/goldenPath/hg19/encodeDCC/wgEncodeAwgTfbsUniform/wgEncodeAwgTfbsHaibH1hescP300V0416102UniPk.narrowPeak.gz"
Nanog.url="http://hgdownload.cse.ucsc.edu/goldenPath/hg19/encodeDCC/wgEncodeAwgTfbsUniform/wgEncodeAwgTfbsHaibH1hescNanogsc33759V0416102UniPk.narrowPeak.gz"
SP1.url="http://hgdownload.cse.ucsc.edu/goldenPath/hg19/encodeDCC/wgEncodeAwgTfbsUniform/wgEncodeAwgTfbsHaibH1hescSp1Pcr1xUniPk.narrowPeak.gz"
chrHMM.url="http://hgdownload.cse.ucsc.edu/goldenPath/hg19/encodeDCC/wgEncodeBroadHmm/wgEncodeBroadHmmH1hescHMM.bed.gz"
#http://hgdownload.cse.ucsc.edu/goldenPath/hg19/encodeDCC/wgEncodeAwgSegmentation/wgEncodeAwgSegmentationChromhmmH1hesc.bed.gz"
# get chromHMM annotation and make a list out of it
@al2na
al2na / annotateWithFeatures.R
Last active June 10, 2020 09:31
new annotation functions for genomation,
library(data.table)
library(genomation)
library(ggplot2)
#' Annotate given ranges with genomic features
#'
#' The function annotates a target GRangesList or GRanges object as overlapping
#' or not with
#' the elements of named GRangesList. This is useful to annotate your regions
@al2na
al2na / readBismarkFiles.R
Last active August 30, 2023 15:47
read Bismark coverage and cytosine report files as methylKit objects
#' Read bismark coverage file as a methylKit object
#'
#' Bismark aligner can output methylation information per base in
#' multiple different formats. This function reads coverage files,
#' which have chr,start,end, number of cytosines (methylated bases)
#' and number of thymines (unmethylated bases).
#'
#' @param location a list or vector of file paths to coverage files
#'
#' @param sample.id a list or vector of sample ids
@al2na
al2na / .gitignore
Created September 28, 2015 10:00 — forked from hadley/.gitignore
Benchmark different ways of reading a file
.Rproj.user
.Rhistory
.RData
*.Rproj
*.html
@al2na
al2na / methSegDemo.R
Last active August 29, 2015 14:23
methseg usage and installation
download.file("https://dl.dropboxusercontent.com/u/1373164/H1.chr21.chr22.rds",destfile="H1.chr21.chr22.rds",method="curl")
mbw=readRDS("H1.chr21.chr22.rds")
# it finds the optimal number of componets as 6
res=methSeg(mbw,diagnostic.plot=TRUE,maxInt=100,minSeg=10)
# however the BIC stabilizes after 4, we can also try 4 componets
res=methSeg(mbw,diagnostic.plot=TRUE,maxInt=100,minSeg=10,G=1:4)
# get segments to BED file
@al2na
al2na / scatterNVD3.R
Last active August 29, 2015 14:19
rcharts NVD3 scatterplot with different shapes and color code adjustment. Works in reveal.js slides
y=readRDS("data/othersmRNA.pca.table.rds")
p1=nPlot(PC2 ~ PC1, data = y,group="cellDisease", type = "scatterChart",
filter="disease")
p1$xAxis(axisLabel = 'PC1')
p1$yAxis(axisLabel = 'PC2')
p1$chart(color = y$color) # color for each dot
p1$chart(sizeRange = c(100,100)) # for dot sizes

This document shows how to use packrat to create reproducible R projects. packrat allows reproducuiblty of R code in an OS independent manner. First we need to install the packrat package.

install.packages("packrat")
setwd("~/mdc_desktop_projects/packrat_trial3")

now we can initialize the packrat project. This will create local directories for packages and .Rprofile file. Whenever we run R in this directory, we will be using locally installed R packages and even if we copy this directory to some other computer (even with different OS) we will still have the same setup.

@al2na
al2na / readMethylRawList.para.R
Created January 3, 2015 12:26
read files in parallel
library(foreach)
library(methylKit)
library(doMC)
registerDoMC(2)
file.list=list( system.file("extdata", "test1.myCpG.txt", package = "methylKit"),
system.file("extdata", "test2.myCpG.txt", package = "methylKit"),
system.file("extdata", "control1.myCpG.txt", package = "methylKit"),
system.file("extdata", "control2.myCpG.txt", package = "methylKit") )
ids=c("test1","test2","ctrl1","ctrl2")
#!/bin/bash
#$ -N run_bowtie
#$ -cwd
#$ -pe smp 2
#$ -l h_vmem=6G
infile=/data/bioinfo/genome_data/sample.ce10.fastq
outfile=~/my.alignment.sam
btindex=/data/bioinfo/genome_data/Caenorhabditis_elegans/UCSC/ce10/Sequence/BowtieIndex/genome