-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathTPCG_matrix.pl
executable file
·67 lines (57 loc) · 1.41 KB
/
TPCG_matrix.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
#!/usr/bin/perl -w
use strict;
die "perl $0 <DNA_PerCell> <RNA_PerCell> <OUT_TPCG>
This script transform the DNA matrix normalized to per cell and RNA matrix normalized to per cell into the TPCG, after running aqmm, the number of sequenced cells in DNA sample and the number of eqivalent expressed cells are obtained. Users can easly normalized the read count matrix of genes with these absolute quantifications \n" unless (@ARGV == 3);
die "$!\n" unless open(D, "$ARGV[0]");
die "$!\n" unless open(R, "$ARGV[1]");
die "$!\n" unless open(O, ">$ARGV[2]");
## DNA G/Cell
## RNA Exoressuib/Cell whether the total cell is the same?
my %dna;
<D>;
while(<D>){
chomp;
my @m = split(/\t/, $_, 2);
$dna{$m[0]} = $m[1];
}
close D;
my %excep;
<R>;
while(<R>){
chomp;
my @m = split(/\t/, $_, 2);
my @tm = split(/_/, $m[0]);
pop @tm;
my $name = join("_", @tm);
if(exists $dna{$name}){
my @dm = split(/\t/, $dna{$name});
my @rm = split(/\t/, $m[1]);
my @temp = ();
my $flag = 0;
for(my $i=0;$i<=$#dm;$i++){
if($dm[$i] != 0){
my $gpc = $rm[$i] / $dm[$i];
push @temp, $gpc;
}else{
if($rm[$i] == 0){
push @temp, 0;
}else{
push @temp, 0;
$flag = 1;
}
}
}
if($flag == 1){
$excep{$m[0]} = $dna{$name};
}
my $o = join("\t", @temp);
print O "$m[0]\t$o\n";
}else{
die "$m[0]\n";
}
}
close R;
close O;
for (keys %excep){
print "$_\t$excep{$_}\n";
}