3

A friend of mine has written a code in unix

awk '\
BEGIN { OFS = "\t"; FS = "\t"} ;\
(NR >= 2){\
split($3,a,"|");\
if(a[1]!~ /\?/) {\
  print a[1], a[2] > "geneinfo_tumor.txt";\
  printf "%s", a[1] > "gene_tumor.txt";\
  for (i = 2; i <= 1099; i++)  printf "\t%g", log($i+1) > "gene_tumor.txt";\
  printf "\n" > "gene_tumor.txt";}\
}' tumor.exp.gt.txt

but I don't understand the following line

 

for (i = 2; i <= 1099; i++)  printf "\t%g", log($i+1) > "gene_tumor.txt";\

what does the log($i+1) do here ??

6

In AWK, log() is the natural logarithm fonction, and $i is the value of the ith field in the current record. So log($i+1) takes the value of the ith field, adds 1, and returns the natural logarithm of the sum.

  • Thank you, so if I don't want to do log of the (field +1) and just add the value of the field what should I replace the log($i+1) with ? – Marwah Soliman Feb 8 '17 at 21:54
  • Just $i then. – Stephen Kitt Feb 8 '17 at 22:02
  • could you please explain the whole code for me if you don't mind – Marwah Soliman Feb 10 '17 at 5:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.