Mercurial > repos > nturaga > minfi_analyze_tcga
annotate minfi_pipeline.R @ 1:3cd8ea4f7079 draft default tip
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
author | nturaga |
---|---|
date | Tue, 19 Apr 2016 12:21:01 -0400 |
parents | 8b26eeb2da29 |
children |
rev | line source |
---|---|
0
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
1 # setup R error handling to go to stderr |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
2 options(show.error.messages=F, error=function(){cat(geterrmessage(),file=stderr());q("no",1,F)}) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
3 |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
4 # we need that to not crash galaxy with an UTF8 error on German LC settings. |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
5 loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8") |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
6 |
1
3cd8ea4f7079
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
0
diff
changeset
|
7 install.packages('getopt', repos='http://cran.us.r-project.org') |
3cd8ea4f7079
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
0
diff
changeset
|
8 |
0
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
9 library("getopt") |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
10 options(stringAsfactors = FALSE, useFancyQuotes = FALSE) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
11 args <- commandArgs(trailingOnly = TRUE) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
12 |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
13 # get options, using the spec as defined by the enclosed list. |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
14 # we read the options from the default: commandArgs(TRUE). |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
15 spec <- matrix(c( |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
16 'quiet', 'q', 2, "logical", |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
17 'help' , 'h', 0, "logical", |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
18 "preprocess","p",1,"character", |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
19 "cores","c",1,"integer", |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
20 "numPositions","n",2,"integer", |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
21 "shrinkVar","s",2,"logical", |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
22 "b_permutations","b",2,"integer", |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
23 "smooth","m",2,"logical", |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
24 "cutoff","t",2,"double", |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
25 "l_value","l",2,"integer") |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
26 ,byrow=TRUE, ncol=4) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
27 opt <- getopt(spec) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
28 |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
29 # If help was asked for print a friendly message |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
30 # and exit with a non-zero error code |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
31 if (!is.null(opt$help)) { |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
32 cat(getopt(spec, usage=TRUE)) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
33 q(status=1) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
34 } |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
35 |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
36 |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
37 ## Set verbose mode |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
38 verbose = if(is.null(opt$quiet)){TRUE}else{FALSE} |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
39 if(verbose){ |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
40 cat("Verbose mode is ON\n\n") |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
41 } |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
42 |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
43 # Enforce the following required arguments |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
44 if (is.null(opt$preprocess)) { |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
45 cat("'--preprocess' is required\n") |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
46 q(status=1) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
47 } |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
48 cat("verbose = ", opt$quiet,"\n") |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
49 cat("preprocess = ",opt$preprocess,"\n") |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
50 cat("cores = ", opt$cores, "\n") |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
51 cat("b_permutations = ",opt$b_permutations,"\n") |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
52 cat("smooth = ",opt$smooth,"\n") |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
53 cat("cutoff = ",opt$cutoff,"\n") |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
54 cat("l_value = ",opt$l_value,"\n") |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
55 cat("numPositions = ",opt$numPositions,"\n") |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
56 cat("shrinkVar = ",opt$shrinkVar,"\n") |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
57 |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
58 |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
59 # Load required libraries |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
60 suppressPackageStartupMessages({ |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
61 library("minfi") |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
62 library("FlowSorted.Blood.450k") |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
63 library("TxDb.Hsapiens.UCSC.hg19.knownGene") |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
64 library("doParallel") |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
65 }) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
66 |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
67 |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
68 ## Parse cheetah code and make dataframe for creating tmp dir |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
69 minfi_config_file = paste0("minfi_temp","/minfi_config.txt") |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
70 minfi_config = read.table(minfi_config_file) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
71 colnames(minfi_config) = c("status","green","red","name") |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
72 |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
73 |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
74 ## Make the tmpdir for symlinking data |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
75 base_dir = paste0("minfi_temp","/base") |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
76 system(paste0("mkdir ",base_dir)) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
77 |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
78 |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
79 ## Make symlinks of files |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
80 for (i in 1:nrow(minfi_config)){ |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
81 stopifnot(nrow(minfi_config) == nrow(minfi_config["name"])) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
82 |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
83 ## Make green idat file symlinks |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
84 file_green = paste0(base_dir,"/",as.character(minfi_config[i,"name"]),"_Grn.idat") |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
85 cmd_green = paste("ln -s",as.character(minfi_config[i,"green"]),file_green,sep=" ") |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
86 cat("Reading file ",i,"GREEN Channel ", file_green) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
87 system(cmd_green) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
88 |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
89 ## Make red idat file symlinks |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
90 file_red = paste0(base_dir,"/",as.character(minfi_config[i,"name"]),"_Red.idat") |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
91 cmd_red = paste("ln -s",as.character(minfi_config[i,"red"]),file_red,sep=" ") |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
92 cat("Reading file ",i,"RED Channel ", file_red) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
93 system(cmd_red) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
94 } |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
95 |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
96 ## Make dataframe with Basenames |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
97 Basename = paste0(base_dir,"/",unique(substr(list.files(base_dir),1,17))) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
98 status = minfi_config[match(gsub(".+/","",Basename), minfi_config$name),"status"] |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
99 targets = data.frame(Basename=Basename,status=status) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
100 |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
101 if ( verbose ) { |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
102 cat("Minfi targets file:\n\n ") |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
103 print(targets) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
104 } |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
105 |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
106 ## Read 450k files |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
107 RGset = read.450k.exp(targets=targets,verbose=T) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
108 |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
109 if (verbose){ |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
110 cat("RGset has been read: \n\n") |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
111 print(RGset) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
112 } |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
113 |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
114 pd = pData(RGset) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
115 |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
116 ## NOTE: QC report is for samples before normalization |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
117 ## QC REPORT |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
118 files = gsub(".+/","",pd$filenames) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
119 ## Produce PDF file |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
120 if (!is.null(RGset)) { |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
121 # Make PDF of QC report |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
122 minfi::qcReport(rgSet=RGset,sampNames=files,sampGroups=pd$status,pdf="qc_report.pdf") |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
123 } |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
124 |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
125 |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
126 ## MDS Plot |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
127 ## Set phenotype data |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
128 files = gsub(".+/","",pd$filenames) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
129 #numPositions=as.integer("${numPositions}") |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
130 |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
131 ## Produce PDF file |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
132 if (!is.null(RGset)) { |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
133 ## Make PDF of MDS plot |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
134 pdf("mds_plot.pdf") |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
135 minfi::mdsPlot(dat=RGset,sampNames=files,sampGroups=pd$status,main="Beta MDS",numPositions = opt$numPositions,pch=19) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
136 dev.off() |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
137 } |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
138 |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
139 if(verbose){ |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
140 cat("Made plot of QC report and MDS plot\n\n") |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
141 } |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
142 |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
143 |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
144 ## Preprocess data with the normalization method chosen |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
145 if(opt$preprocess == "quantile"){ |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
146 normalized_RGset = preprocessQuantile(RGset) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
147 if (verbose){cat("Preprocessed using Quantile normalization")}; |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
148 } else if (opt$preprocess == "funnorm"){ |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
149 normalized_RGset = preprocessFunnorm(RGset) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
150 if(verbose){print("Preprocessed using Functional normalization")} |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
151 } else if (opt$preprocess == "noob"){ |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
152 normalized_RGset = preprocessNoob(RGset) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
153 if (verbose){cat("Preprocessed using Noob normalization")}; |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
154 } else if (opt$preprocess == "illumina"){ |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
155 normalized_RGset = preprocessIllumina(RGset,bg.correct = TRUE, normalize = c("controls", "no"),reference = 1) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
156 if(verbose){print("Preprocessed using Illumina normalization")} |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
157 } else if (opt$preprocess == "swan"){ |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
158 normalized_RGset = preprocessSWAN(RGset) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
159 if(verbose){print("Preprocessed using SWAN normalization")} |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
160 }else { |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
161 normalized_RGset = RGset |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
162 if(verbose){print("Preprocessed using No normalization")} |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
163 } |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
164 |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
165 |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
166 |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
167 ## Get beta values from Proprocessed data |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
168 beta = getBeta(normalized_RGset) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
169 ## Set phenotype data |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
170 pd = pData(normalized_RGset) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
171 |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
172 |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
173 ## DMP finder |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
174 dmp = dmpFinder(dat=beta,pheno=pd$status,type="categorical",shrinkVar=opt$shrinkVar) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
175 write.csv(dmp,file="dmps.csv",quote=FALSE,row.names=TRUE) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
176 if(verbose){ |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
177 cat("\n","DMP Finder successful \n") |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
178 } |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
179 |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
180 |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
181 # Model Matrix to pass into the bumphunter function |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
182 T1= levels(pd$status)[2] |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
183 T2= levels(pd$status)[1] |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
184 |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
185 # Introduce error if levels are different |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
186 stopifnot(T1!=T2) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
187 |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
188 keep=pd$status%in%c(T1,T2) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
189 tt=factor(pd$status[keep],c(T1,T2)) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
190 design=model.matrix(~tt) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
191 |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
192 if(verbose){ |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
193 cat("Model matrix is: \n") |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
194 design |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
195 } |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
196 |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
197 # Start bumphunter in a parallel environment |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
198 # Parallelize over cores on machine |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
199 registerDoParallel(cores = opt$cores) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
200 |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
201 ## Bumphunter Run with normalized_RGset processed with Quantile Normalization |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
202 if (is(normalized_RGset,"GenomicRatioSet")) { |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
203 res=bumphunter(normalized_RGset[,keep],design,B=opt$b_permutations,smooth=opt$smooth,cutoff= opt$cutoff,type="Beta") |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
204 bumps= res$tab |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
205 } else if(is(normalized_RGset,"MethylSet")) { |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
206 # convert MethylSet (norm.swan) into GenomicRatioSet through Ratioset |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
207 normalized_RGset = ratioConvert(normalized_RGset, what = "both", keepCN = TRUE) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
208 normalized_RGset = mapToGenome(normalized_RGset) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
209 res = bumphunter(normalized_RGset[,keep],design=design,B=opt$b_permutations,smooth=opt$smooth,cutoff=opt$cutoff) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
210 bumps = res$tab |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
211 } else { |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
212 # This else case is never supposed to run, |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
213 # it will run only if the normalized_RGset object |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
214 # did not have the expected class type |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
215 cat("Bumphunter did not run properly","\n") |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
216 stopifnot(!is.null(bumps)) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
217 } |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
218 |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
219 if(verbose){ |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
220 cat("Bumphunter result", "\n") |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
221 head(bumps) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
222 } |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
223 |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
224 |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
225 ## Choose DMR's of a certain length threshold. |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
226 ## This helps reduce the size of DMRs early, and match |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
227 ## with genes closest to region |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
228 bumps = bumps[bumps$L > opt$l_value,] |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
229 genes <- annotateTranscripts(TxDb.Hsapiens.UCSC.hg19.knownGene) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
230 tab=matchGenes(bumps,genes) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
231 annotated_dmrs=cbind(bumps,tab) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
232 |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
233 if(verbose){ |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
234 cat("Match with annotation\n") |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
235 head(annotated_dmrs) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
236 } |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
237 |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
238 # Save result, which contains DMR's and closest genes |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
239 write.csv(annotated_dmrs,file = "dmrs.csv",quote=FALSE,row.names=FALSE) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
240 |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
241 # Garbage collect |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
242 gc() |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
243 |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
244 |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
245 ## TODO: FIX BLOCK FINDER |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
246 # Block finder |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
247 #library(sva) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
248 #pheno <- pData(GRset) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
249 #mod <- model.matrix(~as.factor(status), data=pheno) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
250 #mod0 <- model.matrix(~1, data=pheno) |
8b26eeb2da29
planemo upload commit fb90aafc93e5e63acfcdac4c27cfd865cdf06c5a-dirty
nturaga
parents:
diff
changeset
|
251 #sva.results <- sva(mval, mod, mod0) |