-
Notifications
You must be signed in to change notification settings - Fork 1
/
Fig5A_GSVA_subtype_every_spot.pl
94 lines (66 loc) · 1.65 KB
/
Fig5A_GSVA_subtype_every_spot.pl
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
use File::Basename;
my %hash;
open IN, "Fig3A_B_subtype_cluster_demo.txt";
while ($line=<IN>){
chomp $line;
my @tmp=split(/\t/,$line);
$hash{$tmp[1]}=$tmp[0];
}
close IN;
my @files1=`find ./ -name "GSVA*ST_P1*txt"`;
chomp @files1;
my @files2=`find ./ -name "GSVA*ST_P5*txt"`;
chomp @files2;
my @files3=`find ./ -name "GSVA*ST_P6*txt"`;
chomp @files3;
my @files4=`find ./ -name "GSVA*ST_P7*txt"`;
chomp @files4;
my @files5=`find ./ -name "GSVA*ST_P8*txt"`;
chomp @files5;
my @files= (@files1, @files2, @files3, @files4, @files5);
print "Sample\tSubtype\tCluster\tSpot\tPathway\tScore\n";
foreach my $infile (@files){
my $sample=basename $infile;
$sample=~s/GSVA_//;
$sample=~s/_KEGG\.txt//;
$sample=~s/_Reactome\.txt//;
$sample=~s/_Hallmark\.txt//;
my %cluster;
open IN, "stdata_meta.txt";
while ($line=<IN>){
chomp $line;
next if ($line=~/cell_type/);
my @tmp=split(/\t/,$line);
$cluster{$tmp[0]}=$tmp[1];
}
close IN;
my %header;
my $i=1;
open IN, "$infile";
while ($line=<IN>){
chomp $line;
my @tmp=split(/\t/,$line);
if ($i == 1){
for(my $j=0; $j<=$#tmp;$j++){
my $new_j=$j+1;
$header{$new_j}=$tmp[$j];
}
}else{
my $pathway=$tmp[0];
for(my $j=1; $j<=$#tmp;$j++){
my $spot = $header{$j};
$spot=~s/\./-/;
my $clus=$cluster{$spot};
my $tt="$sample.$clus";
if (exists $hash{$tt}){
my $subtype=$hash{$tt};
my @tmp0=split(/_/,$subtype);
my $subtype2=$tmp0[0];
print "$sample\t$subtype2\t$clus\t$spot\t$pathway\t$tmp[$j]\n";
}
}
}
$i++;
}
close IN;
}