This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Map genomic coordinate to specific chromosome region

Hi there,

I wonder is there any R package can map a genomic coordinate to specific chromosome region?

For example, I have a genomic coordinate of chr4:19077912-75295480, is there any tool (R package would be perfect) that I can use to map this coordinate to 4p22.3 (I wrote it blindly) something like that.

Many thanks in advance.

coordinate r chromosome genomic region package

Thank you this is exactly what I want. However do you know is there any R package can do such convertion because it will be easy for me to concatenate other codes!

1 answer

You can do this via the command line very easily, using the cytoband file published by UCSC on their Goldenpath service:

$ wget -qO- ftp://hgdownload.soe.ucsc.edu//apache/htdocs/goldenPath/hg38/database/cytoBand.txt.gz \
    | gunzip -c \
    | sort-bed - \
    | bedmap --echo --echo-map-id --delim '\t' <( sort-bed myCoordinates.bed ) - \
    > answer.bed

If you just want to do an ad-hoc search, replace myCoordinates.bed with a process substitution containing your region:

$ wget -qO- ftp://hgdownload.soe.ucsc.edu//apache/htdocs/goldenPath/hg38/database/cytoBand.txt.gz \
    | gunzip -c \
    | sort-bed - \
    | bedmap --echo --echo-map-id --delim '\t' <( echo -e 'chr4\t19077912\t75295480' ) - \
    > answer.bed

In the latter case, there are multiple bands overlapping that region:

$ more answer.bed 
chr4    19077912        75295480     p15.31;p15.2;p15.1;p14;p13;p12;p11;q11;q12;q13.1;q13.2;q13.3

The above cytoband file is for hg38. If you're working with a different genome assembly, you just have to dig around the similar path structure for that assembly on Goldenpath. UCSC hosts cytoband files for many organisms and assemblies, so this is a good way to find things.

Log in to answer this question.