Skip to content

Instantly share code, notes, and snippets.

@ATpoint
Created February 26, 2020 18:53
Show Gist options
  • Save ATpoint/ce87c32737bd2fffa6932ca9af8ddd70 to your computer and use it in GitHub Desktop.
Save ATpoint/ce87c32737bd2fffa6932ca9af8ddd70 to your computer and use it in GitHub Desktop.
library(biomaRt)
## How to get gene coordinates starting from Entrez gene IDs:
## Example for human:
GeneName <- "hgnc_symbol" ## for mouse use "mgi_symbol"
DataSet <- "hsapiens_gene_ensembl" ## for mouse use "mmusculus_gene_ensembl
## Create a look-up table using biomaRt:
Coords <- mmusculus_genes <- getBM(attributes = c("entrezgene_id",
"ensembl_gene_id",
GeneName,
"chromosome_name",
"start_position",
"end_position"),
mart = useMart("ensembl", dataset = DataSet))
## merge with your genes:
example_genes <- c("6688", "2623", "1050")
## get the output table:
output.df <- merge(x = data.frame(EntrezID = example_genes),
y = Coords,
by.x = "EntrezID", by.y = "entrezgene_id")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment