extract the max value category

Hi,

I have a file and I want the category for each row to be its highest value.


gene    highest   medium   lower  lowest

ABC     20            30          50      70
DEF     90            20          60       0

o/p

gene    highest   medium   lower  lowest   category 

ABC     20            30          50      70      lowest
DEF     90            20          60       0       highest

Thanks

awk '{ HI=$1; for(N=2; N<=NF; N++) if($N > HI) HI=$N; $(NF+1)=HI } 1'

Hi,

Thanks for the code , but its printing the same 1st column instead of category

o/p for the script is

[dvaka@cabiopeds ~]$ head test_code
gene    highest   medium   lower  lowest

ABC     20            30          50      70
DEF     90            20          60       0

[dvaka@cabiopeds ~]$ awk '{ HI=$1; for(N=2; N<=NF; N++) if($N > HI) HI=$N; $(NF+1)=HI } 1' test_code
gene highest medium lower lowest medium

ABC 20 30 50 70 ABC
DEF 90 20 60 0 DEF

Thanks,

Diya

The sample posted does not seem to reflect this rule.
Please post a larger sample (say 10 lines input and desired output) and explain the rule in detail.

[dvaka@cabiopeds ~]$ head -10  table1_predominent
me      5'UTR   3'UTR   exon    intron
ADARB1  781     55      14      239
C6orf176        477     0       0       0
BASP1   465     14      1       0
SMAD2   94      128     11      225
TEAD1   89      59      4       48
CUL4A   70      21      17      177
CREBZF  69      0       0       0
SFRS1   65      0       4       9
LIFR    63      21      10      16
[dvaka@cabiopeds ~]$ awk '{ HI=$1; for(N=2; N<=NF; N++) if($N > HI) HI=$N; $(NF+1)=HI } 1' table1_predominent >output_table1_predominent
[dvaka@cabiopeds ~]$ head -10 output_table1_predominent

me 5'UTR 3'UTR exon intron me
ADARB1 781 55 14 239 ADARB1
C6orf176 477 0 0 0 C6orf176
BASP1 465 14 1 0 BASP1
SMAD2 94 128 11 225 SMAD2
TEAD1 89 59 4 48 TEAD1
CUL4A 70 21 17 177 CUL4A
CREBZF 69 0 0 0 CREBZF
SFRS1 65 0 4 9 SFRS1
LIFR 63 21 10 16 LIFR

The output I desire is the category

me 5'UTR 3'UTR exon intron me
ADARB1 781 55 14 239 5'UTR
C6orf176 477 0 0 0 5'UTR
BASP1 465 14 1 0 5'UTR
SMAD2 94 128 11 225 intron
TEAD1 89 59 4 48 5'UTR
CUL4A 70 21 17 177 intron
CREBZF 69 0 0 0 5'UTR
SFRS1 65 0 4 9 5'UTR
LIFR 63 21 10 16 5'UTR

The max number category should be listed in column 6

Thanks,

Diya

I can't see the rule here at all. Other posters may see it?
Please post the rule in great detail.

I don't think his output actually matches his input, it looks nearly random.