This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Bedgraph file annotation

Hi,

I have a bedgraph which contain chromosome start and end site.

How can I get the annotation for the chromosome location,such as gene name?

Thanks

annotation

1 answer

First, you might download a set of genes, using gtf2bed to make a BED file, e.g. for human:

$ wget -qO- ftp://ftp.sanger.ac.uk/pub/gencode/Gencode_human/release_21/gencode.v21.annotation.gtf.gz \
    | gunzip -c - \
    | gtf2bed - \
    | grep -w gene - \
    > gencode.v21.genes.bed

Basically, you want a set of genomic ranges that have gene names associated with them, and you want them in BED format. The above is just one way to do this.

Second, use bedmap to map the elements in elements.bedgraph to the gene names in gencode.v21.genes.bed, e.g.:

$ bedmap --echo --echo-map-id-uniq --delim '\t' elements.bedgraph gencode.v21.genes.bed > answer.bed

The file answer.bed will have your bedgraph ranges, along with a list of gene names for genes that overlap the bedgraph ranges by one or more bases. If you want more than just the gene ID or name, then take a look at bedmap's --echo-map-* options.

Log in to answer this question.