Skip to contents

This function maps codes (identifiers) across tumor classification systems. Use the arguments from and to to choose the source and target ontologies. Available options are: 'oncotree_code', 'nci_code', 'umls_code', 'icdo_topography_code', 'icdo_morphology_code', and 'hemeonc_code'.

Note that you can also use the functions oncotree_to_nci(), nci_to_oncotree(), oncotree_to_umls() and umls_to_oncotree() to map between OncoTree and NCIt systems. The difference is that these functions use the OncoTree API, and the output can be made to depend on older versions of OncoTree. map_ontology_code() relies on a static file provided by the OncoTree team that is not as up to date as the data provided by the web API. Nevetheless, the scope of the mappings provided by map_ontology_code() is broader. The file used by map_ontology_code() can be directly imported into R using the function read_ontology_mappings().

Usage

map_ontology_code(code, from, to, collapse = NULL)

Arguments

code

A character vector with identifier codes of the from ontology that are meant to be mapped to the to ontology.

from

The source ontology. One of: 'oncotree_code', 'nci_code', 'umls_code', 'icdo_topography_code', 'icdo_morphology_code', and 'hemeonc_code'.

to

The target ontology. One of: 'oncotree_code', 'nci_code', 'umls_code', 'icdo_topography_code', 'icdo_morphology_code', and 'hemeonc_code'.

collapse

A function that expects one argument, it will be the character vector of codes in the to variable, that are to be "collapsed". When the mapping is one-to-many, passing a collapsing function will allow you to make the mapping one-to-one. See examples.

Value

A tibble of two variables: first column is corresponds to the from variable and the second is the to variable.

Examples

# Omit the `code` argument to get all possible mappings. Note that
# one-to-many mappings will generate more than one row per `from` code.
map_ontology_code(from = 'oncotree_code', to = 'nci_code')
#> # A tibble: 855 × 2
#>    oncotree_code nci_code
#>    <chr>         <chr>   
#>  1 MMB           C3706   
#>  2 AIS           C4123   
#>  3 AASTR         C9477   
#>  4 FL            C3209   
#>  5 VIMT          C4286   
#>  6 KIDNEY        C12415  
#>  7 MDEP          C4327   
#>  8 PAOS          C8969   
#>  9 PRSCC         C6766   
#> 10 DSTAD         C9159   
#> # … with 845 more rows

# Simple example
map_ontology_code('MMB', from = 'oncotree_code', to = 'nci_code')
#> # A tibble: 1 × 2
#>   oncotree_code nci_code
#>   <chr>         <chr>   
#> 1 MMB           C3706   

# Some mappings are one-to-many, e.g. "SRCCR", which means repeated rows for
# the same input code.
map_ontology_code('SRCCR', from = 'oncotree_code', to = 'nci_code')
#> # A tibble: 2 × 2
#>   oncotree_code nci_code
#>   <chr>         <chr>   
#> 1 SRCCR         C9168   
#> 2 SRCCR         C7967   

# Using the `collapse` argument to "collapse" one-to-many mappings makes sure
# that the output has as many rows as the `from` vector.
map_ontology_code('SRCCR',
                  from = 'oncotree_code',
                  to = 'nci_code',
                  collapse = toString)
#> # A tibble: 1 × 2
#>   oncotree_code nci_code    
#>   <chr>         <chr>       
#> 1 SRCCR         C9168, C7967

map_ontology_code('SRCCR',
                  from = 'oncotree_code',
                  to = 'nci_code',
                  collapse = list)
#> # A tibble: 1 × 2
#>   oncotree_code nci_code 
#>   <chr>         <list>   
#> 1 SRCCR         <chr [2]>

map_ontology_code(
  'SRCCR',
  from = 'oncotree_code',
  to = 'nci_code',
  collapse = \(x) paste(x, collapse = ' ')
)
#> # A tibble: 1 × 2
#>   oncotree_code nci_code   
#>   <chr>         <chr>      
#> 1 SRCCR         C9168 C7967

# `map_ontology_code()` is vectorized over `code`
map_ontology_code(
  c('AASTR', 'MDEP'),
  from = 'oncotree_code',
  to = 'nci_code'
  )
#> # A tibble: 2 × 2
#>   oncotree_code nci_code
#>   <chr>         <chr>   
#> 1 AASTR         C9477   
#> 2 MDEP          C4327   

# Map from ICDO topography to ICDO morphology codes
map_ontology_code(
  'C72.9',
  from = 'icdo_topography_code',
  to = 'icdo_morphology_code'
  )
#> # A tibble: 65 × 2
#>    icdo_topography_code icdo_morphology_code
#>    <chr>                <chr>               
#>  1 C72.9                9401/3              
#>  2 C72.9                9501/3              
#>  3 C72.9                9390/1              
#>  4 C72.9                8000/3              
#>  5 C72.9                9424/3              
#>  6 C72.9                9391/3              
#>  7 C72.9                9425/3              
#>  8 C72.9                9383/1              
#>  9 C72.9                9100/3              
#> 10 C72.9                9522/3              
#> # … with 55 more rows