Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hari_iyer16
    Junior Member
    • Feb 2013
    • 8

    #1

    pipe two inputs to a command (coverageBed)

    Hi,
    I am trying to run coverageBed on my data. Since it is huge, I have to split the data into each chromosome and run them separately. coverageBed takes two input files, the data.bed file (contains the sequencing data) and the windows.bed (a file with defined windows in which the sequencing coverage has to be estimated). I thought it would be a good idea to grep for each chromosome in the data.bed and windows.bed and pipe that input to the coverageBed command. How do I simultaneously grep from two files and pass the two outputs to coverageBed? I figured how I can pipe one file (shown below), but struggling with piping two files simultaneously.
    grep -w 'chr[1]' data.bed| coverageBed -counts -a stdin -b ExtraFiles_for_Analysis/windows_chr1.bed | sortBed -i stdin > chr1_coverage.txt

    In the above command, windows_chr1.bed is the file containing only the windows in chromosome-1, which I had to create separately. So my goal is not to create separate files for each chromosomes a priori, and instead be able to create that in the same line.

    And secondly, can I use some loop so that I can do this for each chromosome?
    I searched a lot in online forums and couldn't get anything.
    Thanks for any help or pointers.
    Hari
  • kmcarr
    Senior Member
    • May 2008
    • 1181

    #2
    You could do this with named pipes.

    Code:
    mkfifo data
    mkfifo windows
    This will create two special files in the current directory named data and windows respectively.

    Code:
    grep -w 'chr[1]' data.bed > data &
    grep -w 'chr[1]' windows.bed > windows &
    
    coverageBed -counts -a data -b windows | sortBed -i stdin > chr1_coverage.txt
    When the coverageBed task completes the grep jobs in the background will terminate. You can then reuse the same named pipes while iterating through each of the chromosomes.

    Comment

    • lh3
      Senior Member
      • Feb 2008
      • 686

      #3
      coverageBed -counts -a <(grep chr1 data.beg) -b <(grep chr1 windows.beg)

      Comment

      • syfo
        Just a member
        • Nov 2012
        • 103

        #4
        Originally posted by lh3 View Post
        coverageBed -counts -a <(grep chr1 data.beg) -b <(grep chr1 windows.beg)
        That looks great, thanks.
        Of course do not forget the "-w" option to only grep the chr1 and not chr10, chr11 etc (I would actually use awk ' $1=="chr1" ' < data.bed).

        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
        16 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, Yesterday, 10:48 AM
        0 responses
        15 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 10-15-2026, 10:52 AM
        0 responses
        35 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...