Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tonybert
    Member
    • Aug 2012
    • 38

    #1

    creating tab-delimited output from unix

    greetings, i have a large list of taxonomic information from a blast search in a text file (taxa.txt, see below).

    $ head -5 taxa.txt
    Eukaryota;Opisthokonta;Fungi;Ascomycota
    Bacteria;Candidate division OD1;marine metagenome
    Bacteria;Planctomycetes;Phycisphaerae
    Bacteria;Cyanobacteria;Chloroplast;
    Eukaryota;Opisthokonta;Fungi;Ascomycota;

    What i would like to do is create a bar plot of this data in excel or R. To do this, I have been using sort and uniq to tally up each of the hits.

    $sort -u taxa.txt|uniq -c > sorted_taxa.txt
    $head -5 sorted_taxa.txt
    1 Archaea;Euryarchaeota;Halobacteria
    1 Archaea;Euryarchaeota;Thermoplasmata
    1 Archaea;Thaumarchaeota;Marine Group I
    1 Archaea;Thaumarchaeota;Marine Group I
    1 Archaea;Thaumarchaeota;Soil Crenarchaeotic Group(SCG)

    However, when i open this file, and copy and paste the results into excel, it treats each row as one single string. What I would like is for there to be two columns (at least) in output, the column describing the count, and the column describing the taxonomic information. I believe this would be tab-delimited output. Is there a way to tell unix to produce such a result? Thanks,

    -Tony
  • BAMseek
    Senior Member
    • Apr 2011
    • 124

    #2
    Hi Tony,

    First thing I noticed is that I think you want to remove the "-u" flag from the sort. The -u flag will remove duplicate lines, so when you do "uniq -c", you will get all 1s.

    Something like this might work:

    Code:
    sort taxa.txt | uniq -c | awk '{$1=$1};1' | awk '{sub(/\ /,"\t")};1' > histo.txt
    The first awk command gets rid of leading, trailing, and extra white spaces. The second awk command replaces the first space with a tab (both commands from awk one-liners).

    Hope that helps,
    Justin

    Comment

    • maubp
      Peter (Biopython etc)
      • Jul 2009
      • 1544

      #3
      Why not open it in Excel (or R or ...) but specify the separators are semi-colons?

      Comment

      Latest Articles

      Collapse

      • SEQadmin2
        Multiomic Liquid Biopsy: What DNA/RNA Panels Reveal That DNA Alone Can’t
        by SEQadmin2



        Tumors contain complex mixtures of cell populations that evolve in response to treatment and host-specific factors. Tissue biopsies provide only static snapshots of a tumor’s state. But what if we could follow that evolution over time using a minimally invasive technique?

        Liquid biopsies can detect tumor-derived material circulating in the bloodstream, providing a way to study treatment response, detect emerging resistance, and discover new biomarkers. Circulating
        ...
        10-14-2026, 09:55 AM
      • SEQadmin2
        New Genomics Technologies Take Aim at Long-Standing Limits
        by SEQadmin2


        Researchers using sequencing and genomics tools often have to make trade-offs. They can choose between speed or scale, short reads or long-range information, or targeted panels or a view of the whole transcriptome. New technologies that have been released this year are built to address those tough choices.

        We asked six companies the same four questions to learn about their latest products. The new technologies bring a lot to the table, including rethinking sequencing
        ...
        09-28-2026, 10:25 AM

      ad_right_rmr

      Collapse

      News

      Collapse

      Topics Statistics Last Post
      Started by SEQadmin2, Yesterday, 11:13 AM
      0 responses
      21 views
      0 reactions
      Last Post SEQadmin2  
      Started by SEQadmin2, Yesterday, 10:48 AM
      0 responses
      18 views
      0 reactions
      Last Post SEQadmin2  
      Started by SEQadmin2, 10-15-2026, 10:52 AM
      0 responses
      36 views
      0 reactions
      Last Post SEQadmin2  
      Started by SEQadmin2, 10-14-2026, 05:39 AM
      0 responses
      42 views
      0 reactions
      Last Post SEQadmin2  
      Working...