Question: How To Get Bed File Containing Exons Of Canonical Transcripts And Their Corresponding Gene Symbols
13
gravatar for pristanna
3.8 years ago by
pristanna420
Czech Republic
pristanna420 wrote:

Hi everyone,

I need a bed file containing starts and ends of the exons, gene name and number of the exon - but just for the canonical transcript - because I don't want to have the regions repeated.

I tried UCSC Table browser and BioMart but non of them gives me exactly what I need.

Using UCSC I can get canonical transcripts (but at the same time I couldn't get starts and ends of the exon altogether with the gene name).

Using BioMart I can get starts and ends of the exons altogether with the gene name, but I can't find how to choose the canonical transcripts and that's why the regions are repeated as seen below in the case of NUS1P3:

Chromosome Name    Exon Chr Start (bp)    Exon Chr End (bp)    Associated Gene Name    Exon Rank in Transcript
1    955551  955753  AGRN    1
1    957579  957842  AGRN    2
1    970629  970730  AGRN    3
13     24902349    24903210    NUS1P3    1
13     24902376    24902559    NUS1P3    1
13  24902577    24902961    NUS1P3    2
13     24903006    24903210    NUS1P3    3

Thank you in advance for any suggestions!

bed biomart transcript ucsc • 16k views
ADD COMMENTlink modified 3.8 years ago • written 3.8 years ago by pristanna420
25
gravatar for pristanna
3.8 years ago by
pristanna420
Czech Republic
pristanna420 wrote:

Download a bed file for the canonical transcripts using UCSC Table Browser:

  • track: UCSC Genes
  • table: knownCanonical
  • output format: select fields from primary and related tables
  • press get output
  • select fields from hg19.knownCanonical: chrom, chromStart, chromEnd,
  • transcript select fields from hg19.kgXref: geneSymbol
  • press get output

The file UCSC_canonical.bed looks like that:

#hg19.knownCanonical.chrom      hg19.knownCanonical.chromStart  hg19.knownCanonical.chromEnd    hg19.knownCanonical.transcript  hg19.kgXref.geneSymbol
chr1    11873   14409   uc010nxq.1      DDX11L1
chr1    14361   19759   uc009viu.3      WASH7P
chr1    14406   29370   uc009viw.2      WASH7P
chr1    34610   36081   uc001aak.3      FAM138F
chr1    69090   70008   uc001aal.1      OR4F5
chr1    134772  140566  uc021oeg.2      LOC729737
chr1    321083  321115  uc001aaq.2      DQ597235
chr1    321145  321207  uc001aar.2      DQ599768
chr1    322036  326938  uc009vjk.2      LOC100133331

Download a bed file for all UCSC exons using UCSC Table Browser:

  • track: UCSC Genes
  • table: knownGene
  • output format: BED - browser extensible data
  • press get output
  • select option Exons
  • press get BED

The file UCSC_exons.bed looks like that:

chr1    11873   12227   uc001aaa.3_exon_0_0_chr1_11874_f        0       +
chr1    12612   12721   uc001aaa.3_exon_1_0_chr1_12613_f        0       +
chr1    13220   14409   uc001aaa.3_exon_2_0_chr1_13221_f        0       +
chr1    11873   12227   uc010nxr.1_exon_0_0_chr1_11874_f        0       +
chr1    12645   12697   uc010nxr.1_exon_1_0_chr1_12646_f        0       +
chr1    13220   14409   uc010nxr.1_exon_2_0_chr1_13221_f        0       +
chr1    11873   12227   uc010nxq.1_exon_0_0_chr1_11874_f        0       +
chr1    12594   12721   uc010nxq.1_exon_1_0_chr1_12595_f        0       +
chr1    13402   14409   uc010nxq.1_exon_2_0_chr1_13403_f        0       +
chr1    14361   14829   uc009vis.3_exon_0_0_chr1_14362_r        0       -

Modify the file to separate the transcript name of the rest of information:

awk '{split ($4,a,"_"); {print $1"\t"$2"\t"$3"\t"a[1]"\t"a[3]"\t"$6}}' UCSC_exons.bed > UCSC_exons_modif.bed

The file UCSC_exons_modif.bed:

chr1    11873   12227   uc001aaa.3      0       +
chr1    12612   12721   uc001aaa.3      1       +
chr1    13220   14409   uc001aaa.3      2       +
chr1    11873   12227   uc010nxr.1      0       +
chr1    12645   12697   uc010nxr.1      1       +
chr1    13220   14409   uc010nxr.1      2       +
chr1    11873   12227   uc010nxq.1      0       +
chr1    12594   12721   uc010nxq.1      1       +
chr1    13402   14409   uc010nxq.1      2       +
chr1    14361   14829   uc009vis.3      0       -

Join the sorted files based on the transcript identificator:

join -1 4 -2 4 <(sort -k4 UCSC_exons_modif.bed ) <(sort -k4 UCSC_canonical.bed) | awk '{print $2"\t"$3"\t"$4"\t"$10"\t"$5"\t"$6}' | bedtools sort -i "-" > UCSC_exons_modif_canonical.bed

The final file contains exons of the canonical transcripts:

chr1    11873   12227   DDX11L1 0       +
chr1    12594   12721   DDX11L1 1       +
chr1    13402   14409   DDX11L1 2       +
chr1    14361   14829   WASH7P  0       -
chr1    14406   16765   WASH7P  0       -
chr1    14969   15038   WASH7P  1       -
chr1    15795   15947   WASH7P  2       -
chr1    16606   16765   WASH7P  3       -
chr1    16857   17055   WASH7P  4       -
chr1    16857   17055   WASH7P  1       -
ADD COMMENTlink written 3.8 years ago by pristanna420
1

At this step: transcript select fields from hg19.kgXref: geneSymbol, one need to check kgID in that hg19.kgXref table to produce the expected UCSC_canonical.bed.

Another important thing: exon numeration is always forward! So if the gene is in reverse complement strand than Exon 0 there is the last exon.

ADD REPLYlink modified 14 months ago • written 14 months ago by biocyberman640

Pulling this thread again since I got this error:

header$ join -1 4 -2 4 <(sort -k4 UCSC_exons_modif.bed ) <(sort -k4 UCSC_canonical.bed) | awk '{print $2"\t"$3"\t"$4"\t"$10"\t"$5"\t"$6}' | bedtools sort -i "-" > UCSC_exons_modif_canonical.bed

join: /dev/fd/62:7064: is not sorted: chrX    155255322    155257848    DDX11L family member

ADD REPLYlink written 22 months ago by MAPK1.1k

Did you solve this issue?

ADD REPLYlink written 21 months ago by francesco.tabaro0

I had the same problem. Just download again both bed from UCSC. Probably you need to wait and confirm the download.

ADD REPLYlink written 6 months ago by dsmarcoantonio10
2
gravatar for Alex Reynolds
3.8 years ago by
Alex Reynolds21k
Seattle, WA USA
Alex Reynolds21k wrote:

Perhaps apply a BEDOPS bedmap map operation, mapping BioMart-sourced exons to UCSC-sourced canonical transcripts. You could do something like:

$ bedmap --echo --echo-map-id-uniq ucsc_canonical.sorted.bed biomart_exons.sorted.bed > answer.bed

The --echo operator prints each canonical element. The --echo-map-id-uniq operator prints the unique ID name(s) for exons whose genomic ranges span across the canonical element's genomic range.

If you want all the exon information, ranges and all, use --echo-map in place of --echo-map-id-uniq.

The default overlap criteria is one or more bases between map (exon) and reference (canonical) element — you can adjust this stringency up to complete overlap.

It looks like you'd need to pre-process the BioMart data into UCSC BED format (renaming chromosomes, at least). Prepending the chromosome index with the string chr can be done with a simple awk statement:

$ awk '{print "chr"$0}' biomart_stuff.bed > biomart_stuff_with_UCSC_chromosome_names.bed

If necessary, also sort the BED data:

$ sort-bed ucsc_canonical.bed > ucsc_canonical.sorted.bed
$ sort-bed biomart_exons.bed > biomart_exons.sorted.bed

Do this once, if your data are of uncertain sort order. This lets you take advantage of BEDOPS speed and memory enhancements. You only need to sort input sets once.

ADD COMMENTlink modified 2.8 years ago • written 3.8 years ago by Alex Reynolds21k

Thanks a lot Alex for the idea, I am not familiar with BEDOPS, but I will try, it looks interesting!

ADD REPLYlink written 3.8 years ago by pristanna420

Let us know if you have any questions!

ADD REPLYlink written 3.8 years ago by Alex Reynolds21k

Finally I solved it using different approach, but for another task I need some tool which can work with the overlap criteria, so I am going to try the BEDOPS now! Thanks a lot!

ADD REPLYlink written 3.8 years ago by pristanna420
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: 946 users visited in the last hour