Question: Text Editing
gravatar for Jennifer Hillman Jackson
7.0 years ago by
United States
Jennifer Hillman Jackson25k wrote:
Hello Luce, I can explain the use of the tools "Text Manipulation". For each file independently, the following steps will rename the "name" identifier in column 4. I don't believe that there a more direct method, but you may discover one. This type of customization is why the tools are distinct - so they can be used in sequence to do many of the same text manipulations as on the unix line command. There is a biosed command as part of EMBOSS, but that tool works on sequence text, not text files in general. To save time in the future, these steps can be put into a workflow, with a edit of step 2 to customize the new ID text as needed when run. Starting with a 5 column MACS BED file: 1 - Save the track header line with the tool "Select first lines from a dataset" with the option to save the line 1. 2 - Create the working dataset that does not include the first line with the tool "Remove beginning of a file" with the option "Remove first: 1" lines. 3 - Split of up the existing ID with the tool 'Convert delimiters to TAB" using the "Underscores" option. This will split the fourth "name" column into three distinct columns, the last new column will be using to create the new ID. 4 - Create a column in your file named "treatment1_peak_" with the tool "Add column to an existing dataset" This will create an extra column at the end of the BED file, to be used in the new ID. The file should now be: c1 - chrom c2 - start c3 - end c4 - the text "MACS" c5 - the text "peak" c6 - the text will be a number, second part of the new ID c7 - score c8 - the text "treatment1_peak_" (or "treatment2_peak_" if the second file) 5 - Merge the two ID portions with the tool "Merge Columns together" using the option of merging column c8 with c6. This will create a new field, c9, with the text "treatment2_peak_N" where "N" is whatever the number in c6 was, per row. 6 - Create the new BED file, putting the new "name" column in the correct order and omitting the columns not needed, using the tool "Cut columns from a table" and pasting into the "Cut columns:" box the this text (no quotes): c1,c2,c3,c9,c7 7 - Add in back the track line (removed in step 1) with the tool "Concatenate datasets tail-to-head" with the options set to concatenate the output of step#1 as the first file and the output of step 6 as a second file. 8 - Use the Edit Attributes form to change the file type back to BED and assign all five columns to the proper attribute (click on pencil icon to reach form). Hopefully this is will work (it did for my test) or is enough information for you to worked out the exact steps for your particular datasets. Next time, please send data/tool questions directly "to" the mailing list. Replies should be send "reply- all". The outreach account is for other purposes. distinct peaks between them and visualize them. I end up with a MACS bed file for each (listing a bunch of MACS_peaks). I then use the Intersect and Subtract tools from the Genomic Intervals tab and end up with the peaks I want. However, because of the way that MACS names its peaks, there can end up being some peaks named the same way in both files (because, for example, peak 20 in file1 is from position 300,000-300,500 but peak 20 in file 2 is from position 320,000-320,500). So, I can end up with multiple peaks with the same name. Because all the peak names have the same form, it can also be difficult to tell them apart when visualizing them in the UCSC Genome Browser. the text MACS_peak_<number> to, say, treatment1_peak_<number> so that peak 20 would now still be numbered 20 in both files, but would have a different label. This would be pretty easy to do using regular expressions and sed. know that there is a text manipulation tab, but I can't seem to find an easy way to do what I want to do. -- Jennifer Jackson
macs • 2.2k views
ADD COMMENTlink modified 7.0 years ago by Dave Clements ♦♦ 2.5k • written 7.0 years ago by Jennifer Hillman Jackson25k
gravatar for Dave Clements
7.0 years ago by
Dave Clements ♦♦ 2.5k
United States
Dave Clements ♦♦ 2.5k wrote:
Hi Luce, I'm forwarding this question to the Galaxy-User mailing list, as I think this is a pretty common situation. Here's how I replace text in a column. It's a two step process for each dataset. First go to Text Manipulation -> Compute. In the Add expression text box enter columnNum.replace("oldVal", "newVal") In your case I think this is c4.replace("MACS_peak_", "treatment1_peak_", 1) "replace" is a Python character string operation, and c4 is the character string column we are working on. I added the 1 out of paranoia. This tells galaxy to only replace the first occurrence of the old string, in each line. Care must be taken to avoid more replacement than you want. Executing this will create a dataset with a new column at the end. Now, use the Text Manipulation -> Cut operation to substitute the new column in place of the old column. Does that do the trick? Thanks, Dave C. --
ADD COMMENTlink written 7.0 years ago by Dave Clements ♦♦ 2.5k
Thanks! This worked perfectly. luce
ADD REPLYlink written 7.0 years ago by Lucy A. Skrabanek20
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 172 users visited in the last hour