annotate methylGSA.R @ 1:51dbd3d869ce draft default tip

Uploaded
author mora-lab
date Thu, 20 May 2021 08:44:37 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
1 ###############################################################################
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
2 # title: MethylGSA
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
3 # author: Xiaowei
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
4 # time: Mar.31 2021
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
5 ###############################################################################
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
6
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
7 spec <- matrix(c("data_file", "D",1, "character", "txt file",
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
8 "test_method","M",1,"character", "Test method",
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
9 "array_type","T",1,"character","Array type, 450K, EPCI",
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
10 "group","G",1,"character","group: all, body, promoter1, promoter2",
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
11 "GS_list","L",1,"character","Gene Set tested: Gene Ontology, KEGG, Reactome",
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
12 "minsize","I",1,"integer", "Minimum gene set size",
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
13 "maxsize","A",1,"integer", "Maximum gene set size",
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
14 "result", "R", 1, "character", "result table"
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
15 ), byrow = TRUE, ncol = 5)
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
16
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
17 opt <- getopt::getopt(spec)
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
18
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
19
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
20 # #===========================================================================
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
21 # #输入的参数
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
22 # #===========================================================================
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
23 # # txt文件
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
24 # opt$data_file
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
25 # opt$test_method
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
26 # opt$array_type
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
27 # opt$group
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
28 # opt$GS_list
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
29 # opt$minsize
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
30 # opt$maxsize
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
31
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
32
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
33 temp = read.table(opt$data_file)
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
34 cpg.pval1 = temp[,2]
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
35 names(cpg.pval1) = temp[,1]
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
36 inputmethod = opt$test_method
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
37
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
38 #================================================================
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
39 #run codes
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
40 #================================================================
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
41 suppressPackageStartupMessages(library(methylGSA))
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
42
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
43
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
44 if(opt$array_type=="450K"){
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
45 suppressMessages(library(IlluminaHumanMethylation450kanno.ilmn12.hg19))
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
46 }else{
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
47 suppressMessages(library(IlluminaHumanMethylationEPICanno.ilm10b4.hg19))
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
48 }
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
49
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
50 if(inputmethod == "methylglm"){
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
51 res <- methylglm(cpg.pval = cpg.pval1, array.type = opt$array_type,
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
52 group = opt$group, GS.list=NULL,
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
53 GS.idtype = "SYMBOL", GS.type = opt$GS_list,
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
54 minsize = opt$minsize, maxsize = opt$maxsize)
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
55
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
56 }
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
57
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
58 if(inputmethod == "RRA_ORA"){
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
59 res <- methylRRA(cpg.pval = cpg.pval1, array.type = opt$array_type,
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
60 group = opt$group, method = "ORA",
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
61 GS.list=NULL, GS.idtype = "SYMBOL", GS.type = opt$GS_list,
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
62 minsize = opt$minsize, maxsize = opt$maxsize)
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
63 }
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
64
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
65 if(inputmethod == "RRA_GSEA"){
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
66 res <- methylRRA(cpg.pval = cpg.pval1, array.type = opt$array_type,
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
67 group = opt$group, method = "GSEA",
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
68 GS.list=NULL, GS.idtype = "SYMBOL", GS.type = opt$GS_list,
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
69 minsize = opt$minsize, maxsize = opt$maxsize)
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
70 }
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
71
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
72 if(inputmethod == "gometh"){
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
73 res <- methylgometh(cpg.pval = cpg.pval1, sig.cut = 0.001, array.type = opt$array_type,
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
74 GS.list=NULL, GS.idtype = "SYMBOL", GS.type = opt$GS_list,
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
75 minsize = opt$minsize, maxsize = opt$maxsize)
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
76 }
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
77
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
78 #===============================================================================
51dbd3d869ce Uploaded
mora-lab
parents:
diff changeset
79 write.csv(res, file = opt$result)