-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbootstrapPathway.pl
More file actions
executable file
·96 lines (83 loc) · 1.89 KB
/
bootstrapPathway.pl
File metadata and controls
executable file
·96 lines (83 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
use strict;
use Data::Dumper;
my $file = shift;
my %data;
open IN, "$file";
my %colnames;
my %colindex;
my @samples;
while ( <IN> ){
chomp;
my @cols = split /\t/;
if ($_ =~ /^gene/) { #header
for (my $i = 0; $i <= $#cols; $i++) {
$colnames{$i} = $cols[$i];
$colindex{$cols[$i]} = $i;
}
} #header
else { #normal lines
my $gene = $cols[$colindex{'gene'}];
#print "$gene\n";
for (my $i = 1; $i <= $#cols; $i++) {
my $sample = $colnames{$i};
if ( scalar(@samples) < 21 ) {
push(@samples, $sample);
}
$data{$gene}{$sample} = $cols[$i];
}
}
}
close IN;
#print STDERR Dumper(\%colnames);
#print STDERR Dumper(\%colindex);
#print Dumper(\%data);
#print Dumper(\@samples);
srand();
my $b = 1;
while ($b <= 1000) {
my %rinds;
my $s = 1; #7 samples
while ( $s <= 7 ) {
my $rind = int(rand(21));
while ( exists($rinds{$rind}) ) {
$rind = int(rand(21));
}
$rinds{$rind} = '';
$s++;
} #7 samples
#print Dumper(\%rinds);
#now the samples are chose, do genes
foreach my $srindp (sort keys %rinds) { #samples
my $samplep = $samples[$srindp];
print "b$b\t$samplep\n";
} #each sample
open OUT, ">b$b";
foreach my $gene (keys %data) { #each gene
my $found = 0;
foreach my $srind (sort keys %rinds) { #samples
my $sample = $samples[$srind];
if ($data{$gene}{$sample} != 0){
$found = 1;
}
} #each sample
if ($found != 0){
print OUT "$gene\n";
}
}
close OUT;
#now run pathway
my $cmd = "perl /tools/trick/runPathwayEnrichment.pl b$b /cygdrive/h/annotation/CPDB_pathways_genes.tab";
RunCommand($cmd, 0 , 0);
print STDERR "b$b\n";
$b++;
}
exit 0;
sub RunCommand {
my ($command,$noexecute,$quiet) = @_ ;
unless ($quiet){
print STDERR "$command\n\n";
}
unless ($noexecute) {
system($command);
}
}