Version 1 (modified by 12 years ago) ( diff ) | ,
---|
- The detailed format descriptions can be found at http://genome.ucsc.edu/goldenPath/help/customTrack.html
- How to choose data format? Check http://genomewiki.ucsc.edu/index.php/Selecting_a_graphing_track_data_format
- samtools reference: http://samtools.sourceforge.net/
- samtools and bedtools have been installed on tak
- Other scripts can be found in the BaRC_Public/BaRC_code folder (/nfs/BaRC_Public/BaRC_code)
Convert text file to wig
Sample command: txt2wig.pl foo.txt trackName(one word) > foo.wig
Convert bed to wig
Sample command: bed2wig.pl inputBed sampleName(one word) probeWidth > outputWig Note: It assumes that the probe width in all records is constant. If probe width is not constant, you can use bedGraph format. To convert bed to bedGraph format, just change the track name to bedGraph, and minus chromosome end position in bed format by 1.
Convert wig to bed
Sample command with variableStep wig format: wig2bed.pl inputWig sampleName(one word) > outputBed Sample command with fixedStep wig format: wig2bed_fixedStep.pl inputWig > outputBed
Convert wig to bigwig
Sample commands: Get chromosome lengths fetchChromSizes hg18 > chrSize.txt Convert wig to big wig: wigToBigWig foo.wig chrSize.txt foo.bw
Convert bed to bigbed
Sample commands: Get chromosome lengths fetchChromSizes hg18 > chrSize.txt Convert bed to big bed: bedToBigBed foo.bed chrSize.txt foo.bb
Convert BAM to bedGraph for UCSC genome browser
To view BAM files on UCSC browser, both foo.sorted.bam and foo.sorted.bam.bai have to be on a http or ftp server. One way to get around this is to convert BAM files into bedGraph files, which should be small enough that they can be simply uploaded. genomeCoverageBed -split -bg -ibam sorted.bam -g hg19.genome where hg19.genome file is tab delimited and structured as follows: <chromName><TAB><chromSize> chr1 249250621 One can use the UCSC Genome Browser's MySQL database to extract chromosome sizes. For example, H. sapiens: mysql --user=genome --host=genome-mysql.cse.ucsc.edu -A -e "select chrom, size from hg19.chromInfo" > hg19.genome
convert bam to bigwig
Step1: convert bam to bedGraph format: genomeCoverageBed -split -bg -ibam accepted_hits.bam -g /nfs/genomes/mouse_gp_jul_07/anno/mm9.size > accepted_hits.bedGraph Step2: convert bedGraph to bigwig format: bedGraphToBigWig accepted_hits.bedGraph /nfs/genomes/mouse_gp_jul_07/anno/mm9.size accepted_hits.bw where mm9.size file is tab delimited and structured as follows: <chromName><TAB><chromSize>
Updating/fixing UCSC GTF file
- GTF files from UCSC Table Browser use RefSeq (NM* ids) for both gene_id and transcript_id which may not be compatible for some programs (eg. counting by genes using HTSeq)
- Some Refseq gtf files (such as for the hg19, hg18, mm9, and dm3 assemblies) are in /nfs/genomes/, under gtf/ in each species folder. If you would like to create additional files, here are the steps:
Step 1: Use UCSC Table Browser to download RefSeq id and gene symbol. Use "Genes and Gene Prediction Tracks" for group, "RefSeq Genes" for track and "refGene" for table. Choose "selected fields from primary and related tables" for output format and click "get output". In the next page select "name" and "name2" for the fields. output format should be : NM_017940 NBPF1 Step 2: Download a gtf file from the UCSC Table Browser This uses refseq ID as gene_id and transcript_id, so we need to replace it with the gene symbol. sample command: /nfs/BaRC_Public/BaRC_code/Perl/fix_gtf_refSeq_ensembl.pl hg19.refgene.gtf refseq2symbol > hg19.refgene.gtf Step 3: About 50-70 genes in the gtf file from UCSC are incorrect; they include exons with a start coordinate that is larger than the end coordinate. Software such as cufflinks fails to deal with this situation and ignores these exons. Since this only affects the last 1-3 bases of a transcript, a temporary solution is to remove these records. sample command: awk -F"\t" '{ if($4<=$5) print $0 }' hg19.refgene.gtf > hg19.refgene_new.gtf
- Ensembl gtf files can be downloaded from ftp://ftp.ensembl.org/pub/current_gtf/
Convert bed to gff
- Note that bed and gff use slightly different coordinate conventions
- Use /nfs/BaRC_Public/BaRC_code/Perl/bed2gff/bed2gff.pl
USAGE: bed2gff.pl bedFile > gffFile Ex: bed2gff.pl foo.bed WIBR exon > foo.gff
Convert gtf to bed
- convert gtf to genePhred
gtfToGenePred my.gtf my.genePhred
- convert genePhred to bed:
awk -f genePhredToBed my.genePhred > my.bed
genePhredToBed is a awk script by Katrina Learned, downloaded from UCSC Genome Browser discussion list
#!/usr/bin/awk -f # # Convert genePred file to a bed file (on stdout) # BEGIN { FS="\t"; OFS="\t"; } { name=$1 chrom=$2 strand=$3 start=$4 end=$5 cdsStart=$6 cdsEnd=$7 blkCnt=$8 delete starts split($9, starts, ","); delete ends split($10, ends, ","); blkStarts="" blkSizes="" for (i = 1; i <= blkCnt; i++) { blkSizes = blkSizes (ends[i]-starts[i]) ","; blkStarts = blkStarts (starts[i]-start) ","; } print chrom, start, end, name, 1000, strand, cdsStart, cdsEnd, 0, blkCnt, blkSizes, blkStarts }
Convert blat to gff
- Use /nfs/BaRC_Public/BaRC_code/Perl/blat2gff/blat2gff.pl
Convert BLAT output file (PSL format) into GFF format (v1.1 14 Dec 2010) blat2gff.pl blatFile dataSource(ex:WIBR) > gffFile }}
Note:
See TracWiki
for help on using the wiki.