Skip to main content

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

Project description

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 a Python wrapper for the Otter API. This wrapper helps you run the API available at https://otter.ccm.sickkids.ca/.

PyPI PyPI pyversions

Installation

pip install otter-api-wrapper

Quickstart

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

from otter_api_wrapper import OtterAPI
from otter_api_wrapper.utils import save_plotly_figure
import pandas as pd

otter_api = OtterAPI(
    api_token='<your API token>'
)
df = otter_api.run_sample_path(
    file_path='examples/data/rhabdomyosarcoma.genes.hugo.results',
    model_name='otter',
    sample_name='rhabdo'
)

Short Docs

Usually you want to start with creating an OtterAPI object:

from otter_api_wrapper import OtterAPI

otter_api = OtterAPI(
    api_token='<your API token>' # You can find yours at https://otter.ccm.sickkids.ca/app/api_docs
)

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 = otter_api.run_sample_path(
    file_path='<path_to_sample>',
    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_sample = otter_api.plot_sample(df)

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_explore = otter_api.get_explore_plots()

# or 

plot_explore = otter_api.get_explore_plots(class_name=plot_sample['top_path']['names'][-1]) # where class_name is the name of any class you are interested in

You can save any of the plots by using:

from otter_api_wrapper.utils import save_plotly_figure

save_plotly_figure(plot_sample['sunburst_plot'], '<path to save file>')

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

otter_api_wrapper-0.0.3.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

otter_api_wrapper-0.0.3-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file otter_api_wrapper-0.0.3.tar.gz.

File metadata

  • Download URL: otter_api_wrapper-0.0.3.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for otter_api_wrapper-0.0.3.tar.gz
Algorithm Hash digest
SHA256 25c125dc091c66fc0e55997c2b38b83ead1b19a6cd6bfe872f526c8960a10901
MD5 a33d37486faae78dbda4740564692f73
BLAKE2b-256 7cc6ca62fd29ad677a7ff143d068bfc0849c6be1b86ba9ac553a785749bfa60c

See more details on using hashes here.

File details

Details for the file otter_api_wrapper-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for otter_api_wrapper-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1265de9d2122daf76dcbb6f4692b572caf8c91a705900e000fc01793b5bcaa3d
MD5 10f0805267032e2450ddc3320deee686
BLAKE2b-256 51dfbdeb4a7f01fc693e67a1c80316abeb7d88993063db1df0ac8efae7e49067

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page