Thanks. But I don't work in human. I've a gtf and bed file with all my exon position.
Hi,
How can I define the genomic context (so what are the genes in the neighbourhood) based on position ( like a bed file ).
The informations I want to know is :
- Is the position in an intron of a gene ? If yes, which intron (and the distance from the exons)
- If the position is intergenic : which gene are upstream and downstream (and distances)
- If there are several genes that are overlapping the position, report them and where it is (which intro or exon)
Edit > I add a little picture to explain the expected results :

So the expected results for position 1 ( I omit the position and gene real coordinates but they have to be in the results also )
Position1 Gene_A exon1 50 intronPosition
Position1 Gene_B exon2 -100 intronPosition
For position2
Position2 Gene_A exon3 200 intergenicPosition
Position2 Gene_C exon1 -100 intergenicPosition
I konw that bedops closes-feature is a good start but I'm stuck with the overlapping genes and to check if the position is intergenic or not ?
Anyone can give me ideas and/or advices to solve this problem
Thanks a lot,
N.
2 answers
I quickly wrote something: see https://github.com/lindenb/jvarkit#biostar81455 .it finds a record in UCSC knownGenes, get all the overlaping transcripts and output the nearest exons.
$ ant biostar81455 && echo -e "chr22\t41258261\nchr22\t52000000\nchr22\t0" | java -jar dist/biostar81455.jar
chr22 41258261 uc003azg.2 41253084 41258785 POSITIVE Exon 2 41257621 41258785 0
chr22 41258261 uc011aox.2 41253084 41305239 POSITIVE Exon 1 41253084 41253249 -5012
chr22 41258261 uc003azi.3 41253084 41328823 POSITIVE Exon 1 41253084 41253249 -5012
chr22 41258261 uc003azj.3 41255553 41258130 NEGATIVE Exon 1 41255553 41258130 -131
chr22 41258261 uc010gyh.1 41258260 41282519 POSITIVE Exon 1 41258260 41258683 0
chr22 41258261 uc011aoy.1 41258260 41363888 POSITIVE Exon 1 41258260 41258683 0
chr22 52000000 uc011asd.2 51195513 51227614 POSITIVE Exon 4 51227177 51227614 -772386
chr22 52000000 uc003bni.3 51195513 51238065 POSITIVE Exon 4 51237082 51238065 -761935
chr22 52000000 uc011ase.1 51205919 51220775 NEGATIVE Exon 1 51220615 51220775 -779225
chr22 52000000 uc003bnl.1 51205919 51222087 NEGATIVE Exon 1 51221928 51222087 -777913
chr22 52000000 uc003bns.3 51222156 51238065 POSITIVE Exon 3 51237082 51238065 -761935
chr22 52000000 uc003bnq.1 51222224 51227600 POSITIVE Exon 4 51227322 51227600 -772400
chr22 52000000 uc003bnr.1 51222224 51227781 POSITIVE Exon 4 51227319 51227781 -772219
chr22 52000000 uc010hbj.3 51222224 51238065 POSITIVE Exon 3 51237082 51238065 -761935
chr22 0 uc002zks.4 16150259 16193004 NEGATIVE Exon 8 16150259 16151821 16150259
chr22 0 uc002zkt.3 16162065 16172265 POSITIVE Exon 1 16162065 16162388 16162065
chr22 0 uc002zku.3 16179617 16181004 NEGATIVE Exon 1 16179617 16181004 16179617
chr22 0 uc002zkv.3 16187164 16193004 NEGATIVE Exon 5 16187164 16187302 16187164
You can use Annotation software like snpEff and Annovar and annotate your genomic positions.
Log in to answer this question.
have a look at Is a genome position in an exon or intron?