npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cbioportal-api-client

v0.3.4

Published

cBio Portal API client with promises and response parsing

Downloads

13

Readme

cBio Portal API Client

npm Build Status Coverage Status Dependency Status

cBio Portal API client. Parses tab separated responses into JSON format. Works in node and in the browser via a module loader such as Webpack.

This library can be used programatically or via the command line.

Under active development: This library is currently under active development. The module API is not finalized and is likely to change before v1.

Installation

$ npm install cbioportal-api-client --save

Programmatic Usage

API Reference

import CbioPortal from 'cbioportal-api-client';

const cbioPortal = CbioPortal();

cbioPortal.getCancerStudies()
  .then(response => {
    console.log(response); // Prints array of cancer studies returned from API
  });

cbioPortal.getGeneticProfiles({ cancer_study_id: 'gbm_tcga' })
  .then(response => {
    console.log(response); // Prints array of genetic profiles returned from the 'gbm_tcga' study
  });

Command Line Usage

Note: Requires node.

# global install to use anywhere
$ npm install -g cbioportal-api-client

# print usage info using --help
$ cbioportal-api-client --help

  Usage: cbioportal-api-client [options] [command]


  Commands:

    getCancerStudies                 get cancer study meta-data
    getTypesOfCancer                 get clinical cancer types
    getGeneticProfiles [options]     get genetic profile data for a cancer study.
    getCaseLists [options]           get case lists stored for a specific cancer study.
    getProfileData [options]         get genomic profile data for one or more genes.
    getAlterationSummary [options]   summarize alterations for the profile data.

  You can get usage info for specific commands using [command] --help

  Options:

    -h, --help             output usage information
    -V, --version          output the version number
    -f, --format <format>  response format

# example API call, sends JSON formatted response to stdout
$ cbioportal-api-client getProfileData -s gbm_tcga_cnaseq -p gbm_tcga_mutations -g TP53
# .... cut long JSON response

# summarizing alterations
$ cbioportal-api-client getAlterationSummary -s gbm_tcga_cnaseq -p gbm_tcga_mutations,gbm_tcga_gistic -g TP53,MDM2,MDM4
{"summary":{"genes":{"mdm2":{"mutated":1,"cna":9,"combined":10},"mdm4":{"mutated":0,"cna":10,"combined":10},"tp53":{"mutated":29,"cna":2,"combined":30}},"overall":47}}

API Reference

Modules

cbioportal-api-client


cbioportal-api-client ⏏ exports.default(config) ⇒ cbioPortal

Creates a new cBio Portal API client

Kind: exports method of cbioportal-api-client
Returns: cbioPortal

| Param | Type | Description | | --- | --- | --- | | config | Object | Configuration options object. | | config.requestOpts | Object | Override the request congfiguration object. |

Example
Basic usage:

import CbioPortal from 'cbioportal-api-client';

const cbioPortal = CbioPortal();

cbioPortal.getCancerStudies()
  .then(response => {
    console.log(response); // Prints array of cancer studies returned from API
  });

cbioportal-api-client~cbioPortal : Object

cbioPortal API Object Prototype. Used as the object prototype when creating an API client object via the module factory method.

Kind: inner constant of cbioportal-api-client

See: Use CbioPortal() for object creation.


cbioPortal.getTypesOfCancer() ⇒ Promise

Retrieves a list of all the clinical types of cancer stored on the server.

Kind: instance method of cbioPortal
Returns: Promise
Fulfills: Array response data converted from TSV to JSON


cbioPortal.getCancerStudies() ⇒ Promise

Retrieves meta-data regarding cancer studies stored on the server.

Kind: instance method of cbioPortal
Returns: Promise
Fulfills: Array response data converted from TSV to JSON


cbioPortal.getGeneticProfiles(query) ⇒ Promise

Retrieves meta-data regarding all genetic profiles, e.g. mutation or copy number profiles, stored about a specific cancer study.

Kind: instance method of cbioPortal
Returns: Promise
Fulfills: Array response data converted from TSV to JSON

| Param | Type | Description | | --- | --- | --- | | query | Object | | | query.cancer_study_id | string | Cancer study ID |


cbioPortal.getCaseLists(query) ⇒ Promise

Retrieves meta-data regarding all case lists stored about a specific cancer study.

For example, a within a particular study, only some cases may have sequence data, and another subset of cases may have been sequenced and treated with a specific therapeutic protocol.

Multiple case lists may be associated with each cancer study, and this method enables you to retrieve meta-data regarding all of these case lists.

Kind: instance method of cbioPortal
Returns: Promise
Fulfill: response data converted from TSV to JSON

| Param | Type | Description | | --- | --- | --- | | query | Object | | | query.cancer_study_id | string | Cancer study ID |


cbioPortal.getProfileData(query) ⇒ Promise

Retrieves genomic profile data for one or more genes.

Note: If you pass in multiple genetic profile IDs and multiple genes, the library will make multiple requests as the API does not support this type of query.

Kind: instance method of cbioPortal
Returns: Promise
Fulfill: response data converted from TSV to JSON

| Param | Type | Description | | --- | --- | --- | | query | Object | | | query.case_set_id | string | A unique ID used to identify the case list ID in subsequent interface calls. This is a human readable ID. For example, "gbm_all" identifies all cases profiles in the TCGA GBM study. | | query.genetic_profile_id | Array.<string> | string | One or more genetic profile IDs | | query.gene_list | Array.<string> | string | One or more genes, specified as HUGO Gene Symbols or Entrez Gene IDs |


cbioPortal.getAlterationSummary(query) ⇒ Promise

Summarize gene alterations

Kind: instance method of cbioPortal
Returns: Promise

| Param | Type | Description | | --- | --- | --- | | query | Object | | | query.case_set_id | string | A unique ID used to identify the case list ID in subsequent interface calls. This is a human readable ID. For example, "gbm_all" identifies all cases profiles in the TCGA GBM study. | | query.genetic_profile_id | Array.<string> | string | One or more genetic profile IDs | | query.gene_list | Array.<string> | string | One or more genes, specified as HUGO Gene Symbols or Entrez Gene IDs |


cbioportal-api-client/utils/convertResponse ⇒ Promise

Converts tab delimited responses to JSON format

Returns: Promise - Resolves with the response JSON

| Param | Type | Description | | --- | --- | --- | | response | string | TSV string |


cbioportal-api-client/utils/summarizeAlterations ⇒ Promise

Summarizes alterations for results

Returns: Promise - Resolves with the summary
Fulfills: Object Object with results, see example

| Param | Type | Description | | --- | --- | --- | | dataSets | Object | Array | Converted response dataset(s) |

Example
Basic Usage:

import CbioPortal from 'cbioportal-api-client';
import { summarizeAlterations } from 'cbioportal-api-client/dist/utils';

const cbioPortal = CbioPortal();

cbioPortal.getProfileData({
  case_set_id: 'gbm_tcga_cnaseq',
  genetic_profile_id: ['gbm_tcga_mutations', 'gbm_tcga_gistic'],
  gene_list: ['tp53', 'mdm2', 'mdm4']
})
.then(response => summarizeAlterations(response))
.then(result => console.log(result));

// console.log output

{
  summary: {
    genes: {
      tp53: {
        mutated: 29,
        cna: 2,
        combined: 30
      },
      mdm2: {
        mutated: 1,
        cna: 9,
        combined: 10
      },
      mdm4: {
        mutated: 0,
        cna: 10,
        combined: 10
      }
    },
    overall: 47
  }
}