├── .Rbuildignore ├── .gitignore ├── NAMESPACE ├── R ├── set_key.R ├── get_title.R ├── get_gene.R ├── get_pheno_key.R ├── get_inheritance.R ├── gene_to_omim.R ├── phenotypic_series.R ├── search_phenotype.R └── get_omim.R ├── romim.Rproj ├── man ├── set_key.Rd ├── get_title.Rd ├── gene_to_omim.Rd ├── get_gene.Rd ├── get_pheno_key.Rd ├── phenotypic_series.Rd ├── search_phenotype.Rd ├── get_inheritance.Rd └── get_omim.Rd ├── DESCRIPTION ├── LICENSE └── README.md /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^.*\.Rproj$ 2 | ^\.Rproj\.user$ 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export(gene_to_omim) 4 | export(get_gene) 5 | export(get_inheritance) 6 | export(get_omim) 7 | export(get_pheno_key) 8 | export(get_title) 9 | export(phenotypic_series) 10 | export(search_phenotype) 11 | export(set_key) 12 | -------------------------------------------------------------------------------- /R/set_key.R: -------------------------------------------------------------------------------- 1 | #' Set API key 2 | #' 3 | #' This function sets the API key 4 | #' 5 | #' @param key Your API key 6 | #' @keywords key 7 | #' @export 8 | #' @examples 9 | #' set_key('aAS5ASdf35jasdnadsfj') # not a real key 10 | 11 | set_key <- function(key){ 12 | my_key <<- paste('apiKey=', key, sep='') 13 | } 14 | 15 | -------------------------------------------------------------------------------- /romim.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: No 4 | SaveWorkspace: No 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | Encoding: UTF-8 9 | 10 | AutoAppendNewline: Yes 11 | StripTrailingWhitespace: Yes 12 | 13 | BuildType: Package 14 | PackageUseDevtools: Yes 15 | PackageInstallArgs: --no-multiarch --with-keep.source 16 | PackageRoxygenize: rd,collate,namespace 17 | -------------------------------------------------------------------------------- /man/set_key.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/set_key.R 3 | \name{set_key} 4 | \alias{set_key} 5 | \title{Set API key} 6 | \usage{ 7 | set_key(key) 8 | } 9 | \arguments{ 10 | \item{key}{Your API key} 11 | } 12 | \description{ 13 | This function sets the API key 14 | } 15 | \examples{ 16 | set_key('aAS5ASdf35jasdnadsfj') # not a real key 17 | } 18 | \keyword{key} 19 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: romim 2 | Title: R wrapper functions for the OMIM API 3 | Version: 1.0.1 4 | Authors@R: person("Dave", "Tang", email = "me@davetang.org", role = c("aut", "cre")) 5 | Description: The package contains wrapper functions that make it easier to use 6 | the OMIM API. 7 | Depends: 8 | R (>= 4.0.0), 9 | XML (>= 3.98), 10 | magrittr (>= 2.0.1), 11 | xml2 (>= 1.3.2) 12 | Imports: 13 | XML, 14 | magrittr, 15 | xml2 16 | License: GNU General Public License 17 | Encoding: UTF-8 18 | LazyData: true 19 | RoxygenNote: 7.1.1 20 | -------------------------------------------------------------------------------- /man/get_title.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/get_title.R 3 | \name{get_title} 4 | \alias{get_title} 5 | \title{Get title from an OMIM ID} 6 | \usage{ 7 | get_title(my_xml) 8 | } 9 | \arguments{ 10 | \item{xml}{XML result from get_omim()} 11 | } 12 | \description{ 13 | Returns the preferred title of an OMIM entry. 14 | The function assumes that the preferred title is in the XML node /omim/entryList/entry/titles/preferredTitle. 15 | } 16 | \examples{ 17 | get_title(get_omim(100200)) 18 | } 19 | \keyword{title} 20 | -------------------------------------------------------------------------------- /R/get_title.R: -------------------------------------------------------------------------------- 1 | #' Get title from an OMIM ID 2 | #' 3 | #' Returns the preferred title of an OMIM entry. 4 | #' The function assumes that the preferred title is in the XML node /omim/entryList/entry/titles/preferredTitle. 5 | #' 6 | #' @param xml XML result from get_omim() 7 | #' @keywords title 8 | #' @export 9 | #' @examples 10 | #' get_title(get_omim(100200)) 11 | 12 | get_title <- function(my_xml){ 13 | my_preferred_title_node <- getNodeSet(my_xml, path = "/omim/entryList/entry/titles/preferredTitle") 14 | xmlSApply(my_preferred_title_node, xmlValue) 15 | } 16 | 17 | -------------------------------------------------------------------------------- /man/gene_to_omim.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/gene_to_omim.R 3 | \name{gene_to_omim} 4 | \alias{gene_to_omim} 5 | \title{Gene search} 6 | \usage{ 7 | gene_to_omim(gene_symbol = "FGFR2", show_query = FALSE) 8 | } 9 | \arguments{ 10 | \item{gene_symbol}{Gene Symbol. Default is FGFR2.} 11 | 12 | \item{show_query}{Show API query. Default is FALSE.} 13 | } 14 | \description{ 15 | This function builds the URL to search the OMIM server based on an input gene 16 | } 17 | \examples{ 18 | gene_to_omim(TTN) 19 | } 20 | \keyword{Gene} 21 | \keyword{Symbol} 22 | -------------------------------------------------------------------------------- /man/get_gene.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/get_gene.R 3 | \name{get_gene} 4 | \alias{get_gene} 5 | \title{Get gene/s from an OMIM ID} 6 | \usage{ 7 | get_gene(my_xml) 8 | } 9 | \arguments{ 10 | \item{xml}{XML result from get_omim()} 11 | } 12 | \description{ 13 | Returns the gene/s associated with an OMIM entry. Entries such as 109400 are associated with more than one gene. 14 | The function assumes that the gene symbol is stored in the XML node /omim/entryList/entry/phenotypeMapList/phenotypeMap/geneSymbols. 15 | } 16 | \examples{ 17 | get_gene(get_omim(303600, geneMap=TRUE)) 18 | } 19 | \keyword{gene} 20 | -------------------------------------------------------------------------------- /R/get_gene.R: -------------------------------------------------------------------------------- 1 | #' Get gene/s from an OMIM ID 2 | #' 3 | #' Returns the gene/s associated with an OMIM entry. Entries such as 109400 are associated with more than one gene. 4 | #' The function assumes that the gene symbol is stored in the XML node /omim/entryList/entry/phenotypeMapList/phenotypeMap/geneSymbols. 5 | #' 6 | #' @param xml XML result from get_omim() 7 | #' @keywords gene 8 | #' @export 9 | #' @examples 10 | #' get_gene(get_omim(303600, geneMap=TRUE)) 11 | 12 | get_gene <- function(my_xml){ 13 | my_gene_node <- getNodeSet(my_xml, path = "/omim/entryList/entry/phenotypeMapList/phenotypeMap/geneSymbols") 14 | xmlSApply(my_gene_node, xmlValue) 15 | } 16 | 17 | -------------------------------------------------------------------------------- /R/get_pheno_key.R: -------------------------------------------------------------------------------- 1 | #' Get phenotype mapping key for gene/s associated with an OMIM entry 2 | #' 3 | #' Returns the phenotype mapping key of gene/s associated with an OMIM entry. 4 | #' Assumes that the phenotype mapping key is stored in the XML node /omim/entryList/entry/phenotypeMapList/phenotypeMap/phenotypeMappingKey. 5 | #' 6 | #' @param xml XML result from get_omim() 7 | #' @keywords phenotype mapping key 8 | #' @export 9 | #' @examples 10 | #' get_pheno_key(get_omim(303600, geneMap=TRUE)) 11 | 12 | get_pheno_key <- function(my_xml){ 13 | my_pheno_node <- getNodeSet(my_xml, path = "/omim/entryList/entry/phenotypeMapList/phenotypeMap/phenotypeMappingKey") 14 | xmlSApply(my_pheno_node, xmlValue) 15 | } 16 | 17 | -------------------------------------------------------------------------------- /man/get_pheno_key.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/get_pheno_key.R 3 | \name{get_pheno_key} 4 | \alias{get_pheno_key} 5 | \title{Get phenotype mapping key for gene/s associated with an OMIM entry} 6 | \usage{ 7 | get_pheno_key(my_xml) 8 | } 9 | \arguments{ 10 | \item{xml}{XML result from get_omim()} 11 | } 12 | \description{ 13 | Returns the phenotype mapping key of gene/s associated with an OMIM entry. 14 | Assumes that the phenotype mapping key is stored in the XML node /omim/entryList/entry/phenotypeMapList/phenotypeMap/phenotypeMappingKey. 15 | } 16 | \examples{ 17 | get_pheno_key(get_omim(303600, geneMap=TRUE)) 18 | } 19 | \keyword{key} 20 | \keyword{mapping} 21 | \keyword{phenotype} 22 | -------------------------------------------------------------------------------- /man/phenotypic_series.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/phenotypic_series.R 3 | \name{phenotypic_series} 4 | \alias{phenotypic_series} 5 | \title{OMIM Phenotypic Series} 6 | \usage{ 7 | phenotypic_series(series = "PS163950", show_query = FALSE) 8 | } 9 | \arguments{ 10 | \item{series}{Phenotypic Series Number. Default is PS163950.} 11 | 12 | \item{show_query}{Show API query. Default is FALSE.} 13 | } 14 | \description{ 15 | This function returns OMIM IDs given a OMIM Phenotypic Series ID. 16 | Recursive apply (rapply) and grep is used because phenotypeMimNumber is not always present in the same XML structure. 17 | } 18 | \examples{ 19 | phenotypic_series(series = 'PS308350') 20 | } 21 | \keyword{Number} 22 | \keyword{Phenotypic} 23 | \keyword{Series} 24 | -------------------------------------------------------------------------------- /man/search_phenotype.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/search_phenotype.R 3 | \name{search_phenotype} 4 | \alias{search_phenotype} 5 | \title{Search OMIM} 6 | \usage{ 7 | search_phenotype(search_term = "noonan syndrome", show_query = FALSE) 8 | } 9 | \arguments{ 10 | \item{show_query}{Show API query. Default is FALSE.} 11 | 12 | \item{series}{Search term. Default is "noonan syndrome".} 13 | } 14 | \description{ 15 | This function returns OMIM phenotypes given a match of a search term in the text meta field of OMIM phenotype entries. 16 | Recursive apply (rapply) and grep is used because phenotypeMimNumber is not always present in the same XML structure. 17 | } 18 | \examples{ 19 | search_phenotype(search_term = 'noonan syndrome') 20 | } 21 | \keyword{OMIM} 22 | \keyword{Search} 23 | -------------------------------------------------------------------------------- /man/get_inheritance.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/get_inheritance.R 3 | \name{get_inheritance} 4 | \alias{get_inheritance} 5 | \title{Get inheritance model of genes associated with OMIM ID} 6 | \usage{ 7 | get_inheritance(my_xml) 8 | } 9 | \arguments{ 10 | \item{xml}{XML result from get_omim()} 11 | } 12 | \description{ 13 | Returns the inheritance model of a gene/s associated with the OMIM entry. 14 | An OMIM entry may be associated to more than one gene and therefore will have more than one inheritance model. 15 | The function assumes that the inheritance model is stored in the XML node /omim/entryList/entry/phenotypeMapList/phenotypeMap/phenotypeInheritance. 16 | The clinical synopsis contains the inheritance model of the OMIM entry. 17 | } 18 | \examples{ 19 | get_inheritance(get_omim(303600, geneMap=TRUE)) 20 | } 21 | \keyword{inheritance} 22 | -------------------------------------------------------------------------------- /R/get_inheritance.R: -------------------------------------------------------------------------------- 1 | #' Get inheritance model of genes associated with OMIM ID 2 | #' 3 | #' Returns the inheritance model of a gene/s associated with the OMIM entry. 4 | #' An OMIM entry may be associated to more than one gene and therefore will have more than one inheritance model. 5 | #' The function assumes that the inheritance model is stored in the XML node /omim/entryList/entry/phenotypeMapList/phenotypeMap/phenotypeInheritance. 6 | #' The clinical synopsis contains the inheritance model of the OMIM entry. 7 | #' 8 | #' @param xml XML result from get_omim() 9 | #' @keywords inheritance 10 | #' @export 11 | #' @examples 12 | #' get_inheritance(get_omim(303600, geneMap=TRUE)) 13 | 14 | get_inheritance <- function(my_xml){ 15 | my_inheritance_node <- getNodeSet(my_xml, path = "/omim/entryList/entry/phenotypeMapList/phenotypeMap/phenotypeInheritance") 16 | xmlSApply(my_inheritance_node, xmlValue) 17 | } 18 | 19 | -------------------------------------------------------------------------------- /R/gene_to_omim.R: -------------------------------------------------------------------------------- 1 | #' Gene search 2 | #' 3 | #' This function builds the URL to search the OMIM server based on an input gene 4 | #' 5 | #' @param gene_symbol Gene Symbol. Default is FGFR2. 6 | #' @param show_query Show API query. Default is FALSE. 7 | #' @keywords Gene Symbol 8 | #' @export 9 | #' @examples 10 | #' gene_to_omim(TTN) 11 | 12 | gene_to_omim <- function(gene_symbol = 'FGFR2', show_query = FALSE){ 13 | my_search <- paste('https://api.omim.org/api/entry/search?search=gene_symbol:', gene_symbol, sep='') 14 | my_include <- 'include=geneMap' 15 | my_query <- paste(my_search, my_include, my_key, sep = "&") 16 | if (show_query){ 17 | message(my_query) 18 | } 19 | my_result <- read_xml(my_query) %>% xmlParse(.) 20 | my_list <- xmlToList(my_result) 21 | my_xml <- my_list$searchResponse$entryList$entry$geneMap$phenotypeMapList 22 | as.vector(unlist(sapply(my_xml, function(x) x$phenotypeMimNumber))) 23 | } 24 | 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016-2017 Dave Tang 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /R/phenotypic_series.R: -------------------------------------------------------------------------------- 1 | #' OMIM Phenotypic Series 2 | #' 3 | #' This function returns OMIM IDs given a OMIM Phenotypic Series ID. 4 | #' Recursive apply (rapply) and grep is used because phenotypeMimNumber is not always present in the same XML structure. 5 | #' 6 | #' @param series Phenotypic Series Number. Default is PS163950. 7 | #' @param show_query Show API query. Default is FALSE. 8 | #' @keywords Phenotypic Series Number 9 | #' @export 10 | #' @examples 11 | #' phenotypic_series(series = 'PS308350') 12 | 13 | phenotypic_series <- function(series = 'PS163950', show_query = FALSE){ 14 | my_search <- paste('https://api.omim.org/api/entry/search?search=phenotypic_series_number:', series, sep='') 15 | my_include <- 'include=geneMap' 16 | start <- 0 17 | limit <- 20 # max limit is 20 when geneMap is included 18 | my_start <- paste('start=', start, sep='') 19 | my_limit <- paste('limit=', limit, sep='') 20 | my_query <- paste(my_search, my_include, my_key, my_start, my_limit, sep = "&") 21 | if (show_query){ 22 | message(my_query) 23 | } 24 | my_result <- read_xml(my_query) %>% xmlParse(.) 25 | my_list <- xmlToList(my_result) 26 | my_total <- as.numeric(my_list$searchResponse$totalResults) 27 | tmp <- rapply(my_list, function(x) x) 28 | my_omim <- as.vector(tmp[grep('phenotypeMimNumber', names(tmp))]) 29 | 30 | if (my_total < 21){ 31 | return(unique(my_omim)) 32 | } else { 33 | my_last <- round(my_total/20) 34 | for(i in 2:my_last){ 35 | start <- start + 20 36 | my_start <- paste('start=', start, sep='') 37 | my_query <- paste(my_search, my_include, my_key, my_start, my_limit, sep = "&") 38 | my_result <- read_xml(my_query) %>% xmlParse(.) 39 | my_list <- xmlToList(my_result) 40 | my_total <- as.numeric(my_list$searchResponse$totalResults) 41 | tmp <- rapply(my_list, function(x) x) 42 | my_omim <- c(my_omim, as.vector(tmp[grep('phenotypeMimNumber', names(tmp))])) 43 | } 44 | return(unique(my_omim)) 45 | } 46 | } 47 | 48 | -------------------------------------------------------------------------------- /man/get_omim.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/get_omim.R 3 | \name{get_omim} 4 | \alias{get_omim} 5 | \title{Query OMIM server} 6 | \usage{ 7 | get_omim( 8 | omim_id = 100100, 9 | show_query = FALSE, 10 | text = FALSE, 11 | existflags = FALSE, 12 | allelicVariantList = FALSE, 13 | clinicalSynopsis = FALSE, 14 | seeAlso = FALSE, 15 | referenceList = FALSE, 16 | geneMap = FALSE, 17 | externalLinks = FALSE, 18 | contributors = FALSE, 19 | creationDate = FALSE, 20 | editHistory = FALSE, 21 | dates = FALSE, 22 | all = FALSE 23 | ) 24 | } 25 | \arguments{ 26 | \item{omim_id}{OMIM ID. Default is 100100.} 27 | 28 | \item{show_query}{Show API query. Default is FALSE.} 29 | 30 | \item{text}{Includes the text field sections with the entry. Default is FALSE.} 31 | 32 | \item{existflags}{Include the 'exists' flags with the entry (clinical synopsis, allelic variant, gene map & phenotype map). Default is FALSE.} 33 | 34 | \item{allelicVariantList}{Includes the allelic variant list with the entry. Default is FALSE.} 35 | 36 | \item{clinicalSynopsis}{Include the clinical synopsis with the entry. Default is FALSE.} 37 | 38 | \item{seeAlso}{Includes the 'see also' field with the entry. Default is FALSE.} 39 | 40 | \item{referenceList}{Include the reference list with the entry. Default is FALSE.} 41 | 42 | \item{geneMap}{Include the gene map/phenotype map data with the entry. Default is FALSE.} 43 | 44 | \item{externalLinks}{Include the external links with the entry. Default is FALSE.} 45 | 46 | \item{contributors}{Includes the 'contributors' field with the entry. Default is FALSE.} 47 | 48 | \item{creationDate}{Includes the 'creation date' field with the entry. Default is FALSE.} 49 | 50 | \item{editHistory}{Includes the 'edit history' field with the entry. Default is FALSE.} 51 | 52 | \item{dates}{Include the dates data with the entry. Default is FALSE.} 53 | 54 | \item{all}{the above data with the entry. Default is FALSE.} 55 | } 56 | \description{ 57 | This function builds the URL and queries the OMIM server 58 | } 59 | \examples{ 60 | get_omim(303600, geneMap = TRUE) 61 | } 62 | \keyword{ID} 63 | \keyword{OMIM} 64 | -------------------------------------------------------------------------------- /R/search_phenotype.R: -------------------------------------------------------------------------------- 1 | #' Search OMIM 2 | #' 3 | #' This function returns OMIM phenotypes given a match of a search term in the text meta field of OMIM phenotype entries. 4 | #' Recursive apply (rapply) and grep is used because phenotypeMimNumber is not always present in the same XML structure. 5 | #' 6 | #' @param series Search term. Default is "noonan syndrome". 7 | #' @param show_query Show API query. Default is FALSE. 8 | #' @keywords Search OMIM 9 | #' @export 10 | #' @examples 11 | #' search_phenotype(search_term = 'noonan syndrome') 12 | 13 | search_phenotype <- function(search_term = 'noonan syndrome', show_query = FALSE){ 14 | search_term <- gsub("\\s", '%20', search_term) 15 | search_term <- sub("^", "%22", search_term) 16 | search_term <- sub("$", "%22", search_term) 17 | # my_search <- paste('https://api.omim.org/api/entry/search?search=', search_term, '+AND+gm_phenotype_exists:true', sep='') 18 | my_search <- paste('https://api.omim.org/api/entry/search?search=', search_term, sep='') 19 | my_include <- 'include=geneMap' 20 | start <- 0 21 | limit <- 20 # max limit is 20 when geneMap is included 22 | my_start <- paste('start=', start, sep='') 23 | my_limit <- paste('limit=', limit, sep='') 24 | my_query <- paste(my_search, my_include, my_key, my_start, my_limit, sep = "&") 25 | if (show_query){ 26 | message(my_query) 27 | } 28 | my_result <- read_xml(my_query) %>% xmlParse(.) 29 | my_list <- xmlToList(my_result) 30 | my_total <- as.numeric(my_list$searchResponse$totalResults) 31 | tmp <- rapply(my_list, function(x) x) 32 | my_omim <- as.vector(tmp[grep('phenotypeMimNumber', names(tmp))]) 33 | 34 | if (my_total < 21){ 35 | return(unique(my_omim)) 36 | } else { 37 | if (my_total > 100){ 38 | return(paste('Please use more specific term/s; search term: ', search_term, ' returned over 100 results (', my_total, ')', sep = '')) 39 | } 40 | my_last <- round(my_total/20) 41 | for(i in 2:my_last){ 42 | start <- start + 20 43 | my_start <- paste('start=', start, sep='') 44 | my_query <- paste(my_search, my_include, my_key, my_start, my_limit, sep = "&") 45 | my_result <- read_xml(my_query) %>% xmlParse(.) 46 | my_list <- xmlToList(my_result) 47 | my_total <- as.numeric(my_list$searchResponse$totalResults) 48 | tmp <- rapply(my_list, function(x) x) 49 | my_omim <- c(my_omim, as.vector(tmp[grep('phenotypeMimNumber', names(tmp))])) 50 | } 51 | return(unique(my_omim)) 52 | } 53 | } 54 | 55 | -------------------------------------------------------------------------------- /R/get_omim.R: -------------------------------------------------------------------------------- 1 | #' Query OMIM server 2 | #' 3 | #' This function builds the URL and queries the OMIM server 4 | #' 5 | #' @param omim_id OMIM ID. Default is 100100. 6 | #' @param show_query Show API query. Default is FALSE. 7 | #' @param text Includes the text field sections with the entry. Default is FALSE. 8 | #' @param existflags Include the 'exists' flags with the entry (clinical synopsis, allelic variant, gene map & phenotype map). Default is FALSE. 9 | #' @param allelicVariantList Includes the allelic variant list with the entry. Default is FALSE. 10 | #' @param clinicalSynopsis Include the clinical synopsis with the entry. Default is FALSE. 11 | #' @param seeAlso Includes the 'see also' field with the entry. Default is FALSE. 12 | #' @param referenceList Include the reference list with the entry. Default is FALSE. 13 | #' @param geneMap Include the gene map/phenotype map data with the entry. Default is FALSE. 14 | #' @param externalLinks Include the external links with the entry. Default is FALSE. 15 | #' @param contributors Includes the 'contributors' field with the entry. Default is FALSE. 16 | #' @param creationDate Includes the 'creation date' field with the entry. Default is FALSE. 17 | #' @param editHistory Includes the 'edit history' field with the entry. Default is FALSE. 18 | #' @param dates Include the dates data with the entry. Default is FALSE. 19 | #' @param all the above data with the entry. Default is FALSE. 20 | #' @keywords OMIM ID 21 | #' @export 22 | #' @examples 23 | #' get_omim(303600, geneMap = TRUE) 24 | 25 | get_omim <- function(omim_id = 100100, #default OMIM ID 26 | show_query = FALSE, 27 | text = FALSE, #Includes the text field sections with the entry. 28 | existflags = FALSE, #Include the 'exists' flags with the entry (clinical synopsis, allelic variant, gene map & phenotype map). 29 | allelicVariantList = FALSE, #Includes the allelic variant list with the entry. 30 | clinicalSynopsis = FALSE, #Include the clinical synopsis with the entry. 31 | seeAlso = FALSE, #Includes the 'see also' field with the entry. 32 | referenceList = FALSE, #Include the reference list with the entry. 33 | geneMap = FALSE, #Include the gene map/phenotype map data with the entry. 34 | externalLinks = FALSE, #Include the external links with the entry. 35 | contributors = FALSE, #Includes the 'contributors' field with the entry. 36 | creationDate = FALSE, #Includes the 'creation date' field with the entry. 37 | editHistory = FALSE, #Includes the 'edit history' field with the entry. 38 | dates = FALSE, #Include the dates data with the entry. 39 | all = FALSE #Include the above data with the entry. 40 | ){ 41 | #get all the arguments of the function call 42 | a <- as.list(match.call()) 43 | my_mim <- paste('mimNumber=', omim_id, sep='') 44 | my_link <- 'https://api.omim.org/api/entry?' 45 | my_query <- paste(my_link, my_mim, my_key, sep = "&") 46 | #loop through all the arguments 47 | for (i in names(a)){ 48 | #skip the omid_id and blank argument 49 | if(!i %in% '' && !i %in% 'omim_id' && !i %in% 'show_query'){ 50 | my_include <- paste('&', 'include=', i, sep='') 51 | my_query <- paste(my_query, my_include, sep='') 52 | } 53 | } 54 | if (show_query){ 55 | message(my_query) 56 | } 57 | read_xml(my_query) %>% xmlParse(.) 58 | } 59 | 60 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.574927.svg)](https://doi.org/10.5281/zenodo.574927) 2 | 3 | README 4 | ====== 5 | 6 | The `romim` package can be used to query the OMIM database; it uses the [OMIM API](https://www.omim.org/help/api). You can install this package using [remotes](https://github.com/r-lib/remotes) or [devtools](https://github.com/r-lib/devtools); the `remotes` package is a lightweight replacement of the install functions in devtools. 7 | 8 | ```r 9 | install.packages("remotes") 10 | remotes::install_github('davetang/romim') 11 | 12 | library(romim) 13 | help(package = "romim") 14 | ``` 15 | 16 | # Usage 17 | 18 | You will need a valid API key, which you can request for on the [OMIM API page](https://www.omim.org/api). Note that in order to apply for API access you need: 19 | 20 | > Access will not be granted without a valid institutional email address. Email addresses from generic email providers such as Gmail, Yahoo, Hotmail, Live, MSN, iCloud, 126.com, 163.com or qq.com will be automatically rejected. 21 | 22 | Use `set_key` to use your API key. 23 | 24 | ```r 25 | library(romim) 26 | Loading required package: XML 27 | Loading required package: magrittr 28 | Loading required package: xml2 29 | 30 | # not a real key 31 | set_key('AAAAAAAAAAAAAAAAAAAAAA') 32 | ``` 33 | 34 | Use `get_omim` to retrieve an OMIM entry using a [MIM number](https://en.wikipedia.org/wiki/Online_Mendelian_Inheritance_in_Man#MIM_numbers). 35 | 36 | ```r 37 | omim_result <- get_omim(147920, geneMap = TRUE) 38 | ``` 39 | 40 | There are several functions for parsing `omim_result`. 41 | 42 | ```r 43 | get_gene(omim_result) 44 | # [1] "KMT2D, MLL2, ALR, KABUK1" 45 | 46 | get_title(omim_result) 47 | # [1] "KABUKI SYNDROME 1; KABUK1" 48 | 49 | get_inheritance(omim_result) 50 | # [1] "Autosomal dominant" 51 | ``` 52 | 53 | Use the `sapply` function to query a list of OMIM numbers. 54 | 55 | ```r 56 | # a list of OMIM IDs 57 | my_list <- list(100070,100100,100300,100600,100800,100820,101000,101200,101400,101600) 58 | 59 | my_list_omim <- sapply(my_list, get_omim) 60 | sapply(my_list_omim, get_title) 61 | # [1] "AORTIC ANEURYSM, FAMILIAL ABDOMINAL, 1; AAA1" 62 | # [2] "PRUNE BELLY SYNDROME; PBS" 63 | # [3] "ADAMS-OLIVER SYNDROME 1; AOS1" 64 | # [4] "ACANTHOSIS NIGRICANS" 65 | # [5] "ACHONDROPLASIA; ACH" 66 | # [6] "ACHOO SYNDROME" 67 | # [7] "NEUROFIBROMATOSIS, TYPE II; NF2" 68 | # [8] "APERT SYNDROME" 69 | # [9] "SAETHRE-CHOTZEN SYNDROME; SCS" 70 | # [10] "PFEIFFER SYNDROME" 71 | ``` 72 | 73 | Search OMIM disorders associated with a gene of interest. 74 | 75 | ```r 76 | my_list <- gene_to_omim('TTN') 77 | my_list_omim <- sapply(my_list, get_omim) 78 | sapply(my_list_omim, get_title) 79 | # 604145 80 | # "CARDIOMYOPATHY, DILATED, 1G; CMD1G" 81 | # 613765 82 | # "CARDIOMYOPATHY, FAMILIAL HYPERTROPHIC, 9; CMH9" 83 | # 608807 84 | # "MUSCULAR DYSTROPHY, LIMB-GIRDLE, AUTOSOMAL RECESSIVE 10; LGMDR10" 85 | # 603689 86 | # "MYOPATHY, MYOFIBRILLAR, 9, WITH EARLY RESPIRATORY FAILURE; MFM9" 87 | # 611705 88 | # "SALIH MYOPATHY; SALMY" 89 | # 600334 90 | # "TIBIAL MUSCULAR DYSTROPHY, TARDIVE; TMD" 91 | ``` 92 | 93 | Obtain OMIM IDs from a Phenotypic Series ID. 94 | 95 | ```r 96 | phenotypic_series('PS213600') 97 | # [1] "213600" "615007" "615483" "616413" "618317" "618824" 98 | ``` 99 | 100 | Search OMIM using free text, which may be useful for searching for OMIM entries using keywords. 101 | 102 | ```r 103 | my_search <- search_phenotype("Waardenburg Shah syndrome") 104 | omim_list <- sapply(my_search, get_omim, geneMap = TRUE) 105 | sapply(omim_list, get_title) 106 | # 277580 107 | # "WAARDENBURG SYNDROME, TYPE 4A; WS4A" 108 | # 609136 109 | # "PERIPHERAL DEMYELINATING NEUROPATHY, CENTRAL DYSMYELINATION, WAARDENBURG SYNDROME, AND HIRSCHSPRUNG DISEASE; PCWH" 110 | # 611584 111 | # "WAARDENBURG SYNDROME, TYPE 2E; WS2E" 112 | # 613266 113 | # "WAARDENBURG SYNDROME, TYPE 4C; WS4C" 114 | # 613712 115 | # "HIRSCHSPRUNG DISEASE, SUSCEPTIBILITY TO, 4; HSCR4" 116 | # 209880 117 | # "CENTRAL HYPOVENTILATION SYNDROME, CONGENITAL; CCHS" 118 | # 613265 119 | # "WAARDENBURG SYNDROME, TYPE 4B; WS4B" 120 | # 600155 121 | # "HIRSCHSPRUNG DISEASE, SUSCEPTIBILITY TO, 2; HSCR2" 122 | # 600501 123 | # "ABCD SYNDROME; ABCDS" 124 | # 142623 125 | # "HIRSCHSPRUNG DISEASE, SUSCEPTIBILITY TO, 1; HSCR1" 126 | # 148820 127 | # "WAARDENBURG SYNDROME, TYPE 3; WS3" 128 | # 193500 129 | # "WAARDENBURG SYNDROME, TYPE 1; WS1" 130 | # 193510 131 | # "WAARDENBURG SYNDROME, TYPE 2A; WS2A" 132 | # 613884 133 | # "CHROMOSOME 13q14 DELETION SYNDROME" 134 | ``` 135 | 136 | # How to modify package 137 | 138 | The functions are in the `R` directory and you can modify them as you please. If you modify the documentation in these files, you will need to run document(); see below. 139 | 140 | ```bash 141 | ls -1 R 142 | gene_to_omim.R 143 | get_gene.R 144 | get_inheritance.R 145 | get_omim.R 146 | get_pheno_key.R 147 | get_title.R 148 | phenotypic_series.R 149 | search_phenotype.R 150 | set_key.R 151 | ``` 152 | 153 | To add more functions, create an `.R` file inside the `R` directory; the file should follow the [Roxygen process](https://cran.r-project.org/web/packages/roxygen2/vignettes/rd.html). For example: 154 | 155 | ```r 156 | #' Set API key 157 | #' 158 | #' This function sets the API key 159 | #' 160 | #' @param key Your API key 161 | #' @keywords key 162 | #' @export 163 | #' @examples 164 | #' my_key <- set_key('aAS5ASdf35jasdnadsfj') # not a real key 165 | 166 | set_key <- function(key){ 167 | my_key <<- paste('apiKey=', key, sep='') 168 | } 169 | ``` 170 | 171 | After you have added the file (or modified the original files), you'll need to run document(). 172 | 173 | ```r 174 | library(roxygen2) 175 | library(devtools) 176 | 177 | # change this to where you cloned the repo 178 | setwd('~/github/romim/') 179 | document() 180 | ``` 181 | 182 | Then (re-)install the package to see if everything works. 183 | 184 | ```r 185 | setwd('..') 186 | install("romim") 187 | ``` 188 | 189 | # Troubleshooting 190 | 191 | The first version of `romim` stopped working when the `xmlParse` function from the `XML` package was updated. In the latest version of `romim` (1.0.1), `read_xml` from the `xml2` package is used to retrieve the results. The functions `get_omim`, `gene_to_omim`, `phenotypic_series`, and `search_phenotype` now includes a `show_query` parameter that will output the query. You can paste this output to your Internet browser for troubleshooting purposes, to see if any results are retrieved. 192 | 193 | # Further reading 194 | 195 | See my [this blog post](https://davetang.org/muse/2015/03/17/getting-started-with-the-omim-api/) for more information on the OMIM API. For more information on creating R packages, see [this blog post](https://davetang.org/muse/2015/02/04/bed-granges/). 196 | 197 | # Contact 198 | 199 | Email me at davetang dot org (no spaces). 200 | 201 | --------------------------------------------------------------------------------