hellohello1 has asked for the wisdom of the Perl Monks concerning the following question:
I have part of this code where I am calculating the average and coefficient variance from the values I generated from input data based on my code. And then the values will be output into a textfile.
so the output is:. . . while(<CURINFILE>) { push @full_data , [split] while (<CURINFILE>); for $arr_ref1 (@full_data) { for $arr_ref2(@full_data) { $variable1 = ''; $variable2=''; for my $index1 (3..4) #first group { $ratio1 = ($$arr_ref2[$index1]/$$arr_ref1[$index1],"\t"); $variable1 .= $ratio1; #join column by column } for my $index2 (5..6) #second group { $ratio2 = ($$arr_ref2[$index2]/$$arr_ref1[$index2],"\t"); $variable2 .= $ratio2; #join column by column } #Calculate Average @arrayint1 = split (/\t/,$variable1); $avg1 = &average (\@arrayint1); @arrayint2 = split (/\t/,$variable2); $avg2 = &average (\@arrayint2); #Calculate SD @arrayint1 = split (/\t/,$variable1); $std1 = &stdev(\@arrayint1); @arrayint2 = split (/\t/,$variable2); $std2 = &stdev(\@arrayint2); #Calculate CV $cv1 = $std1/$avg1; $cv2 = $std2/$avg2; my $outputa = "$$arr_ref1[0]"; my $outputb = "$variable1\t$variable2\t"; my $outputc = "\t$avg1\t$avg2"; my $outputd = "\t$cv1\t$cv2"; ###### print everything out ##################### my $key = "$outputa"."$outputb". "$outputc"."outputd"; print OUT1 $key; print OUT1 "\n"; } } . (average and SD codes) .
_OUTPUT_ M446T27 1 1 1 1 1 1 0 0 M446T27 1.75 2.66 1.80 2.16 2.20 1.98 0.29 0.12 M446T27 1.00 1.64 0.99 1.09 1.32 1.04 0.34 0.06 . .
My question is, is it possible to actually filter the whole row ($key) based on the outputd(set condition for CV)(last two columns)? So that I do not want to print those rows that does not meet the criteria based on the CV of both groups.
EDIT: I'll rephrase my question..never good in words. Is there a need to put them into hashes or I can just do the if condition straightaway using variables and then assign back the outputa,b,c to the filtered outputd accordingly?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Filter rows according to certain criteria based on CV
by kcott (Archbishop) on Mar 26, 2014 at 06:21 UTC | |
by hellohello1 (Sexton) on Mar 26, 2014 at 07:10 UTC | |
|
Re: Filter rows according to certain criteria based on CV
by Anonymous Monk on Mar 26, 2014 at 07:13 UTC | |
by hellohello1 (Sexton) on Mar 26, 2014 at 08:26 UTC | |
by Anonymous Monk on Mar 26, 2014 at 08:48 UTC | |
by hellohello1 (Sexton) on Mar 26, 2014 at 09:42 UTC |