rbbt-marq 1.1.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/R/GEO.R +6 -4
- data/R/MA.R +1 -0
- data/bin/marq_config +4 -3
- data/install_scripts/CustomDS/Rakefile +27 -215
- data/install_scripts/GEO/Rakefile +34 -275
- data/install_scripts/rake_includes.rb +236 -0
- data/lib/MARQ/CustomDS.rb +63 -32
- data/lib/MARQ/GEO.rb +99 -63
- data/lib/MARQ/MADB.rb +107 -202
- data/lib/MARQ/annotations.rb +124 -38
- data/lib/MARQ/main.rb +152 -160
- data/lib/MARQ/rankproduct.rb +20 -34
- data/tasks/install.rake +7 -2
- metadata +3 -2
data/R/GEO.R
CHANGED
@@ -9,17 +9,19 @@ GEO.get <- function(name, cachedir = NULL){
|
|
9
9
|
cachedir = paste(MARQ.config$cachedir, 'GEO', sep="/");
|
10
10
|
}
|
11
11
|
|
12
|
-
if (is.null(cachedir)){
|
12
|
+
if (is.null(cachedir) || cachedir == FALSE){
|
13
13
|
object <- getGEO(name);
|
14
14
|
}else{
|
15
|
-
filename = dir(cachedir,pattern= paste(name, 'soft', sep='.'))[1]
|
16
|
-
|
15
|
+
filename = dir(cachedir,pattern= paste(name, 'soft', sep='.'))[1];
|
16
|
+
complete_path = paste(cachedir,filename,sep="/");
|
17
|
+
if (is.na(filename) || file.info(complete_path)$size == 0){
|
17
18
|
object <- getGEO(name, destdir=cachedir);
|
18
19
|
}else{
|
19
|
-
object <- getGEO(name, filename =
|
20
|
+
object <- getGEO(name, filename = complete_path);
|
20
21
|
}
|
21
22
|
}
|
22
23
|
|
24
|
+
|
23
25
|
object
|
24
26
|
}
|
25
27
|
|
data/R/MA.R
CHANGED
@@ -307,6 +307,7 @@ MA.process <- function(m, conditions_list, two.channel = FALSE){
|
|
307
307
|
|
308
308
|
MA.save <- function(prefix, orders, ratios, t , p.values, experiments, description = NULL) {
|
309
309
|
if (is.null(orders)){
|
310
|
+
cat("No suitable samples for analysis\n")
|
310
311
|
write(file=paste(prefix,'skip',sep="."), "No suitable samples for analysis" );
|
311
312
|
} else {
|
312
313
|
write.table(file=paste(prefix,'orders',sep="."), orders, sep="\t", row.names=F, col.names=F, quote=F);
|
data/bin/marq_config
CHANGED
@@ -88,7 +88,7 @@ $USAGE =<<EOT
|
|
88
88
|
EOT
|
89
89
|
|
90
90
|
class Controller < SimpleConsole::Controller
|
91
|
-
params :string => {:p => :platform, :s => :series, :o => :organism}, :boolean => {:d => :update_db, :f => :force}, :integer => {:p => :port}
|
91
|
+
params :string => {:t => :target, :p => :platform, :s => :series, :o => :organism}, :boolean => {:d => :update_db, :f => :force}, :integer => {:p => :port}
|
92
92
|
|
93
93
|
|
94
94
|
def prepare
|
@@ -103,6 +103,7 @@ class Controller < SimpleConsole::Controller
|
|
103
103
|
$update_db = params[:update_db] && params[:update_db] =~ /true|yes|y/i
|
104
104
|
$force = params[:force] && params[:force] =~ /true|yes|y/i
|
105
105
|
@actions = params[:id] || %w(GEO)
|
106
|
+
@rake_action = params[:target] || 'default'
|
106
107
|
end
|
107
108
|
|
108
109
|
def config
|
@@ -198,10 +199,10 @@ class View < SimpleConsole::View
|
|
198
199
|
|
199
200
|
@actions.each{|action|
|
200
201
|
Thread.new{
|
201
|
-
puts "Updating #{action}"
|
202
|
+
puts "Updating #{action}. Target: #{@rake_action}"
|
202
203
|
FileUtils.cd File.join(MARQ.datadir, action)
|
203
204
|
load File.join(MARQ.datadir, action, 'Rakefile')
|
204
|
-
Rake::Task[
|
205
|
+
Rake::Task[@rake_action].invoke
|
205
206
|
}.join
|
206
207
|
}
|
207
208
|
end
|
@@ -1,223 +1,35 @@
|
|
1
1
|
require 'MARQ'
|
2
|
+
require 'MARQ/main'
|
2
3
|
require 'MARQ/CustomDS'
|
3
4
|
require 'MARQ/MADB'
|
4
5
|
require 'MARQ/annotations'
|
5
6
|
require 'progress-monitor'
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
$
|
10
|
-
$
|
11
|
-
$
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
else
|
29
|
-
missing = datasets - CustomDS::datasets(org)
|
30
|
-
end
|
31
|
-
missing.each{|d|
|
32
|
-
CustomDS::process(d)
|
33
|
-
MADB::CustomDS::save(d)
|
34
|
-
}
|
35
|
-
}
|
36
|
-
end
|
37
|
-
|
38
|
-
|
39
|
-
def annotations(name, cross_platform = false, &block)
|
40
|
-
FileUtils.mkdir_p File.join("annotations", name) unless File.exist? File.join("annotations", name)
|
41
|
-
organisms = Dir.glob(CustomDS::customdir + '/*').select{|f| File.directory? f}.collect{|f| File.basename(f)} - ["annotations"]
|
42
|
-
|
43
|
-
Progress.monitor("Annotating with #{ name }")
|
44
|
-
organisms.each{|org|
|
45
|
-
Progress.monitor("Annotating organism #{ org }")
|
46
|
-
CustomDS::datasets(org).each{|dataset|
|
47
|
-
begin
|
48
|
-
next if File.exist? File.join("annotations", name, dataset)
|
49
|
-
filename = File.join("annotations", name, dataset)
|
50
|
-
dataset += '_cross_platform' if cross_platform && GEO.has_cross_platform?(dataset)
|
51
|
-
next if File.exist? CustomDS.path(dataset) + '.skip'
|
52
|
-
terms = block.call(dataset)
|
53
|
-
Open.write(filename, terms.to_yaml)
|
54
|
-
rescue Exception
|
55
|
-
puts $!.message
|
56
|
-
end
|
57
|
-
}
|
58
|
-
}
|
59
|
-
end
|
60
|
-
|
61
|
-
def goterms(org, list, slim, threshold)
|
62
|
-
return [] if list.empty?
|
63
|
-
results = Annotations::GO::Genecodis::Local.analysis(org, list, slim)
|
64
|
-
results.
|
65
|
-
select{|info| info[:s].to_i > 2 }.
|
66
|
-
select{|info| info[:hyp_c].to_f < threshold }.
|
67
|
-
collect{|info| info[:items]}.collect{|id| GO::id2name(id)}
|
68
|
-
end
|
69
|
-
|
70
|
-
|
71
|
-
task 'annotate_Words' do
|
72
|
-
FileUtils.mkdir_p "annotations/Words"
|
73
|
-
require 'rbbt/bow/bow'
|
74
|
-
organisms = Dir.glob(CustomDS::customdir + '/*').select{|f| File.directory? f}.collect{|f| File.basename(f)} - ["annotations"]
|
75
|
-
organisms.each{|org|
|
76
|
-
CustomDS::datasets(org).each{|dataset|
|
77
|
-
begin
|
78
|
-
next if File.exist? "annotations/Words/#{ dataset }"
|
79
|
-
next if File.exist? CustomDS.path(dataset) + '.skip'
|
80
|
-
|
81
|
-
terms = {}
|
82
|
-
description = Open.read(CustomDS.path(dataset) + '.description')
|
83
|
-
terms[:dataset] = [dataset] + description.words
|
84
|
-
Open.read(CustomDS.path(dataset) + '.experiments').collect{|name|
|
85
|
-
name = name.strip
|
86
|
-
terms[name] = name.sub(/\[ratio\]/,'').words
|
87
|
-
}
|
88
|
-
|
89
|
-
Open.write("annotations/Words/#{ dataset }", terms.to_yaml)
|
90
|
-
|
91
|
-
rescue Exception
|
92
|
-
puts $!.message
|
93
|
-
end
|
94
|
-
}
|
95
|
-
}
|
96
|
-
end
|
97
|
-
|
98
|
-
task 'annotate_UMLS' do
|
99
|
-
FileUtils.mkdir_p "annotations/UMLS"
|
100
|
-
organisms = Dir.glob(CustomDS::customdir + '/*').select{|f| File.directory? f}.collect{|f| File.basename(f)} - ["annotations"]
|
101
|
-
organisms.each{|org|
|
102
|
-
CustomDS::datasets(org).each{|dataset|
|
103
|
-
begin
|
104
|
-
next if File.exist? "annotations/UMLS/#{ dataset }"
|
105
|
-
next if File.exist? CustomDS.path(dataset) + '.skip'
|
106
|
-
terms = {}
|
107
|
-
description = Open.read(CustomDS.path(dataset) + '.description')
|
108
|
-
terms[:dataset] = Annotations::UMLS::OBA(description)
|
109
|
-
Open.read(CustomDS.path(dataset) + '.experiments').collect{|name|
|
110
|
-
name = name.strip
|
111
|
-
terms[name] = Annotations::UMLS::OBA(name)
|
112
|
-
}
|
113
|
-
Open.write("annotations/UMLS/#{ dataset }", terms.to_yaml)
|
114
|
-
rescue Exception
|
115
|
-
puts $!.message
|
7
|
+
require File.join(File.dirname(File.dirname(__FILE__)), 'rake_includes')
|
8
|
+
|
9
|
+
|
10
|
+
$platform ||= ENV['platform']
|
11
|
+
$organism ||= [$organism, ENV['organism'], nil].compact.first
|
12
|
+
$dataset ||= ENV['dataset']
|
13
|
+
|
14
|
+
def process_list
|
15
|
+
list = {}
|
16
|
+
organisms = $organism ? [$organism] : Organism.all(true)
|
17
|
+
|
18
|
+
# Find candidate datasets
|
19
|
+
case
|
20
|
+
when $dataset
|
21
|
+
list[$dataset] = [$dataset]
|
22
|
+
when $platform
|
23
|
+
list[$platform] = [$platform]
|
24
|
+
else
|
25
|
+
organisms.each do |organism|
|
26
|
+
platforms = CustomDS.organism_platforms(organism)
|
27
|
+
platforms.each do |platform|
|
28
|
+
list[platform] = platform
|
116
29
|
end
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
task 'annotate_Words' do
|
126
|
-
annotations('Words'){|dataset|
|
127
|
-
description = Open.read(CustomDS.path(dataset) + '.description')
|
128
|
-
terms[:dataset] = [dataset] + description.words
|
129
|
-
Open.read(CustomDS.path(dataset) + '.experiments').collect{|name|
|
130
|
-
name = name.strip
|
131
|
-
terms[name] = name.sub(/\[ratio\]/,'').words
|
132
|
-
}
|
133
|
-
terms
|
134
|
-
}
|
135
|
-
end
|
136
|
-
|
137
|
-
task 'annotate_UMLS' do
|
138
|
-
annotations('Words'){|dataset|
|
139
|
-
description = Open.read(CustomDS.path(dataset) + '.description')
|
140
|
-
terms[:dataset] = Annotations::UMLS::OBA(description).uniq
|
141
|
-
Open.read(CustomDS.path(dataset) + '.experiments').collect{|name|
|
142
|
-
name = name.strip
|
143
|
-
terms[name] = Annotations::UMLS::OBA(name.sub(/.*?: /,'').sub(/\[ratio\]/,'')).uniq
|
144
|
-
}
|
145
|
-
terms
|
146
|
-
}
|
147
|
-
end
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
task 'annotate_Polysearch' do
|
152
|
-
require 'rbbt/sources/polysearch'
|
153
|
-
annotations('Polysearch'){|dataset|
|
154
|
-
terms = {}
|
155
|
-
description = Open.read(CustomDS.path(dataset) + '.description')
|
156
|
-
terms[:dataset] = Polysearch::match(description).values.flatten.sort.collect{|n| n.gsub(/\s+/,' ').downcase}.uniq
|
157
|
-
Open.read(CustomDS.path(dataset) + '.experiments').collect{|name|
|
158
|
-
name = name.strip
|
159
|
-
terms[name] = Polysearch::match(name.sub(/.*?: /,'').sub(/\[ratio\]/,'')).values.flatten.sort.collect{|n| n.gsub(/\s+/,' ').downcase}.uniq
|
160
|
-
}
|
161
|
-
terms
|
162
|
-
}
|
163
|
-
|
164
|
-
end
|
165
|
-
|
166
|
-
task 'annotate_GO' do
|
167
|
-
require 'rbbt/sources/go'
|
168
|
-
options = { :cut_off => $expr_threshold, :fdr => $fdr, :folds => $folds, :do_folds => $do_folds, :nth_genes => $nth_genes}
|
169
|
-
annotations('GO_up', true){|dataset|
|
170
|
-
org = MARQ.platform_organism(dataset)
|
171
|
-
genes = Annotations::GO.get_genes(dataset, options)
|
172
|
-
|
173
|
-
up = {}
|
174
|
-
genes[:up] ||= []
|
175
|
-
genes[:up].collect{|experiment,list|
|
176
|
-
up[experiment] = goterms(org, list, false, $expr_threshold)
|
177
|
-
}
|
178
|
-
up
|
179
|
-
}
|
180
|
-
|
181
|
-
annotations('GO_down', true){|dataset|
|
182
|
-
org = MARQ.platform_organism(dataset)
|
183
|
-
genes = Annotations::GO.get_genes(dataset, options)
|
184
|
-
|
185
|
-
down = {}
|
186
|
-
genes[:down] ||= []
|
187
|
-
genes[:down].collect{|experiment,list|
|
188
|
-
down[experiment] = goterms(org, list, false, $expr_threshold)
|
189
|
-
}
|
190
|
-
down
|
191
|
-
}
|
192
|
-
annotations('GOSlim_up', true){|dataset|
|
193
|
-
org = MARQ.platform_organism(dataset)
|
194
|
-
genes = Annotations::GO.get_genes(dataset, options)
|
195
|
-
|
196
|
-
up = {}
|
197
|
-
genes[:up] ||= []
|
198
|
-
genes[:up].collect{|experiment,list|
|
199
|
-
up[experiment] = goterms(org, list, true, $expr_threshold)
|
200
|
-
}
|
201
|
-
up
|
202
|
-
}
|
203
|
-
|
204
|
-
annotations('GOSlim_down', true){|dataset|
|
205
|
-
org = MARQ.platform_organism(dataset)
|
206
|
-
genes = Annotations::GO.get_genes(dataset, options)
|
207
|
-
|
208
|
-
down = {}
|
209
|
-
genes[:down] ||= []
|
210
|
-
genes[:down].collect{|experiment,list|
|
211
|
-
down[experiment] = goterms(org, list, true, $expr_threshold)
|
212
|
-
}
|
213
|
-
down
|
214
|
-
}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
return list
|
215
34
|
end
|
216
35
|
|
217
|
-
task 'default' do
|
218
|
-
Rake::Task['data'].invoke
|
219
|
-
Rake::Task['annotate_Words'].invoke
|
220
|
-
Rake::Task['annotate_UMLS'].invoke
|
221
|
-
Rake::Task['annotate_Polysearch'].invoke
|
222
|
-
Rake::Task['annotate_GO'].invoke
|
223
|
-
end
|
@@ -6,304 +6,63 @@ require 'yaml'
|
|
6
6
|
require 'progress-monitor'
|
7
7
|
require 'MARQ/MADB'
|
8
8
|
require 'rbbt/sources/organism'
|
9
|
+
require File.join(File.dirname(File.dirname(__FILE__)), 'rake_includes')
|
10
|
+
|
9
11
|
|
10
12
|
$platform ||= ENV['platform']
|
11
13
|
$organism ||= [$organism, ENV['organism'], nil].compact.first
|
12
14
|
$dataset ||= ENV['dataset']
|
13
15
|
|
14
|
-
|
15
|
-
$folds ||= (ENV['folds'] || 2.5).to_f
|
16
|
-
$nth_genes ||= (ENV['nth_genes'] || 100).to_i
|
17
|
-
|
18
|
-
$force = [$force, ENV['force'], false].compact.first.to_s == 'true'
|
19
|
-
$tranlations = [$tranlations, ENV['translations'], false].compact.first.to_s == 'true'
|
20
|
-
$series = [$series, ENV['series'], true].compact.first.to_s == 'true'
|
21
|
-
$update_db = [$update_db, ENV['update_db'], false].compact.first.to_s == 'true'
|
22
|
-
$skip_db = [$skip_db, ENV['skip_db'], false].compact.first.to_s == 'true'
|
23
|
-
$fdr = [$fdr, ENV['fdr'], true].compact.first.to_s == 'true'
|
24
|
-
$do_folds = [$do_folds, ENV['do_folds'], true].compact.first.to_s == 'true'
|
25
|
-
|
16
|
+
# More global variables in rake_includes file
|
26
17
|
|
27
18
|
# Record changes in order to update DB
|
28
|
-
$changes = false
|
29
|
-
module GEO::Process::R
|
30
|
-
class << self
|
31
|
-
alias_method :GDS_old, :GDS
|
32
|
-
def GDS(*args)
|
33
|
-
$changes = true
|
34
|
-
GDS_old(*args)
|
35
|
-
end
|
36
|
-
|
37
|
-
alias_method :GSE_old, :GSE
|
38
|
-
def GSE(*args)
|
39
|
-
$changes = true
|
40
|
-
GSE_old(*args)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
19
|
|
46
20
|
def process_list
|
47
|
-
return {GEO::Remote::dataset_platform($dataset) => [$dataset]} if $dataset
|
48
|
-
return {$platform => GEO::Remote::platform_datasets($platform)} if $platform
|
49
|
-
|
50
|
-
if $organism
|
51
|
-
organisms = [$organism]
|
52
|
-
else
|
53
|
-
organisms = Organism.all(true)
|
54
|
-
end
|
55
|
-
|
56
21
|
list = {}
|
57
|
-
organisms.
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
list[platform] = datasets
|
22
|
+
organisms = $organism ? [$organism] : Organism.all(true)
|
23
|
+
|
24
|
+
# Find candidate datasets
|
25
|
+
case
|
26
|
+
when $dataset
|
27
|
+
list[GEO::Remote::dataset_platform($dataset)] = [$dataset]
|
28
|
+
when $platform
|
29
|
+
list[$platform] = GEO::Remote::platform_datasets($platform)
|
30
|
+
else
|
31
|
+
organisms.each do |organism|
|
32
|
+
org_platform = GEO::Remote::organism_platforms(organism)
|
33
|
+
org_platform.each do |platform|
|
34
|
+
datasets = GEO::Remote::platform_datasets(platform)
|
35
|
+
list[platform] = datasets if datasets.any?
|
72
36
|
end
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# Find cadidate series
|
41
|
+
case
|
42
|
+
when $dataset
|
43
|
+
when $series
|
77
44
|
series = Dir.glob('series/*.yaml').collect{|f| File.basename(f).sub(/.yaml/,'')}
|
78
|
-
series.each
|
45
|
+
series.each do |serie|
|
79
46
|
platform = GEO::SOFT.GSE(serie)[:platform]
|
47
|
+
next if $platform && $platform != platform
|
80
48
|
begin
|
81
|
-
if
|
49
|
+
if platform =~ /_/
|
50
|
+
organism = GEO::SOFT.GPL(platform)[:organism]
|
51
|
+
else
|
52
|
+
organism = GEO::Remote::platform_organism(platform)
|
53
|
+
end
|
54
|
+
if organism.split(',').select{|org| organisms.include? Organism.name2org(org.strip)}.any?
|
82
55
|
list[platform] ||= []
|
83
|
-
list[platform] << serie
|
56
|
+
list[platform] << serie
|
84
57
|
end
|
85
58
|
rescue
|
86
59
|
puts "Error process series #{serie} platform #{platform}"
|
87
60
|
puts $!.message
|
88
61
|
puts $!.backtrace.join("\n")
|
89
62
|
end
|
90
|
-
}
|
91
|
-
end
|
92
|
-
|
93
|
-
return list
|
94
|
-
end
|
95
|
-
|
96
|
-
desc "Analyze datasets"
|
97
|
-
task 'data' do
|
98
|
-
|
99
|
-
platforms_to_save = []
|
100
|
-
|
101
|
-
process_list.each{|platform, datasets|
|
102
|
-
|
103
|
-
begin
|
104
|
-
# Prepare the platform
|
105
|
-
GEO::Process.GPL(platform)
|
106
|
-
rescue
|
107
|
-
puts "Error processing platform #{platform}"
|
108
|
-
puts $!.message
|
109
|
-
puts $!.backtrace.join("\n")
|
110
|
-
next
|
111
63
|
end
|
112
|
-
|
113
|
-
$changes = false
|
114
|
-
# Process all datasets
|
115
|
-
datasets.each{|dataset|
|
116
|
-
begin
|
117
|
-
if dataset =~ /GDS/
|
118
|
-
GEO::Process.GDS(dataset, platform)
|
119
|
-
else
|
120
|
-
info = YAML::load(File.open("series/#{ dataset }.yaml"))
|
121
|
-
FileUtils.rm("platforms/#{ info[:platform] }.skip") if File.exist? "platforms/#{ info[:platform] }.skip"
|
122
|
-
GEO::Process.GSE(dataset, info)
|
123
|
-
end
|
124
|
-
|
125
|
-
# Mark the platform for saving in DB
|
126
|
-
rescue
|
127
|
-
puts "Error processing dataset #{ dataset }"
|
128
|
-
puts $!.message
|
129
|
-
puts $!.backtrace.join("\n")
|
130
|
-
end
|
131
|
-
}
|
132
|
-
|
133
|
-
platforms_to_save << platform if $changes || $update_db
|
134
|
-
}
|
135
|
-
|
136
|
-
platforms_to_save.each{|platform|
|
137
|
-
begin
|
138
|
-
puts "Saving #{platform}"
|
139
|
-
MADB::GEO.saveGPL(platform)
|
140
|
-
rescue
|
141
|
-
puts "Error saving platform #{ platform }"
|
142
|
-
puts $!.message
|
143
|
-
puts $!.backtrace.join("\n")
|
144
|
-
end
|
145
|
-
}
|
146
|
-
end
|
147
|
-
|
148
|
-
def annotations(name, cross_platform = false, &block)
|
149
|
-
FileUtils.mkdir_p File.join("annotations", name) unless File.exist? File.join("annotations", name)
|
150
|
-
platforms = Dir.glob('platforms/*.yaml').collect{|f| File.basename(f).sub(/.yaml/,'')}
|
151
|
-
platforms = platforms.sort_by{|platform| MARQ.platform_organism(platform)}.reverse
|
152
|
-
|
153
|
-
if $platform
|
154
|
-
platforms = [$platform]
|
155
64
|
end
|
156
65
|
|
157
|
-
|
158
|
-
platforms.each{|platform|
|
159
|
-
Progress.monitor("Annotating with #{ name }: platform #{ platform }")
|
160
|
-
GEO.platform_datasets(platform).each do |dataset|
|
161
|
-
begin
|
162
|
-
next if File.exist? File.join("annotations", name, dataset)
|
163
|
-
filename = File.join("annotations", name, dataset)
|
164
|
-
dataset += '_cross_platform' if cross_platform && GEO.has_cross_platform?(nil, platform)
|
165
|
-
next if File.exist? GEO.dataset_path(dataset) + '.skip'
|
166
|
-
terms = block.call(dataset)
|
167
|
-
Open.write(filename, terms.to_yaml)
|
168
|
-
rescue Exception
|
169
|
-
puts $!.message
|
170
|
-
end
|
171
|
-
end
|
172
|
-
}
|
173
|
-
return if $platform
|
174
|
-
|
175
|
-
Progress.monitor("Annotating with #{ name }, series")
|
176
|
-
series = Dir.glob('series/*.yaml').collect{|f| File.basename(f).sub(/.yaml/,'')}
|
177
|
-
series.each{|serie|
|
178
|
-
begin
|
179
|
-
next if File.exist? File.join("annotations", name, serie)
|
180
|
-
filename = File.join("annotations", name, serie)
|
181
|
-
serie += '_cross_platform' if cross_platform && GEO.has_cross_platform?(serie)
|
182
|
-
next if File.exist? GEO.dataset_path(serie) + '.skip'
|
183
|
-
terms = block.call(serie)
|
184
|
-
Open.write(filename, terms.to_yaml)
|
185
|
-
rescue Exception
|
186
|
-
puts $!.message
|
187
|
-
end
|
188
|
-
}
|
189
|
-
end
|
190
|
-
|
191
|
-
def goterms(org, list, slim, threshold)
|
192
|
-
return [] if list.empty?
|
193
|
-
results = Annotations::GO::Genecodis::Local.analysis(org, list, slim)
|
194
|
-
results.
|
195
|
-
select{|info| info[:s].to_i > 2 }.
|
196
|
-
select{|info| info[:hyp_c].to_f < threshold }.
|
197
|
-
collect{|info| info[:items]}.collect{|id| GO::id2name(id)}
|
198
|
-
end
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
task 'annotate_Words' do
|
203
|
-
require 'MARQ/annotations'
|
204
|
-
require 'rbbt/bow/bow'
|
205
|
-
annotations('Words'){|dataset|
|
206
|
-
terms = {}
|
207
|
-
description = Open.read(GEO.dataset_path(dataset) + '.description')
|
208
|
-
terms[:dataset] = [dataset] + description.words.uniq
|
209
|
-
Open.read(GEO.dataset_path(dataset) + '.experiments').collect{|name|
|
210
|
-
name = name.strip
|
211
|
-
terms[name] = name.sub(/.*?: /,'').sub(/\[ratio\]/,'').words.uniq
|
212
|
-
}
|
213
|
-
terms
|
214
|
-
}
|
215
|
-
end
|
216
|
-
|
217
|
-
|
218
|
-
task 'annotate_UMLS' do
|
219
|
-
require 'MARQ/annotations'
|
220
|
-
require 'rbbt/util/misc'
|
221
|
-
annotations('UMLS'){|dataset|
|
222
|
-
terms = {}
|
223
|
-
description = Open.read(GEO.dataset_path(dataset) + '.description')
|
224
|
-
terms[:dataset] = Annotations::UMLS::OBA(description).uniq
|
225
|
-
Open.read(GEO.dataset_path(dataset) + '.experiments').collect{|name|
|
226
|
-
name = name.strip
|
227
|
-
terms[name] = Annotations::UMLS::OBA(name.sub(/.*?: /,'').sub(/\[ratio\]/,'')).uniq
|
228
|
-
}
|
229
|
-
terms
|
230
|
-
}
|
231
|
-
end
|
232
|
-
|
233
|
-
|
234
|
-
task 'annotate_Polysearch' do
|
235
|
-
require 'MARQ/annotations'
|
236
|
-
require 'rbbt/util/misc'
|
237
|
-
require 'rbbt/sources/polysearch'
|
238
|
-
annotations('Polysearch'){|dataset|
|
239
|
-
terms = {}
|
240
|
-
description = Open.read(GEO.dataset_path(dataset) + '.description')
|
241
|
-
terms[:dataset] = Polysearch::match(description).values.flatten.sort.collect{|n| n.gsub(/\s+/,' ').downcase}.uniq
|
242
|
-
Open.read(GEO.dataset_path(dataset) + '.experiments').collect{|name|
|
243
|
-
name = name.strip
|
244
|
-
terms[name] = Polysearch::match(name.sub(/.*?: /,'').sub(/\[ratio\]/,'')).values.flatten.sort.collect{|n| n.gsub(/\s+/,' ').downcase}.uniq
|
245
|
-
}
|
246
|
-
terms
|
247
|
-
}
|
248
|
-
|
249
|
-
end
|
250
|
-
|
251
|
-
task 'annotate_GO' do
|
252
|
-
require 'MARQ/annotations'
|
253
|
-
require 'rbbt/sources/go'
|
254
|
-
options = { :cut_off => $expr_threshold, :fdr => $fdr, :folds => $folds, :do_folds => $do_folds, :nth_genes => $nth_genes}
|
255
|
-
annotations('GO_up', true){|dataset|
|
256
|
-
org = MARQ.platform_organism(dataset)
|
257
|
-
genes = Annotations::GO.get_genes(dataset, options)
|
258
|
-
|
259
|
-
up = {}
|
260
|
-
genes[:up] ||= []
|
261
|
-
genes[:up].collect{|experiment,list|
|
262
|
-
up[experiment] = goterms(org, list, false, $expr_threshold)
|
263
|
-
}
|
264
|
-
up
|
265
|
-
}
|
266
|
-
|
267
|
-
annotations('GO_down', true){|dataset|
|
268
|
-
org = MARQ.platform_organism(dataset)
|
269
|
-
genes = Annotations::GO.get_genes(dataset, options)
|
270
|
-
|
271
|
-
down = {}
|
272
|
-
genes[:down] ||= []
|
273
|
-
genes[:down].collect{|experiment,list|
|
274
|
-
down[experiment] = goterms(org, list, false, $expr_threshold)
|
275
|
-
}
|
276
|
-
down
|
277
|
-
}
|
278
|
-
annotations('GOSlim_up', true){|dataset|
|
279
|
-
org = MARQ.platform_organism(dataset)
|
280
|
-
genes = Annotations::GO.get_genes(dataset, options)
|
281
|
-
|
282
|
-
up = {}
|
283
|
-
genes[:up] ||= []
|
284
|
-
genes[:up].collect{|experiment,list|
|
285
|
-
up[experiment] = goterms(org, list, true, $expr_threshold)
|
286
|
-
}
|
287
|
-
up
|
288
|
-
}
|
289
|
-
|
290
|
-
annotations('GOSlim_down', true){|dataset|
|
291
|
-
org = MARQ.platform_organism(dataset)
|
292
|
-
genes = Annotations::GO.get_genes(dataset, options)
|
293
|
-
|
294
|
-
down = {}
|
295
|
-
genes[:down] ||= []
|
296
|
-
genes[:down].collect{|experiment,list|
|
297
|
-
down[experiment] = goterms(org, list, true, $expr_threshold)
|
298
|
-
}
|
299
|
-
down
|
300
|
-
}
|
66
|
+
return list
|
301
67
|
end
|
302
68
|
|
303
|
-
task 'default' do
|
304
|
-
Rake::Task['data'].invoke
|
305
|
-
Rake::Task['annotate_Words'].invoke
|
306
|
-
Rake::Task['annotate_UMLS'].invoke
|
307
|
-
Rake::Task['annotate_Polysearch'].invoke
|
308
|
-
Rake::Task['annotate_GO'].invoke
|
309
|
-
end
|