This is a test version of Biostars. For the public version, visit https://www.biostars.org.
ucsc RSid to gene name

Hi all,

Where can I find a table containing rsid to gene name transformation, preferably at the ucsc database?

gene ucsc rsid

so you are saying that position by kb is the only way to find out what gene a snp belongs to ?, there is no special table for this ?

1 answer

Another way to get access to UCSC datasets and do genomic set operations is via the command line, using mysql, wget and BEDOPS tools like gtf2bed and bedmap.

Get all SNP rs* IDs via the command line:

$ mysql --user=genome --host=genome-mysql.cse.ucsc.edu -A -N -e 'SELECT chrom, chromStart, chromEnd, name FROM snp142Common;' hg19 > snp142Common.bed

Get genes and convert to BED:

$ wget -O - ftp://ftp.sanger.ac.uk/pub/gencode/Gencode_human/release_19/gencode.v19.annotation.gtf.gz \
    | gunzip -c \
    | grep -w "gene" \
    | gtf2bed \
    > gencode.v19.genes.bed

Map gene names (in the gene ID field) to SNPs, using bedmap to look for SNPs whose positions overlap those of Gencode genes:

$ bedmap --echo --echo-map-id-uniq snp142Common.bed gencode.v19.genes.bed > snpsWithMappedGeneIds.bed

If you want, you can expand the window around a SNP by some number of bases to allow a looser search ("nearby" genes) by adding the --range option to bedmap.

For example, for a 1 kb window centered on each SNP, add --range 500:

$ bedmap --echo --echo-map-id-uniq --range 500 snp142Common.bed gencode.v19.genes.bed > snp1kbWindowsWithGeneIds.bed

Log in to answer this question.