comparison region_motif_compare.r @ 31:0e031bf8c5b1 draft

Uploaded
author jeremyjliu
date Wed, 04 Feb 2015 13:52:22 -0500
parents 4439b2ed86e9
children 9525574f700f
comparison
equal deleted inserted replaced
30:da0bc6dead0d 31:0e031bf8c5b1
2 # Description: Reads in two count files and determines enriched and depleted 2 # Description: Reads in two count files and determines enriched and depleted
3 # motifs (or any location based feature) based on poisson tests and gc 3 # motifs (or any location based feature) based on poisson tests and gc
4 # corrections. All enrichment ratios relative to overall count / gc ratios. 4 # corrections. All enrichment ratios relative to overall count / gc ratios.
5 # Author: Jeremy liu 5 # Author: Jeremy liu
6 # Email: jeremy.liu@yale.edu 6 # Email: jeremy.liu@yale.edu
7 # Date: 14/07/03 7 # Date: 15/02/04
8 # Note: This script is meant to be invoked with the following command 8 # Note: This script is meant to be invoked with the following command
9 # R --slave --vanilla -f ./region_motif_compare.r --args <workingdir> <db> <intab1> <intab2> 9 # R --slave --vanilla -f ./region_motif_compare.r --args <workingdir> <db> <intab1> <intab2>
10 # <enriched_tab> <depleted_tab> <plots_png> 10 # <enriched_tab> <depleted_tab> <plots_png>
11 # <workingdir> is working directory of galaxy installation 11 # <workingdir> is working directory of galaxy installation
12 # <db> types: "t" test, "p" pouya, "j" jaspar jolma, "m" mouse, "c" combined 12 # <db> types: "t" test, "p" pouya, "j" jaspar jolma, "m" mouse, "c" combined
22 options(warn=-1) 22 options(warn=-1)
23 23
24 # Set common and data directories 24 # Set common and data directories
25 args <- commandArgs() 25 args <- commandArgs()
26 workingDir = args[7] 26 workingDir = args[7]
27 dbDir = concat(workingDir, "/region_motif_db")
28 dbCode = args[8] 27 dbCode = args[8]
29 # dbCode "c" implemented when pwmFile is loaded 28 # dbCode "c" implemented when pwmFile is loaded
30 if (dbCode == "t" | dbCode == "p") { 29 if (dbCode == "t" | dbCode == "p") {
31 pwmFile = concat(dbDir, "/pwms/pouya.pwms.from.seq.RData") 30 pwmFile = concat(workingDir, "/pwms/pouya.pwms.from.seq.RData")
32 } else if (dbCode == "j") { 31 } else if (dbCode == "j") {
33 pwmFile = concat(dbDir, "/pwms/jaspar.jolma.pwms.from.seq.RData") 32 pwmFile = concat(workingDir, "/pwms/jaspar.jolma.pwms.from.seq.RData")
34 } else if (dbCode == "m") { 33 } else if (dbCode == "m") {
35 pwmFile = concat(dbDir, "/pwms/mm9.pwms.from.seq.RData") 34 pwmFile = concat(workingDir, "/pwms/mm9.pwms.from.seq.RData")
36 } else if (dbCode == "c") { # rest of dbCode "c" implemeted when pwmFile loaded 35 } else if (dbCode == "c") { # rest of dbCode "c" implemeted when pwmFile loaded
37 pwmFile = concat(dbDir, "/pwms/pouya.pwms.from.seq.RData") 36 pwmFile = concat(workingDir, "/pwms/pouya.pwms.from.seq.RData")
38 pwmFile2 = concat(dbDir, "/pwms/jaspar.jolma.pwms.from.seq.RData") 37 pwmFile2 = concat(workingDir, "/pwms/jaspar.jolma.pwms.from.seq.RData")
39 } else { 38 } else {
40 pwmFile = concat(dbDir, "/pwms/pouya.pwms.from.seq.RData") 39 pwmFile = concat(workingDir, "/pwms/pouya.pwms.from.seq.RData")
41 } 40 }
42 41
43 # Set input and reference files 42 # Set input and reference files
44 inTab1 = args[9] 43 inTab1 = args[9]
45 inTab2 = args[10] 44 inTab2 = args[10]
46 enrichTab = args[11] 45 enrichTab = args[11]
47 depleteTab = args[12] 46 depleteTab = args[12]
48 plotsPng = args[13] 47 plotsPng = args[13]
49 48
50 # Load dependencies 49 # Load dependencies
51 source(concat(workingDir, "/region_motif_lib/plotting.r")) 50 source(concat(workingDir, "/plotting.r"))
52 51
53 # Auxiliary function to read in tab file and prepare the data 52 # Auxiliary function to read in tab file and prepare the data
54 read_tsv <- function(file) { 53 read_tsv <- function(file) {
55 data = read.table(file, sep="\t", stringsAsFactors=FALSE) 54 data = read.table(file, sep="\t", stringsAsFactors=FALSE)
56 names(data)[names(data) == "V1"] = "motif" 55 names(data)[names(data) == "V1"] = "motif"