It works using ucsc genome gft file
1) cufflinks
/home/xusheng/Biosoft/cufflinks-1.0.3.Linux_x86_64/cufflinks -p 16 -g /home/xusheng/GenomeSequence/Human/refGene.gtf -o AD1 AD1_accepted_hits.bam
2) cuffcompare
/home/xusheng/Biosoft/cufflinks-1.0.3.Linux_x86_64/cuffcompare -V -r /home/xusheng/GenomeSequence/Human/refGene.gtf -s /home/xusheng/GenomeSequence/Human/hg19.fa -R -o s7_s8_refGene AD1/transcripts.gtf Nor3/transcripts.gtf
3. cuffdiff
home/xusheng/Biosoft/cufflinks-1.0.3.Linux_x86_64/cuffdiff -p 16 s7_s8_refGene.combined.gtf AD1/AD1_accepted_hits.bam Nor3/Nor3_accepted_hits.bam
Saturday, July 30, 2011
Friday, July 29, 2011
Cufflinks problem
After running tophat, we get accepted_hits.bam file
1. /home/xusheng/Biosoft/cufflinks-1.0.3.Linux_x86_64/cufflinks -p 16 -g /home/xusheng/GenomeSequence/Human/Homo_sapiens.GRCh37.63.gtf Nor3_accepted_hits.bam
/home/xusheng/Biosoft/cufflinks-1.0.3.Linux_x86_64/cufflinks -p 16 -g Genes_July_2010_hg19.gff AD3_accepted_hits.bam (gff file only contain gene info)
remember: 1. use the UCSC gff file or ENSEMBL gff file; 2. specify the sequence file when performing the cuffcompare analysis, as the following command; 3. use -g rather than -G
3. cuffcompare step
/home/xusheng/Biosoft/cufflinks-1.0.3.Linux_x86_64/cuffcompare -o adnor_compare -s /home/xusheng/GenomeSequence/Human/Ensembl/Hs19_Ensembl.fa -r /home/xusheng/GenomeSequence/Human/Homo_sapiens.GRCh37.63.gtf AD1/AD1_transcripts.gtf AD3/AD3_transcripts.gtf AD4/AD4_transcripts.gtf AD6/AD6_transcripts.gtf AD7/AD7_transcripts.gtf Nor3/Nor3_transcripts.gtf Nor4/Nor4_transcripts.gtf Nor5/Nor5_transcripts.gtf Nor7/Nor7_transcripts.gtf
good links:
http://dingo.ucsf.edu/twiki/bin/view/Cores/BioinformaticsCore/RnaSeqAnalysis
tophat-cufflinks-cuffcompare-cuffdiff (2011-03-29 15:28:55)转载
标签: 杂谈 分类: Nextgenerationsequencing
1. Creation of a genome index (needed for Bowtie and TopHat to operate)
bowtie-build genome.fa bowtie_output/genome
2. Alignments of RNA-seq reads to the genome with identification of exon-exon splice functions using TopHat
tophat -o tophat_output/ bowtie_output/genome reads.fastq
3. Assembly of RNA-seq reads into transcripts and report of the RPKM/FPKM using Cufflinks
cufflinks -o cufflinks_output/ --reference-seq genome.fa tophat_output/accepted_hits.bam
4. Comparison of assembled transcripts with a reference annotation, or across experiments, using Cuffcompare
cuffcompare -o cuffcompare_output -r genome.gtf -R cufflinks_output/transcripts.gtf
5. Finding significant changes in transcript expression, splicing, and promoter use using Cuffdiff
cuffdiff -o cuffdiff_output/ cufflinks_output/transcripts.gtf tophat_output/accepted_hits1a.bam,tophat_output/accepted_hits1b.bam tophat_output/accepted_hits2.bam
(in this example, accepted_hits1a.bam and accepted_hits1b.sam are replicates, while accepted_hits2.bam is another experimental condition)
1. /home/xusheng/Biosoft/cufflinks-1.0.3.Linux_x86_64/cufflinks -p 16 -g /home/xusheng/GenomeSequence/Human/Homo_sapiens.GRCh37.63.gtf Nor3_accepted_hits.bam
/home/xusheng/Biosoft/cufflinks-1.0.3.Linux_x86_64/cufflinks -p 16 -g Genes_July_2010_hg19.gff AD3_accepted_hits.bam (gff file only contain gene info)
remember: 1. use the UCSC gff file or ENSEMBL gff file; 2. specify the sequence file when performing the cuffcompare analysis, as the following command; 3. use -g rather than -G
3. cuffcompare step
/home/xusheng/Biosoft/cufflinks-1.0.3.Linux_x86_64/cuffcompare -o adnor_compare -s /home/xusheng/GenomeSequence/Human/Ensembl/Hs19_Ensembl.fa -r /home/xusheng/GenomeSequence/Human/Homo_sapiens.GRCh37.63.gtf AD1/AD1_transcripts.gtf AD3/AD3_transcripts.gtf AD4/AD4_transcripts.gtf AD6/AD6_transcripts.gtf AD7/AD7_transcripts.gtf Nor3/Nor3_transcripts.gtf Nor4/Nor4_transcripts.gtf Nor5/Nor5_transcripts.gtf Nor7/Nor7_transcripts.gtf
good links:
http://dingo.ucsf.edu/twiki/bin/view/Cores/BioinformaticsCore/RnaSeqAnalysis
tophat-cufflinks-cuffcompare-cuffdiff (2011-03-29 15:28:55)转载
标签: 杂谈 分类: Nextgenerationsequencing
1. Creation of a genome index (needed for Bowtie and TopHat to operate)
bowtie-build genome.fa bowtie_output/genome
2. Alignments of RNA-seq reads to the genome with identification of exon-exon splice functions using TopHat
tophat -o tophat_output/ bowtie_output/genome reads.fastq
3. Assembly of RNA-seq reads into transcripts and report of the RPKM/FPKM using Cufflinks
cufflinks -o cufflinks_output/ --reference-seq genome.fa tophat_output/accepted_hits.bam
4. Comparison of assembled transcripts with a reference annotation, or across experiments, using Cuffcompare
cuffcompare -o cuffcompare_output -r genome.gtf -R cufflinks_output/transcripts.gtf
5. Finding significant changes in transcript expression, splicing, and promoter use using Cuffdiff
cuffdiff -o cuffdiff_output/ cufflinks_output/transcripts.gtf tophat_output/accepted_hits1a.bam,tophat_output/accepted_hits1b.bam tophat_output/accepted_hits2.bam
(in this example, accepted_hits1a.bam and accepted_hits1b.sam are replicates, while accepted_hits2.bam is another experimental condition)
Sunday, July 24, 2011
在vi中如何删除^M
在vi中如何删除^M
2011-06-21 12:34:00 发表于互联网事 本文链接: 在vi中如何删除^M
如果你是用某些windows编辑器编辑的文件,很可能就会产生多余的^M转义符合,当然这些符号在wxin下是看不到的。
但是某天,你在linux下,用vim打开,发现文件中很多^M,那是多么的恶心啊,如下图:
这个时候就要vim的替换功能了,替换命令很简单 :%s/^M//g 也就是将全部的^M替换成空。
但是你可能会发现,如果你直接用键盘输入^M,是替换不成功滴,所以这里有个小技巧,^M不是直接输出来的,而是要用 ctrl+v 接下来ctrl+m 才能出现真正的文件中的^M.
上面这行,才是这篇日志记录的主要目的,因为我每次想替代^M总会忘记如何打出^M.
2011-06-21 12:34:00 发表于互联网事 本文链接: 在vi中如何删除^M
如果你是用某些windows编辑器编辑的文件,很可能就会产生多余的^M转义符合,当然这些符号在wxin下是看不到的。
但是某天,你在linux下,用vim打开,发现文件中很多^M,那是多么的恶心啊,如下图:
这个时候就要vim的替换功能了,替换命令很简单 :%s/^M//g 也就是将全部的^M替换成空。
但是你可能会发现,如果你直接用键盘输入^M,是替换不成功滴,所以这里有个小技巧,^M不是直接输出来的,而是要用 ctrl+v 接下来ctrl+m 才能出现真正的文件中的^M.
上面这行,才是这篇日志记录的主要目的,因为我每次想替代^M总会忘记如何打出^M.
Monday, May 2, 2011
黄艺博在2009年武汉市总队长竞选活动上的讲话
黄艺博在2009年武汉市总队长竞选活动上的讲话
同志们:
今天,我们在这里召开的2009年武汉市总队长竞选活动,我认为,这个会议是十分必要的,召开的相当及时。通过这个会议的召开,对于少先队工作的开展,具有十分重要的指导意义。对于刚才徐鎏杨同学的重要讲话,以及众多同学踊跃的发言,我认为,讲的非常好,非常深刻。希望在座的同志,认真领会,深刻理解。主要还是徐鎏杨领导的重要讲话,希望各位回去后,要及时向同志们传达,认真领会徐鎏杨领导的重要讲话精神,抓好落实、真抓实干,推动少先队工作的顺利开展,努力开创少先队工作的新局面。 在这里,对于少先队的工作,我想提几点补充意见:
一、对于少先队的工作,我们要从思想上提高认识,充分领会少先队工作的重要性和必要性。
目前,少先队工作已经开创了很大的局面,获得了很大的成绩,这是有目共睹的吗!但是,还是要从深度和广度上更加推进少先队工作。我看,最重要的一点是:提高认识!是的,提高认识。各级领导要充分领会少先队工作的重要性和必要性,各级党组织要加强关于少先队工作的宣传力度,形成上下“齐抓共管”的局面,只有这样,少先队工作才能更上层楼。
二、 对于少先队工作,要加强落实,要把工作落到实处。
目前,有个别同志、个别部门,存在一个很不好的现象,就是:热衷于搞形式主义,热衷于开大会,传达文件。
当然,开大会嘛,还是有必要的,上传下达也是必须的。但是,光是讲空话、打官腔,是远远不够的。对少先队的工作,我们要真抓实干,加强落实。各级领导要把深入基层的工作,列入日常议事日程,要具体部署,认真执行。各级领导要为工作,创造必要的物质条件和舆论环境,扎扎实实推动工作的开展。要抓出实效,抓出成绩。
三、 要加强联系,搞好协调工作。
历史证明:钢铁一样的团结,是我武汉少先队消除一切困难的有力武器。关于工作也一样,各级领导要加强协调工作,要把上下、左右、各方面、各环节有机结合起来,步调一致地推进少先队工作的开展。目前,有些部门,遇事推诿、互相扯皮,这种官僚主义的作风是十分要不得的!这种作风,轻则导致工作效率降低,重则影响党和政府的威信。我们要坚决铲除这种官僚主义作风。有关职能部门的同志,在开展深入基层工作中,要加强联系,搞好协调工作,务必把工作做好。
四、要在实践中探索少先队工作与市场经济有机结合的新路子。
少先队工作与市场经济有没有关系,我看是大有关系。市场经济是一场深刻的社会变革,它的影响将波及社会生活的每一个领域,少先队的工作也不例外,它必然会受市场经济的影响,因此,如何适应市场经济的要求,如何和市场经济有机结合起来,希望大家认真的思考一下,去探索一下,这是十分有意义的。
五、参与深入基层工作的同志,要有自豪感和责任感。
同志们,对于少先队的工作,政府是非常重视的;各级组织也投入大量的人力、物力、财力来推进这项工作的开展。同志们,你们承担的是中国的未来,是肩负了各级组织对你们的殷切希望的,希望你们要脚踏实地、同心同德、努力工作,在各自的岗位上为社会主义建设,为改革开放,添砖加瓦!
以上五点意见,供同志们参考。总之,希望大家要振奋精神,多干实事,少说空话,开拓进取,努力开创少先队工作的新局面。
我的讲话完了。最后祝同志们五一劳动节愉快,工作顺利。为中华之崛起而奋斗!
谢谢各位!
同志们:
今天,我们在这里召开的2009年武汉市总队长竞选活动,我认为,这个会议是十分必要的,召开的相当及时。通过这个会议的召开,对于少先队工作的开展,具有十分重要的指导意义。对于刚才徐鎏杨同学的重要讲话,以及众多同学踊跃的发言,我认为,讲的非常好,非常深刻。希望在座的同志,认真领会,深刻理解。主要还是徐鎏杨领导的重要讲话,希望各位回去后,要及时向同志们传达,认真领会徐鎏杨领导的重要讲话精神,抓好落实、真抓实干,推动少先队工作的顺利开展,努力开创少先队工作的新局面。 在这里,对于少先队的工作,我想提几点补充意见:
一、对于少先队的工作,我们要从思想上提高认识,充分领会少先队工作的重要性和必要性。
目前,少先队工作已经开创了很大的局面,获得了很大的成绩,这是有目共睹的吗!但是,还是要从深度和广度上更加推进少先队工作。我看,最重要的一点是:提高认识!是的,提高认识。各级领导要充分领会少先队工作的重要性和必要性,各级党组织要加强关于少先队工作的宣传力度,形成上下“齐抓共管”的局面,只有这样,少先队工作才能更上层楼。
二、 对于少先队工作,要加强落实,要把工作落到实处。
目前,有个别同志、个别部门,存在一个很不好的现象,就是:热衷于搞形式主义,热衷于开大会,传达文件。
当然,开大会嘛,还是有必要的,上传下达也是必须的。但是,光是讲空话、打官腔,是远远不够的。对少先队的工作,我们要真抓实干,加强落实。各级领导要把深入基层的工作,列入日常议事日程,要具体部署,认真执行。各级领导要为工作,创造必要的物质条件和舆论环境,扎扎实实推动工作的开展。要抓出实效,抓出成绩。
三、 要加强联系,搞好协调工作。
历史证明:钢铁一样的团结,是我武汉少先队消除一切困难的有力武器。关于工作也一样,各级领导要加强协调工作,要把上下、左右、各方面、各环节有机结合起来,步调一致地推进少先队工作的开展。目前,有些部门,遇事推诿、互相扯皮,这种官僚主义的作风是十分要不得的!这种作风,轻则导致工作效率降低,重则影响党和政府的威信。我们要坚决铲除这种官僚主义作风。有关职能部门的同志,在开展深入基层工作中,要加强联系,搞好协调工作,务必把工作做好。
四、要在实践中探索少先队工作与市场经济有机结合的新路子。
少先队工作与市场经济有没有关系,我看是大有关系。市场经济是一场深刻的社会变革,它的影响将波及社会生活的每一个领域,少先队的工作也不例外,它必然会受市场经济的影响,因此,如何适应市场经济的要求,如何和市场经济有机结合起来,希望大家认真的思考一下,去探索一下,这是十分有意义的。
五、参与深入基层工作的同志,要有自豪感和责任感。
同志们,对于少先队的工作,政府是非常重视的;各级组织也投入大量的人力、物力、财力来推进这项工作的开展。同志们,你们承担的是中国的未来,是肩负了各级组织对你们的殷切希望的,希望你们要脚踏实地、同心同德、努力工作,在各自的岗位上为社会主义建设,为改革开放,添砖加瓦!
以上五点意见,供同志们参考。总之,希望大家要振奋精神,多干实事,少说空话,开拓进取,努力开创少先队工作的新局面。
我的讲话完了。最后祝同志们五一劳动节愉快,工作顺利。为中华之崛起而奋斗!
谢谢各位!
Thursday, February 24, 2011
Usage examples from the wild:
============================================================
Example 1
Summary: Compute the "spanning" or "physical" coverage of my paired-end
dataset on the reference genome. I will use hg18.
Contributor: Aaron Quinlan
Date: 06-July-2010
Tools used: samtools, bamToBed, genomeCoverageBed
============================================================
Workflow:
# 1. Sort the BAM files by read ID so that step 2 can correctly compute the "span" of the
# paired-end fragment.
samtools sort -n -m 50000000000 sample.sorted.dup.bam sample.namesorted.dup
# 2. Create BED from the spanning cooridnates and sort them by chrom for genomeCoverageBed.
# NOTE: Using -bedpe format from bamToBed so that I have the starts/ends for each mate.
# NOTE: Only computing coverage based upon "properly-paired" reads. (i.e., -f 0x2)
samtools view -uf 0x2 sample.namesorted.dup.bam | bamToBed -i stdin -bedpe | awk '{OFS="\t"; print $1,$2,$6,$7,$8}' | sort -k 1,1 > sample.namesorted.dup.bam.bed
# 3. Compute the ___spanning___ coverage histogram for the sample
# NOTE: We are creating a histogram where we lump all positions with depth > 60 into a single bin (-max 60)
genomeCoverageBed -i sample.namesorted.dup.bam.bed -g human.hg18.genome -max 60 > sample.spanning.cov
============================================================
Example 2
Summary: Convert a BAM into a bedgraph or a bigWig.
Contributor: Davide Cittaro
Date: 08-July-2010
Tools used: bamToBed, slopBed, genomeCoverageBed, samtools, wigToBigWig
============================================================
Workflow:
# 1. Remove duplicates from the BAM file. I'm using samtools, Picard may be also used. I'm assuming it's a single read file
samtools rmdup -s sample.bam sample.nodup.bam
# 2. Get chromosome sizes. You may get this from UCSC or from BAM headers
samtools view -H sample.nodup.bam | awk '/@SQ/ {OFS="\t"; gsub("SN:", "", $2); gsub("LN:", "", $3); print $2, $3}' > chromsizes.tab
# 3a. Convert the BAM file into a gzipped bedgraph
# NOTE: You should define the extension size (ssize) as the average library size minus the read length. There's no need to be precise here, if you have library at 200 bp and 36 bp reads, you can set ssize in a range between 160-180 bp
bamTobed -i sample.nodup.bam | slopBed -i stdin -g chromsizes.tab -s -l 0 -r ${ssize} | genomeCoverageBed -g chromsizes.tab -i stdin -bg | gzip -c - > sample.bdg.gz
# 3b. Convert the BAM file into a bigWig file
bamTobed -i sample.nodup.bam | slopBed -i stdin -g chromsizes.tab -s -l 0 -r ${ssize} | genomeCoverageBed -g chromsizes.tab -i stdin -bg | wigToBigWig stdin chromsizes.tab sample.bw
============================================================
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
============================================================
Example 4
Summary: Create two coverage tracks - one per strand
Contributor: Assaf Gordon
Date: 09-July-2010
Tools used: samtools, genomeCoverageBed, bedGraphToBigWig, awk
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 - for positive strand
genomeCoverageBed -bg -ibam sample.sorted.bam -g chromsizes.txt -strand + > sample.pos.bedgraph
# 4. Create BedGraph coverage file - for negative strand
# use AWK to negate the coverage values
genomeCoverageBed -bg -ibam sample.sorted.bam -g chromsizes.txt -strand - | awk -v OFS="\t" '{ $4 = - $4 ; print $0 }' > sample.neg.bedgraph
# 5. Create BigWig tracks from both bedgraph files
bedGraphToBigWig sample.pos.bedgraph chromsizes.txt sample.pos.bw
bedGraphToBigWig sample.pos.bedgraph chromsizes.txt sample.neg.bw
# 6. In the UCSC Genome Browser tracks, add both tracks, with different color values:
track name="Positive Strand" color=0,0,255 type=bigWig bigDataUrl=http://myserver.edu/SAMPLE.POS.BW
track name="Negative Strand" color=255,0,0 type=bigWig bigDataUrl=http://myserver.edu/SAMPLE.NEG.BW
============================================================
Example 5
Summary: Create two coverage tracks - for exons only
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 - calculating the coverage of exons only
genomeCoverageBed -bg -ibam sample.sorted.bam -g chromsizes.txt -split > sample.bedgraph
# 4. Create BigWig tracks from the bedgraph files
bedGraphToBigWig sample.bedgraph chromsizes.txt sample.bw
=============================================================
Example 6
Summary: Find all genomic regions where all samples have >=X coverage
Contributor: Aaron Quinlan
Date: 18-July-2010
Tools used: samtools, intersectBed, genomeCoverageBed, mergeBed, awk
=============================================================
Workflow:
##############################################################
# NOTE: The example below is for three samples in the interest
# of clarity/brevity. It could be extended to many more
# samples with a BASH or Perl/Python script.
##############################################################
# 1. Let's assume you have three human samples, 1, 2, and 3.
# Let's also assume that you have aligned the sequences for
# these samples and they are now in BAM format.
ls
1.bam 2.bam 3.bam
# 1a. These BAM files contain both concordant and discordant reads.
# Also, they contain alignments with _all_ mapping qualities.
# Let's cull the files to solely those alignments that are
# "properly-paired" (0x2) and have a mapping quality >=10.
samtools view -q 10 -f 0x2 -b 1.bam > 1.clean.bam
samtools view -q 10 -f 0x2 -b 2.bam > 2.clean.bam
samtools view -q 10 -f 0x2 -b 3.bam > 3.clean.bam
# 2. First create a BEDGRAPH of the coverage for each sample.
genomeCoverageBed -ibam 1.clean.bam -g human.hg19.genome -bga > 1.clean.bam.bedg
genomeCoverageBed -ibam 2.clean.bam -g human.hg19.genome -bga > 2.clean.bam.bedg
genomeCoverageBed -ibam 3.clean.bam -g human.hg19.genome -bga > 3.clean.bam.bedg
# 3. Now merge all intervals with sufficient depth (say >=6X).
# This will create a BED file.
awk '$4 >= 6' 1.clean.bam.bedg | mergeBed -i stdin > 1.clean.bam.gte6.bed
awk '$4 >= 6' 2.clean.bam.bedg | mergeBed -i stdin > 2.clean.bam.gte6.bed
awk '$4 >= 6' 3.clean.bam.bedg | mergeBed -i stdin > 3.clean.bam.gte6.bed
# 4. Intersect them all to get the set of intervals having depth >= 6 in _all_ 3.
intersectBed -a 1.clean.bam.gte6.bed -b 2.clean.bam.gte6.bed | \
intersectBed -a stdin -b 3.clean.bam.gte6.bed > all.clean.bam.gte6.bed
# 5. What is the total number of base pairs having >=6X in _all_ 3 samples?
awk '{sum += $3-$2} END{print sum}' all.clean.bam.gte6.bed
# 6. One could now filter variant calls against this BED file to restrict
# calls to regions that you believe to be of sufficient quality, etc.
============================================================
Example 1
Summary: Compute the "spanning" or "physical" coverage of my paired-end
dataset on the reference genome. I will use hg18.
Contributor: Aaron Quinlan
Date: 06-July-2010
Tools used: samtools, bamToBed, genomeCoverageBed
============================================================
Workflow:
# 1. Sort the BAM files by read ID so that step 2 can correctly compute the "span" of the
# paired-end fragment.
samtools sort -n -m 50000000000 sample.sorted.dup.bam sample.namesorted.dup
# 2. Create BED from the spanning cooridnates and sort them by chrom for genomeCoverageBed.
# NOTE: Using -bedpe format from bamToBed so that I have the starts/ends for each mate.
# NOTE: Only computing coverage based upon "properly-paired" reads. (i.e., -f 0x2)
samtools view -uf 0x2 sample.namesorted.dup.bam | bamToBed -i stdin -bedpe | awk '{OFS="\t"; print $1,$2,$6,$7,$8}' | sort -k 1,1 > sample.namesorted.dup.bam.bed
# 3. Compute the ___spanning___ coverage histogram for the sample
# NOTE: We are creating a histogram where we lump all positions with depth > 60 into a single bin (-max 60)
genomeCoverageBed -i sample.namesorted.dup.bam.bed -g human.hg18.genome -max 60 > sample.spanning.cov
============================================================
Example 2
Summary: Convert a BAM into a bedgraph or a bigWig.
Contributor: Davide Cittaro
Date: 08-July-2010
Tools used: bamToBed, slopBed, genomeCoverageBed, samtools, wigToBigWig
============================================================
Workflow:
# 1. Remove duplicates from the BAM file. I'm using samtools, Picard may be also used. I'm assuming it's a single read file
samtools rmdup -s sample.bam sample.nodup.bam
# 2. Get chromosome sizes. You may get this from UCSC or from BAM headers
samtools view -H sample.nodup.bam | awk '/@SQ/ {OFS="\t"; gsub("SN:", "", $2); gsub("LN:", "", $3); print $2, $3}' > chromsizes.tab
# 3a. Convert the BAM file into a gzipped bedgraph
# NOTE: You should define the extension size (ssize) as the average library size minus the read length. There's no need to be precise here, if you have library at 200 bp and 36 bp reads, you can set ssize in a range between 160-180 bp
bamTobed -i sample.nodup.bam | slopBed -i stdin -g chromsizes.tab -s -l 0 -r ${ssize} | genomeCoverageBed -g chromsizes.tab -i stdin -bg | gzip -c - > sample.bdg.gz
# 3b. Convert the BAM file into a bigWig file
bamTobed -i sample.nodup.bam | slopBed -i stdin -g chromsizes.tab -s -l 0 -r ${ssize} | genomeCoverageBed -g chromsizes.tab -i stdin -bg | wigToBigWig stdin chromsizes.tab sample.bw
============================================================
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
============================================================
Example 4
Summary: Create two coverage tracks - one per strand
Contributor: Assaf Gordon
Date: 09-July-2010
Tools used: samtools, genomeCoverageBed, bedGraphToBigWig, awk
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 - for positive strand
genomeCoverageBed -bg -ibam sample.sorted.bam -g chromsizes.txt -strand + > sample.pos.bedgraph
# 4. Create BedGraph coverage file - for negative strand
# use AWK to negate the coverage values
genomeCoverageBed -bg -ibam sample.sorted.bam -g chromsizes.txt -strand - | awk -v OFS="\t" '{ $4 = - $4 ; print $0 }' > sample.neg.bedgraph
# 5. Create BigWig tracks from both bedgraph files
bedGraphToBigWig sample.pos.bedgraph chromsizes.txt sample.pos.bw
bedGraphToBigWig sample.pos.bedgraph chromsizes.txt sample.neg.bw
# 6. In the UCSC Genome Browser tracks, add both tracks, with different color values:
track name="Positive Strand" color=0,0,255 type=bigWig bigDataUrl=http://myserver.edu/SAMPLE.POS.BW
track name="Negative Strand" color=255,0,0 type=bigWig bigDataUrl=http://myserver.edu/SAMPLE.NEG.BW
============================================================
Example 5
Summary: Create two coverage tracks - for exons only
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 - calculating the coverage of exons only
genomeCoverageBed -bg -ibam sample.sorted.bam -g chromsizes.txt -split > sample.bedgraph
# 4. Create BigWig tracks from the bedgraph files
bedGraphToBigWig sample.bedgraph chromsizes.txt sample.bw
=============================================================
Example 6
Summary: Find all genomic regions where all samples have >=X coverage
Contributor: Aaron Quinlan
Date: 18-July-2010
Tools used: samtools, intersectBed, genomeCoverageBed, mergeBed, awk
=============================================================
Workflow:
##############################################################
# NOTE: The example below is for three samples in the interest
# of clarity/brevity. It could be extended to many more
# samples with a BASH or Perl/Python script.
##############################################################
# 1. Let's assume you have three human samples, 1, 2, and 3.
# Let's also assume that you have aligned the sequences for
# these samples and they are now in BAM format.
ls
1.bam 2.bam 3.bam
# 1a. These BAM files contain both concordant and discordant reads.
# Also, they contain alignments with _all_ mapping qualities.
# Let's cull the files to solely those alignments that are
# "properly-paired" (0x2) and have a mapping quality >=10.
samtools view -q 10 -f 0x2 -b 1.bam > 1.clean.bam
samtools view -q 10 -f 0x2 -b 2.bam > 2.clean.bam
samtools view -q 10 -f 0x2 -b 3.bam > 3.clean.bam
# 2. First create a BEDGRAPH of the coverage for each sample.
genomeCoverageBed -ibam 1.clean.bam -g human.hg19.genome -bga > 1.clean.bam.bedg
genomeCoverageBed -ibam 2.clean.bam -g human.hg19.genome -bga > 2.clean.bam.bedg
genomeCoverageBed -ibam 3.clean.bam -g human.hg19.genome -bga > 3.clean.bam.bedg
# 3. Now merge all intervals with sufficient depth (say >=6X).
# This will create a BED file.
awk '$4 >= 6' 1.clean.bam.bedg | mergeBed -i stdin > 1.clean.bam.gte6.bed
awk '$4 >= 6' 2.clean.bam.bedg | mergeBed -i stdin > 2.clean.bam.gte6.bed
awk '$4 >= 6' 3.clean.bam.bedg | mergeBed -i stdin > 3.clean.bam.gte6.bed
# 4. Intersect them all to get the set of intervals having depth >= 6 in _all_ 3.
intersectBed -a 1.clean.bam.gte6.bed -b 2.clean.bam.gte6.bed | \
intersectBed -a stdin -b 3.clean.bam.gte6.bed > all.clean.bam.gte6.bed
# 5. What is the total number of base pairs having >=6X in _all_ 3 samples?
awk '{sum += $3-$2} END{print sum}' all.clean.bam.gte6.bed
# 6. One could now filter variant calls against this BED file to restrict
# calls to regions that you believe to be of sufficient quality, etc.
Sunday, December 26, 2010
Subscribe to:
Posts (Atom)