E
ela
__DATA__
ID B C D E F G H
1 3 7 9 3 4 2 3
1 3 7 9 3 4 2 2
1 3 7 9 5 8 6 6
1 3 7 9 3 4 2 3
2 4 7 9 3 4 2 1
2 4 7 9 3 4 2 2
2 4 7 9 3 4 2 3
2 4 7 9 3 4 2 3
For each ID (the above example has two (1 and 2)), I want to identify the
"last common
ancestor: LCA, H being higher preference than B " based on some defined
threshold. If the threshold is set to 100%, then the LCA of ID 1 is D=9; if
set it to 75%, then it is F=2. For ID 2 (100%, G=2; 75%, G=2; 50% H=3)
While hash is good at allocating different instance easily, I don't know
whether perl supports simple architecture to get the max/min. For the
following code,
@array
For each row
for ($i=0; $i<$numcol; $i++)
$array[$i]{$key}++;
if just for B, I know the following should be written in this way:
foreach $key (keys %B) { $Bpertpot{$key} = $B{$key}/$total; }
for ($i=0; $i<$numcol; $i++) {
$maxcol[$i] = 0;
foreach $key (keys %Bpertpot) { if ($Bpertpot{$key}> $maxcol[$i]) {
$maxcol[$i] = $Bpertpot{$key}; }
}
but then I don't know how to do that for array of hash to traverse... i.e.
replace the %B and %Bpertpot to something that is compatible with the array
structure... In fact, I wonder if there is already well-established modules
that may have handled this kind of max-min statistics problems that seem to
encounter frequently in the business sector...
ID B C D E F G H
1 3 7 9 3 4 2 3
1 3 7 9 3 4 2 2
1 3 7 9 5 8 6 6
1 3 7 9 3 4 2 3
2 4 7 9 3 4 2 1
2 4 7 9 3 4 2 2
2 4 7 9 3 4 2 3
2 4 7 9 3 4 2 3
For each ID (the above example has two (1 and 2)), I want to identify the
"last common
ancestor: LCA, H being higher preference than B " based on some defined
threshold. If the threshold is set to 100%, then the LCA of ID 1 is D=9; if
set it to 75%, then it is F=2. For ID 2 (100%, G=2; 75%, G=2; 50% H=3)
While hash is good at allocating different instance easily, I don't know
whether perl supports simple architecture to get the max/min. For the
following code,
@array
For each row
for ($i=0; $i<$numcol; $i++)
$array[$i]{$key}++;
if just for B, I know the following should be written in this way:
foreach $key (keys %B) { $Bpertpot{$key} = $B{$key}/$total; }
for ($i=0; $i<$numcol; $i++) {
$maxcol[$i] = 0;
foreach $key (keys %Bpertpot) { if ($Bpertpot{$key}> $maxcol[$i]) {
$maxcol[$i] = $Bpertpot{$key}; }
}
but then I don't know how to do that for array of hash to traverse... i.e.
replace the %B and %Bpertpot to something that is compatible with the array
structure... In fact, I wonder if there is already well-established modules
that may have handled this kind of max-min statistics problems that seem to
encounter frequently in the business sector...