Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • SDPA_Pet
    Senior Member
    • Apr 2013
    • 222

    awk help

    Can any one help me with awk.

    The attached file is an example. I have 10 functions and 6 comparsions. The first column is the function name and column 2- 7 are p value.

    I need to write a awk command to keep the functions which have five out of six p value less than 0.05

    I want to select functions like this

    function1 0.01 0.01 0.01 0.01 0.01 0.1

    Thanks
    Ben
    Attached Files
    Last edited by SDPA_Pet; 03-26-2014, 02:20 PM.
  • Richard Finney
    Senior Member
    • Feb 2009
    • 701

    #2
    cat file | awk '{n=0;if($2<0.05)n++; if($3<0.05)n++; if($4<0.05)n++; if($5<0.05)n++; if($6<0.05)n++; if($7<0.05)n++; if (n==5) print $0}'

    Note this only picks if 5, if you want >= 5 change "==" to ">="

    Comment

    • GenoMax
      Senior Member
      • Feb 2008
      • 7142

      #3
      If you need 5 out of 6 then the following should work:

      Code:
      $ awk '{count = 0; for (i=2; i<=NF; i++) if ($i < 0.05) count++; if (count == 5) print $0}' data.txt
      Note: Richard beat me to it but I will leave this here since as always more than one way of doing things.
      Last edited by GenoMax; 03-27-2014, 04:14 AM.

      Comment

      • SDPA_Pet
        Senior Member
        • Apr 2013
        • 222

        #4
        Originally posted by GenoMax View Post
        If you need 5 out of 6 then the following should work:

        Code:
        $ awk '{count = 0; for (i=2; i<=NF; i++) if ($i < 0.05) count++; if (count == 5) print $0}' data.txt
        Note: Richard beat me to it but I will leave this here since as always more than one way of doing things.
        Hi GEnoMax

        "i<NF", What does NF mean?

        Thanks

        Comment

        • SDPA_Pet
          Senior Member
          • Apr 2013
          • 222

          #5
          Originally posted by GenoMax View Post
          If you need 5 out of 6 then the following should work:

          Code:
          $ awk '{count = 0; for (i=2; i<=NF; i++) if ($i < 0.05) count++; if (count == 5) print $0}' data.txt
          Note: Richard beat me to it but I will leave this here since as always more than one way of doing things.
          Hi GenoMax,

          Can you help me the attached dataset. I want to extract all the data meet these conditions:

          either column4 or column 6 data >=1

          I try this but it doesn't work

          awk '{n=0;if($4>=1)n++; if($6>=1)n++; if (n>=1) print $0}' t-test-story.txt

          Thank you.
          Attached Files
          Last edited by SDPA_Pet; 03-29-2014, 12:50 PM.

          Comment

          • GenoMax
            Senior Member
            • Feb 2008
            • 7142

            #6
            Originally posted by SDPA_Pet View Post
            Hi GEnoMax

            "i<NF", What does NF mean?

            Thanks
            NF is total number of fields in a record (a line).

            Comment

            • SDPA_Pet
              Senior Member
              • Apr 2013
              • 222

              #7
              Hi GenoMax,

              Can you help me with the new file? I don't know why my script doesn't work.

              Comment

              • GenoMax
                Senior Member
                • Feb 2008
                • 7142

                #8
                Originally posted by SDPA_Pet View Post
                Hi GenoMax,

                Can you help me the attached dataset. I want to extract all the data meet these conditions:

                either column4 or column 6 data >=1

                Thank you.
                Try this:

                Code:
                $ awk '{FS="\t"; if ($4 > 1 || $6 > 1 ) print $0}' t-test-story.txt

                Comment

                • musta1234
                  Member
                  • Jun 2013
                  • 10

                  #9
                  Need help converting tab to fasta

                  Hello all!! I need help converting tab to fasta... I am a newbie and know only a little bash scripting. I need to convert a tab delimited SNP file into either a single fasta file or a multiple fasta files for each column using a the first line as identifier.

                  The closest I got was a script that enters a loop and can only be stopped by ctrl-C


                  #!/bin/bash


                  echo ">" > carat.txt

                  counter=1
                  #My tab file has 64 columns
                  while : [ $counter -lt 64]
                  do

                  less <SNP.txt |awk "{print$"$counter"}"| cat carat.txt - >$counter.fa
                  counter=$(($counter +1))

                  done

                  exit



                  SNP_001 SNP_002 SNP_003....
                  T T T T
                  C C C C
                  C C C C
                  C C C C
                  A A A A
                  A A A A
                  T T T T
                  T T T T
                  C C C C
                  G G G G
                  G G G G
                  C C C C

                  Comment

                  • musta1234
                    Member
                    • Jun 2013
                    • 10

                    #10
                    Moved

                    this post is also copied to a new thread to increase exposure... thanks

                    Comment

                    • GenoMax
                      Senior Member
                      • Feb 2008
                      • 7142

                      #11
                      Originally posted by musta1234 View Post
                      this post is also copied to a new thread to increase exposure... thanks
                      Are you basically looking to transpose the matrix your posted and covert it to a multi-fasta file?

                      Comment

                      Latest Articles

                      Collapse

                      • mylaser
                        Reply to Advanced Sequencing Platforms Tackle Neuroscience’s Toughest Genomics Problems
                        by mylaser
                        Kheloyar – Everything You Need to Know About Kheloyaar Login and Kheoyar Id
                        If you are looking for an online gaming platform that offers a user-friendly experience, Kheloyar has become a name that many users search for. Whether you're interested in creating a new account, accessing your dashboard through Kheloyaar Login, or learning how to obtain a Kheoyar Id, understanding the platform's features and account process is essential.
                        This guide explains everything you need to know about...
                        Yesterday, 01:13 AM
                      • SEQadmin2
                        Advanced Sequencing Platforms Tackle Neuroscience’s Toughest Genomics Problems
                        by SEQadmin2



                        Genomics studies in neuroscience face a special challenge due to the brain’s complexity and scarcity of samples. Mapping changes in cell type and state using conventional next-generation sequencing methods remains challenging. Advances in technologies like single-cell sequencing, spatial transcriptomics, and long-read sequencing have opened the door to deeper studies of the brain and diseases like Alzheimer’s, amyotrophic lateral sclerosis (ALS), and schizophrenia.
                        ...
                        07-09-2026, 11:10 AM
                      • SEQadmin2
                        Cancer Drug Resistance: The Lingering Barrier to Rising Survival
                        by SEQadmin2



                        Cancer survival rates have significantly increased in the last few decades in the United States, reaching a combined 70% 5-year survival rate by 2021. Behind this number, there are years of research to find new therapies, drug targets, and early detection methods. But there is one core challenge that keeps slowing down these advances, and it’s about drug resistance.

                        There is no single reason why many patients don’t respond to treatment as expected. Cancer is...
                        07-08-2026, 05:17 AM

                      ad_right_rmr

                      Collapse

                      News

                      Collapse

                      Topics Statistics Last Post
                      Started by SEQadmin2, 07-09-2026, 10:04 AM
                      0 responses
                      21 views
                      0 reactions
                      Last Post SEQadmin2  
                      Started by SEQadmin2, 07-08-2026, 10:08 AM
                      0 responses
                      13 views
                      0 reactions
                      Last Post SEQadmin2  
                      Started by SEQadmin2, 07-07-2026, 11:05 AM
                      0 responses
                      31 views
                      0 reactions
                      Last Post SEQadmin2  
                      Started by SEQadmin2, 07-02-2026, 11:08 AM
                      0 responses
                      31 views
                      0 reactions
                      Last Post SEQadmin2  
                      Working...