Hi, Zeus. Thanks for your comment. "Replicates" line is the header line and there are two treatments in this case.
Probe id Treat1 Treat1 Treat1 treat1 Treat2 treat2 treat2 AFFX-BioB-5_at P P P P P P P AFFX-BioB-M_at P P M P P M P AFFX-BioB-3_at P M P A A P P AFFX-BioC-5_at P P A M P A M AFFX-BioC-3_at M M P A P P M The output should be as follow without the process of calculation Probe id Treat1 Treat2 AffX-BioB-5_at (2p +M)/4 =2 (2*3+0)/3=2 FFX-BioB-M_at (2*3+0)/4 =1.7 (2*3+0)/3=2 AFFX-BioB-3_at (2*2+0)/4 =1 (2*2+0)/3=1.3 AFFX-BioC-5_at (2*2+1)/4 =1.25 (2*1+1)/3=1 AFFX-BioC-3_at (2*1+1)/4 = 0.75 (2*2+1)/3=1.7 The denominator is always the # of replicates in each treatment. Thanks, Aiguo -----Original Message----- From: Zeus Odin [mailto:[EMAIL PROTECTED] Sent: Thursday, November 11, 2004 8:08 AM To: [EMAIL PROTECTED] Subject: Re: Why doesn't this work? "Aiguo Li" <[EMAIL PROTECTED]> wrote in message... > Hello, Hello. > I have the following dataset and want to calculate a P/A ratio for > each replicates in the dataset. In this case, treatment 1 has 4 > replicats and treatment2 has 3 replicates. The P/A = [((#of P)*2) + (# > of M)]/# of replicates. The output should be two columns of P/A > ratios for two treatments. Your explanation doesn't make much sense to me. Maybe it's just me. ;-) Is the line starting with "Replicates" a header row? I gleaned from your code that P/A = (2p + m)/a where p, m, and a equal the number of P's, M's, and A's respectively on a row. If this is true, what is to be done when a row is missing A, M, or P? Of course, if A is missing then the equation is undefined because you have zero in the denominator. You also state that the output should be two columns, yet in your code you print $a, $m, and $p but nothing else. It would be helpful if you took one record from below then manually compute the two columns you want printed. > > > I have made this far with the following code, but have not been able > to make > the code work yet. Could anybody shed some light on it? > > Thanks, > > AG > > #!usr/bin/perl -w > > use strict; > use warnings; > > my @split; > my @replicate = ( 5, 3); > my @ratio; > my $p=0; > my $m=0; > my $a=0; > my $rep=0; > my $item; > my $ratio; > > > open (FILE, "<C:/replicate.txt") or die "Can't open file: $!"; > > > while( <FILE> ) > { > #print; > chomp; > @split = split (/\t/, $_); > push (@split, $_); > #print "$_ \n"; > foreach $rep (@replicate) > { > for(my $i=1; $i<=$rep; $i++) > { > push (@split, $_); > SWITCH: > if ($_ =~ "P") {$p++; last SWITCH;} > if ($_ =~ "M") {$m++; last SWITCH;} > if ($_ =~ "A") {$a++; last SWITCH;} > } > print $p, $m, $a; > @ratio = (($p*2)+$m)/$rep; > > > > > } > } > > close FILE; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response> -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>