438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
|
# File 'lib/MARQ/annotations.rb', line 438
def self.get_genes_nth(dataset, num_genes)
path = MARQ.dataset_path(dataset)
experiments = File.open(path + '.experiments').collect{|l| l.chomp.strip}
genes = File.open(path + '.codes').collect{|l| l.chomp.strip}
total_genes = genes.length
genes_up = {}
genes_down = {}
experiments.each{|exp| genes_up[exp] = []; genes_down[exp] = []}
File.open(path + '.orders').each_with_index{|l, i|
values = l.chomp.split(/\t/)
experiments.zip(values).each{|p|
name = p.first
value = p.last
next if p.last == "NA"
genes_up[name] << genes[i] if value.to_i < num_genes
genes_down[name] << genes[i] if value.to_i > total_genes - num_genes
}
}
{:up => genes_up, :down => genes_down}
end
|