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.
see Programmatically convert cytoband location to genomic coordinates
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!
Perhaps this: https://cran.r-project.org/web/packages/RCytoGPS/RCytoGPS.pdf