Find Data on CGC via Data Exploerer, SPARQL, and Datasets API

Tengfei Yin <>


1 Introdution

There are currently three ways to find the data you need on CGC:

2 Quick Start

2.1 Graphical data explorer

Please read the tutorial here.

2.2 SPARQL examples

Seven Bridges’ SPARQL console, available at

Please read following tutorials first

Let’s see an example here, you will need the R package SPARQL:

You can use the CGC API to access the TCGA files found via SPARQL queries. To get files that have download links, you will need to use the SPARQL variable path in your query.

You can directly copy those files to a project, make sure if the files is controlled access

Now have fun with more examples in this tutorial.

2.3 Datasets API examples

Please read the tutorials.

2.3.1 Browse TCGA via the Datasets API

Doing a HTTP GET on this endpoint one will get a resource with links to all entities in the dataset. Following these links (doing an HTTP GET on them) one will go to a list of entities (for example /files) from TCGA dataset identified with their proper URL. Further following one of these links you’ll get a particular resource (if we went to /files, we’ll get a description of a particular file) with all specific properties like id, label, etc. and links to other entities that are connected to a specific resource (for example /cases) that you can explore further. From there on, the process repeats as long as you follow the links. Return datasets accessible trough the CGC

Create an Auth object with your token, make sure you are using the correct URL.


use Auth$api() method so there is no need to type base URL or token again. Return list of all TCGA entities

You can issue another GET request to the href of the tcga object, if you want to access TCGA data. Interpreting the list of all entities

For example, to see a list of all TCGA files, send the request:

For example, to see the metadata schema for files send the request: Copy files to you project

Get file id from Datasets API, then use public API to copy files. Make sure your project is “TCGA” compatible, otherwise if you are trying to copy controlled access data to your non-TCGA project, you will get

"HTTP Status 403: Insufficient privileges to access the requested file."

2.3.2 Post with query

endpoint user can filter collection resources by using a DSL in JSON format that translates as a subset of SPARQL. Main advantage here is that an end user gets the subset SPARQL expressiveness without the need to learn SPARQL specification. Find samples connected to a case

Count samples connected to a case

Issuing a GET request to the href path will return the following data:

Note: api function is a light layer of httr package, it’s different from Auth$api call. Find cases with given age at diagnosis

Suppose you want to see all cases for which the age at diagnosis is between 10 and 50. Then, you use the following query.

Note that the value of the metadata field hasAgeAtDiagnosis is a dictionary containing the keyfilter, whose value is a further dictionary with keysgt(greater than) and lt (less than) for the upper and lower bounds to filter by. Find cases with a given age at diagnosis and disease

Suppose you want to see all cases that, as in the example, (Find cases with given age at diagnosis)(doc:find-all-cases-with-a-given-age-at-diagnosis), have an age at diagnosis of between 10 and 50, but that also have the disease “Kidney Chromophobe”. Then, use the following query: