File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+
2+
3+
4+
5+ # ' Convert a UniProt ID to an NCBI Entrez Gene ID
6+ # '
7+ # ' This function takes a single UniProt ID and returns the corresponding NCBI Entrez Gene ID.
8+ # ' It uses the `org.Hs.eg.db` package to perform the mapping.
9+ # '
10+ # ' @author Klangina
11+ # ' @param uniprot_id A string representing a single UniProt ID.
12+ # ' @return A string representing the corresponding NCBI Entrez Gene ID. Returns `NA` if no mapping is found.
13+ # ' @examples
14+ # ' \dontrun{
15+ # ' uniprot_id <- "P04217"
16+ # ' entrez_id <- up2ncbi(uniprot_id)
17+ # ' print(entrez_id)
18+ # ' }
19+ # ' @importFrom AnnotationDbi select
20+ # ' @import org.Hs.eg.db
21+ # ' @export
22+ up2ncbi <- function (uniprot_id ) {
23+ # Use the select function to map the UniProt ID to an Entrez Gene ID
24+ result <- AnnotationDbi :: select(org.Hs.eg.db ,
25+ keys = uniprot_id ,
26+ columns = " ENTREZID" ,
27+ keytype = " UNIPROT" )
28+
29+ # Check if the result is not empty and return the first Entrez ID
30+ if (nrow(result ) > 0 && ! is.na(result $ ENTREZID [1 ])) {
31+ return (as.character(result $ ENTREZID [1 ]))
32+ } else {
33+ return (NA ) # Return NA if no mapping is found
34+ }
35+ }
You can’t perform that action at this time.
0 commit comments