Question: txt file to bigwig
0
gravatar for tanni93
5.3 years ago by
tanni9320
United States
tanni9320 wrote:

Hi all,

After scanning my FastA file for motifs MEME had outputted a txt file --> I  now need this in bigwig format in order to analyze regions in IGV. How can I convert a text file to a bigwig file?

Any help is appreciated!

 

file conversion • 2.9k views
ADD COMMENTlink modified 4.7 years ago by Dataman330 • written 5.3 years ago by tanni9320

What does your text file look like? Could you paste a short example?

ADD REPLYlink written 5.3 years ago by jotan1.2k

sample lines:

#pattern name    sequence name    start    stop    strand    score    p-value    q-value    matched sequence
1    mm9_chr14_48902729_48903386_+    562    576    -    22.5574    6.73e-09    0.182    GCATGTCCAGGCATG
1    mm9_chr9_54962288_54963350_+    779    793    -    22.0164    1.17e-08    0.182    GCAAGCCCAGACATG
1    mm9_chr3_80861952_80862800_+    384    398    -    21.5082    2.38e-08    0.244    ACAAGCCCAGGCATG
1    mm9_chr1_137651753_137653400_+    559    573    -    21.1148    4.07e-08    0.244    GCTTGTCCAGACATG
1    mm9_chr5_111972284_111973197_+    414    428    -    21.0492    4.31e-08
ADD REPLYlink modified 15 months ago by Ram32k • written 5.3 years ago by tanni9320

sample lines:

#pattern name    sequence name    start    stop    strand    score    p-value    q-value    matched sequence
1    mm9_chr14_48902729_48903386_+    562    576    -    22.5574    6.73e-09    0.182    GCATGTCCAGGCATG
1    mm9_chr9_54962288_54963350_+    779    793    -    22.0164    1.17e-08    0.182    GCAAGCCCAGACATG
1    mm9_chr3_80861952_80862800_+    384    398    -    21.5082    2.38e-08    0.244    ACAAGCCCAGGCATG
1    mm9_chr1_137651753_137653400_+    559    573    -    21.1148    4.07e-08    0.244    GCTTGTCCAGACATG
1    mm9_chr5_111972284_111973197_+    414    428    -    21.0492    4.31e-08
ADD REPLYlink modified 15 months ago by Ram32k • written 5.3 years ago by tanni9320
2

to me wiggle file wouldn't be a good options, from what I understand wiggle file is good for representing something at a given genomic position, although position can span multiple bases.. I'm pretty sure you'll be better off investigating bed format and trying to convert your text file into bed, which also has bigBed - binary version. I believe IGV and other viewers accept those formats. In fact your file is essentially bed file, all you need to do is to chop last few columns out. You might want to keep score values in. For more look here https://genome.ucsc.edu/FAQ/FAQformat.html#format1

ADD REPLYlink modified 15 months ago by Ram32k • written 5.3 years ago by Kirill300

I also agree with Kirill that BED file is more appropriate for your need.

ADD REPLYlink written 4.7 years ago by Dataman330
1
gravatar for Kirill
5.3 years ago by
Kirill300
Australia
Kirill300 wrote:

Hi Tanni93,

Most likely you will need to do some custom scripting in your preferred language (python..?)... Like jotan1982 mentioned you should post head of the file you are trying to make your wiggle file from, this may help us to provide you with more specific answer. I personally don't know of any tools that convert any text files into wiggle file.

Don't get confused about bigWig and wig files. What you want is to convert your text file into wiggle file (.wig). Here is specification on how wiggle file should look like http://genome.ucsc.edu/goldenpath/help/wiggle.html. Wiggle file is just flat text file that follows some specifications. You then will need to download wigToBigWig tool that will convert your wiggle file into binary version - bigWig file. Here https://genome.ucsc.edu/goldenpath/help/bigWig.html you can find more information on how to make bigWig from wig and also a link to directory to where you can download wigToBigWig tool.

A note aside; I have fairly recently played around with wiggle files and IGV and as far as I can tell IGV didn't handle my wiggle file with two separate track, i.e track for forward reads and track for reverse reads all in one file..IGV would only display the last track in the file, whereas UCSC browser displayed both track no problem. I didn't try to convert to bigWig. (yes thats another point that I just realised IGV can handle wiggle file fine).

Its rather had to tell what format you should use, since very little information is provided about your file, but maybe different file format might be more appropriate e.g bed format, should also be handled by IGV.

Cheers,
Kirill

ADD COMMENTlink modified 15 months ago by Ram32k • written 5.3 years ago by Kirill300

Thank you Kirill! Very helpful advice!

ADD REPLYlink written 5.3 years ago by tanni9320
0
gravatar for Dataman
4.7 years ago by
Dataman330
Finland
Dataman330 wrote:

As Kirill mentioned, BED format is a better option. Here is my Python script which does the BED conversion for you. Note that this script is for demonstration purpose and you need to change the code a bit to get your desired output. Also note that part of your data is missing, however, you can also concatenate them together and for instance put them on the 4th column of your result file.

fin = open('my_orig_file.txt', 'r')
fout = open('my_bed_file.bed', 'w')
next(fin)
for l in fin:
    cols = l.strip().split('\t')
    fout.write('%s\t%s\t%s\t%s\t%s\t%s\n' %(cols[0], cols[2], cols[3], cols[1], cols[5], cols[4]))    
fin.close()
fout.close()

Assumptions:
1. I have assumed that the columns in your file is tab-separated that is why .split('\t'). You can change it accordingly.

This is how one of the rows will look like in the IGV:

enter image description here

ADD COMMENTlink modified 4.7 years ago • written 4.7 years ago by Dataman330
Please log in to add an answer.

Help
Access

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