Skip to content

R API wrapper for using the Otter webapp: otter.ccm.sickkids.ca

License

Notifications You must be signed in to change notification settings

shlienlab/otter-api-wrapper-R

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OTTER: Oncologic TranscripTome Expression Recognition

Otter is a series of deep learning models aimed at classifying RNA TPM counts against an atlas of cancer types and subtypes. The original code for running Otter is available at https://github.com/shlienlab/otter.


Otter API Wrapper

This is an R wrapper for the Otter API. This wrapper helps you run the API available at https://otter.ccm.sickkids.ca/.

Installation

install.packages("rjson")
install.packages("plotly")
remotes::install_github("shlienlab/otter-api-wrapper-R")

Quickstart

You can check out the examples folder for more details. The simplest usage of the API is:

library(otterapiwrapperR)

otter_obj <- otter_api(api_token="<your API token>")
df_result <- otter_run_sample_path(otter_obj, file_path="examples/data/rhabdomyosarcoma.genes.hugo.results")

Short Docs

Usually you want to start with creating an OtterAPI object:

library(otterapiwrapperR)

otter_obj <- otter_api(api_token="<your API token>")

Then, running a sample is the next step. This sends the sample to our servers and runs our models. The sample is only stored in the server during runtime and is deleted shortly after:

df_result <- otter_run_sample_path(
  otter_obj,
  file_path="examples/data/rhabdomyosarcoma.genes.hugo.results",
  model_name='<otter, hierarchical>', # check http://localhost:3000/app/inference for details
  sample_name='<custom name for the sample>'
)

Details on the classes of the resulting dataframe can be found as an Excel file or if that link fails, as a supplementary table on the paper.

From the dataframe, you can now generate all of the plots available on the webapp using the Plotly library:

# Returns a dictionary with top_path and sunburst_plot
plot_result = otter_plot_sample(otter_obj, df_result)
plotly_fig <- otter_to_plot(plot_result$sunburst_plot)
plotly_fig

The top_path key allows you to get the top path of subclasses based on the model classification. This is the same as you will find on the results page. The sunburst_plot key gives you access to the sunburst plot, also available on the results page.

If you want to retrieve plots from the explore page, you can do so by calling

# returns age_plot, diagnosis_plot, and sex_plot
plot_result <- otter_explore_plots(otter_obj)

# or 

plot_result <- otter_explore_plots(otter_obj, tail(plot_result$top_path$names, n=1)) # where class_name is the name of any class you are interested in

# then
plotly_fig <- otter_to_plot(plot_result$age_plot)
plotly_fig

plotly_fig <- otter_to_plot(plot_result$diagnosis_plot)
plotly_fig

plotly_fig <- otter_to_plot(plot_result$sex_plot)
plotly_fig

Citation

When using this library, please cite:

Comitani, Federico, et al. "Diagnostic classification of childhood cancer using multiscale transcriptomics." Nature medicine 29.3 (2023): 656-666.

Questions

If you have any questions about the API or the methods behind OTTER, please send an email to pedro.lemosballester@sickkids.ca or adam.shlien@sickkids.ca.

About

R API wrapper for using the Otter webapp: otter.ccm.sickkids.ca

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages