SEQanswers

Go Back   SEQanswers > Bioinformatics > Bioinformatics



Similar Threads
Thread Thread Starter Forum Replies Last Post
SOAP alignment format convert to SAM/BAM KevinLam Bioinformatics 31 01-10-2018 09:05 PM
Dindel SAM/BAM format - viewing with IGV EHC General 0 10-06-2011 11:27 AM
How to convert BED format to SAM/BAM? seq_newbie Bioinformatics 1 06-23-2011 09:11 AM
Looking process to convert gff3 format into ace format or sam format andylai Bioinformatics 1 05-17-2011 03:09 AM
customize SAM/BAM format plichel Bioinformatics 1 03-22-2010 07:39 PM

Reply
 
Thread Tools
Old 10-18-2010, 07:11 AM   #1
pinki999
Member
 
Location: Germany

Join Date: Oct 2010
Posts: 37
Default SAM/BAM format to wiggle format

Hi,

Can anyone tell me how to convert SAM/BAM format to wiggle format?


Regards,
Pinki
pinki999 is offline   Reply With Quote
Old 10-18-2010, 07:19 AM   #2
shurjo
Senior Member
 
Location: Rockville, MD

Join Date: Jan 2009
Posts: 126
Default

You could try the rsem-bam2wig utility from RSEM(http://deweylab.biostat.wisc.edu/rsem/docs.html).
shurjo is offline   Reply With Quote
Old 10-18-2010, 11:15 AM   #3
dawe
Senior Member
 
Location: 4530'25.22"N / 915'53.00"E

Join Date: Apr 2009
Posts: 258
Default

Quote:
Originally Posted by pinki999 View Post
Hi,

Can anyone tell me how to convert SAM/BAM format to wiggle format?
Take a look here, examples 2 and 3.

d
dawe is offline   Reply With Quote
Old 10-18-2010, 12:18 PM   #4
ETHANol
Senior Member
 
Location: Western Australia

Join Date: Feb 2010
Posts: 308
Default

If you are doing ChIP-seq, MACS writes you wig files as part of its output and is really simple to use. Some other software chip-seq software packages do the same.
ETHANol is offline   Reply With Quote
Old 10-19-2010, 07:41 AM   #5
mgogol
Senior Member
 
Location: Kansas City

Join Date: Mar 2008
Posts: 197
Default

You can use bedtools to get a bedgraph:

samtools sort sample.bam sample.sorted

genomeCoverageBed -bg -ibam sample.sorted.bam -g chromsizes.txt > sample.bedgraph

#on second look, dawe already said this, but the page was down for me.
mgogol is offline   Reply With Quote
Old 10-19-2010, 07:45 AM   #6
Thomas Doktor
Senior Member
 
Location: University of Southern Denmark (SDU), Denmark

Join Date: Apr 2009
Posts: 105
Default

Yet another way if you have a raw SAM file:
TopHat has an undocumented tool, Wiggles, which will compute coverage of a SAM file and produce a bedgraph file (usage will tell you that it outputs a .wig file, but it really is a bedgraph file).

Note that the Wiggles tool will probably be removed from the source of TopHat as it is no longer used by the TopHat pipeline.
Thomas Doktor is offline   Reply With Quote
Old 10-29-2010, 01:53 AM   #7
pinki999
Member
 
Location: Germany

Join Date: Oct 2010
Posts: 37
Default

Hello Friends,

Thank you for your valuable information.
pinki999 is offline   Reply With Quote
Old 11-22-2010, 06:32 AM   #8
seq_GA
Senior Member
 
Location: Asiana

Join Date: Feb 2009
Posts: 124
Default

HiI tried using RSEM and I get segmentation fault. I tried using sorted bam file but still I get segmentation fault. Any clue on this? Thanks.
seq_GA is offline   Reply With Quote
Old 11-22-2010, 07:35 AM   #9
seq_GA
Senior Member
 
Location: Asiana

Join Date: Feb 2009
Posts: 124
Default

I also tried using bedtools as mentioned above.
Quote:
Take a look here, examples 2 and 3.
Code:
Example 3
Summary:    A slightly different way (than ex. 2) to create BigWig files from BAM
Contributor: Assaf Gordon
Date:             09-July-2010
Tools used:  samtools, genomeCoverageBed, bedGraphToBigWig
More Information : http://cancan.cshl.edu/labmembers/gordon/files/viz2.pdf
============================================================
Workflow:
# 1. Convert SAM to BAM
samtools view -S -b -o sample.bam sample.sam
# 2. Sort the BAM file
samtools sort sample.bam sample.sorted
# 3. Create BedGraph coverage file
genomeCoverageBed -bg -ibam sample.sorted.bam -g chromsizes.txt > sample.bedgraph
# 4. Convert the BedGraph file to BigWig
bedGraphToBigWig sample.bedgraph chromsizes.txt sample.bw
But the output sample.bw is not a human readable file. But I have ot tried uploading them into ucsc yet. Why is it so? Anyone has tried above steps? Thanks.
seq_GA is offline   Reply With Quote
Old 11-22-2010, 09:15 AM   #10
adamdeluca
Member
 
Location: Iowa City, IA

Join Date: Jul 2010
Posts: 95
Default

Quote:
Originally Posted by seq_GA View Post
But the output sample.bw is not a human readable file. But I have ot tried uploading them into ucsc yet. Why is it so? Anyone has tried above steps? Thanks.
bigwig is a binary format. UCSC has utilities for reading the file format, bigWigSummary bigWigToBedGraph etc.
adamdeluca is offline   Reply With Quote
Old 11-22-2010, 05:25 PM   #11
seq_GA
Senior Member
 
Location: Asiana

Join Date: Feb 2009
Posts: 124
Default

Quote:
Originally Posted by adamdeluca View Post
bigwig is a binary format. UCSC has utilities for reading the file format, bigWigSummary bigWigToBedGraph etc.

Thanks for your response. I tried uploading into ucsc but i get the following error:

Code:
Error Can't read file: output.bw
I have uploaded the zipped test output.
Attached Files
File Type: zip output.zip (1.4 KB, 6 views)
seq_GA is offline   Reply With Quote
Old 11-22-2010, 06:37 PM   #12
adamdeluca
Member
 
Location: Iowa City, IA

Join Date: Jul 2010
Posts: 95
Default

http://genome.ucsc.edu/FAQ/FAQformat.html#format6.1

bigWig files are to be linked from your ftp/http server. That way you don't need to transfer the whole file to UCSC, just what is needed for a given view. I don't think you can upload them to ucsc. bigWigInfo can parse the file you uploaded so it appears valid. You should be able to upload the bedGraph file from step 3.

http://genome.ucsc.edu/goldenPath/help/bedgraph.html
adamdeluca is offline   Reply With Quote
Old 11-22-2010, 06:57 PM   #13
seq_GA
Senior Member
 
Location: Asiana

Join Date: Feb 2009
Posts: 124
Default

Hi adamdeluca,
Thanks for your response. I have a bedgraph as below:
Code:
chr10   68271   68272   44
chr10   68272   68274   43
chr10   68274   68275   46
chr10   68275   68282   50
chr10   68282   68283   52
chr10   68283   68284   55
chr10   68284   68285   54
chr10   68285   68287   59
chr10   68287   68289   62
chr10   68289   68291   54
Is there any procedure to upload them into tracks. Because I want to see the density graph like. Thanks.
seq_GA is offline   Reply With Quote
Old 12-04-2010, 03:40 PM   #14
repinementer
Member
 
Location: asia

Join Date: Dec 2009
Posts: 80
Default

shouldn't you go for normalized reads visualization instead of raw reads(SAM/BAM) ?
repinementer is offline   Reply With Quote
Old 03-29-2012, 01:45 PM   #15
liguow
Member
 
Location: Houston

Join Date: Apr 2009
Posts: 12
Default

Quote:
Originally Posted by pinki999 View Post
Hi,

Can anyone tell me how to convert SAM/BAM format to wiggle format?


Regards,
Pinki
Surprisingly to find that this problem is still not well resolved.

I write a python program "bam2wig.py" that is specially designed for RNA-seq, so it works fine for spliced read, for both single-end and pair-end, for both strand-specific and non-strand specific RNA-seq data.

The input BAM file should be sorted and indexed using SamTools before hand.

http://code.google.com/p/rseqc/downloads/list

Best,
liguow is offline   Reply With Quote
Old 02-04-2013, 11:56 AM   #16
mdb@wistar
Junior Member
 
Location: new jersey

Join Date: Jan 2013
Posts: 9
Default

Quote:
Originally Posted by liguow View Post
Surprisingly to find that this problem is still not well resolved.

I write a python program "bam2wig.py" that is specially designed for RNA-seq, so it works fine for spliced read, for both single-end and pair-end, for both strand-specific and non-strand specific RNA-seq data.

The input BAM file should be sorted and indexed using SamTools before hand.

http://code.google.com/p/rseqc/downloads/list

Best,
Unfortunately, the bam2wig.py always gives error and quits:
DeprecationWarning: the sets module is deprecated
import sets

and it is not possble to modify the bam2wig.py downloaded from RseqC since it is read only.
mdb@wistar is offline   Reply With Quote
Old 02-04-2013, 12:24 PM   #17
liguow
Member
 
Location: Houston

Join Date: Apr 2009
Posts: 12
Default

Quote:
Originally Posted by mdb@wistar View Post
Unfortunately, the bam2wig.py always gives error and quits:
DeprecationWarning: the sets module is deprecated
import sets

and it is not possble to modify the bam2wig.py downloaded from RseqC since it is read only.
Interesting. I used it without any problem (I am using python2.7). And, if you can download it, you can do whatever you want.
liguow is offline   Reply With Quote
Old 02-04-2013, 12:35 PM   #18
mdb@wistar
Junior Member
 
Location: new jersey

Join Date: Jan 2013
Posts: 9
Default

Quote:
Originally Posted by liguow View Post
Interesting. I used it without any problem (I am using python2.7). And, if you can download it, you can do whatever you want.
funny, I too have python 2.7. I read somewhere that the 'sets' problem began with python 2.4 and using python2.3 or earlier versions may solve the problem. but sam2wig is not supported by older python versions, so I am stuck now
all other packages from RSeQC have worked except bam2wig.
mdb@wistar is offline   Reply With Quote
Old 07-30-2015, 07:52 PM   #19
ESiPS
Junior Member
 
Location: china

Join Date: Oct 2012
Posts: 2
Default

Quote:
Originally Posted by mdb@wistar View Post
funny, I too have python 2.7. I read somewhere that the 'sets' problem began with python 2.4 and using python2.3 or earlier versions may solve the problem. but sam2wig is not supported by older python versions, so I am stuck now
all other packages from RSeQC have worked except bam2wig.
Me too.

Code:
$ bam2wig.py -i 3Aligned.out.sorted.bam -s Drosophila_melanogaster.BDGP6.dna.toplevel.fa.fai.chrom.sizes -o 3Aligned.out.sorted.bam --skip-multi-hits -d --strand='1+-,1-+,2++,2--'
Skip multi-hits:True
Processing 211000022279100 ...
Processing 211000022279101 ...
Processing 211000022279102 ...
Processing 211000022279103 ...
Processing 211000022279104 ...
Traceback (most recent call last):
  File "/usr/local/bin/bam2wig.py", line 5, in <module>
    pkg_resources.run_script('RSeQC==2.6.1', 'bam2wig.py')
  File "build/bdist.macosx-10.10-x86_64/egg/pkg_resources/__init__.py", line 696, in run_script
  File "build/bdist.macosx-10.10-x86_64/egg/pkg_resources/__init__.py", line 1614, in run_script
  File "/usr/local/lib/python2.7/site-packages/RSeQC-2.6.1-py2.7-macosx-10.10-x86_64.egg/EGG-INFO/scripts/bam2wig.py", line 103, in <module>
    main()
  File "/usr/local/lib/python2.7/site-packages/RSeQC-2.6.1-py2.7-macosx-10.10-x86_64.egg/EGG-INFO/scripts/bam2wig.py", line 100, in main
    obj.bamTowig(outfile = options.output_prefix, chrom_sizes = chromSizes, chrom_file = options.chromSize, q_cut = options.map_qual, skip_multi=options.skip_multi,strand_rule = options.strand_rule, WigSumFactor=norm_factor)
  File "/usr/local/lib/python2.7/site-packages/RSeQC-2.6.1-py2.7-macosx-10.10-x86_64.egg/qcmodule/SAM.py", line 2597, in bamTowig
    if strandRule[key] == '+':Fwig[pos] +=1.0
KeyError: '1+'
ESiPS is offline   Reply With Quote
Old 08-12-2015, 01:35 AM   #20
ESiPS
Junior Member
 
Location: china

Join Date: Oct 2012
Posts: 2
Default

The bam2wig.py worked well after I change the genome version into a new one. Still do not know the reason.
ESiPS is offline   Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off




All times are GMT -8. The time now is 08:58 PM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Single Sign On provided by vBSSO