Example query 5: Complex example for filtering TCGA data

QUERY DATASETS > About the Datasets API > Query via the Datasets API > Example query 5: Complex example...

Complex queries are well-suited to the Datasets API.

For instance, use the following query to obtain all cases that have a sample with a Primary tumor sample type of portion number 11, a new tumor anatomic site of the liver or pancreas, and a new tumor event type containing the word "recurrence".

Request

POST /datasets/tcga/v0/query HTTP/1.1
Host: cgc-datasets-api.sbgenomics.com
X-SBG-Auth-Token: 3210a98c1db9304ea9d9273156740f74
{
    "entity": "cases",
    "hasSample": {
        "hasSampleType": "Primary Tumor",
        "hasPortion": {
            "hasPortionNumber":11
            }
        },
    "hasNewTumorEvent": {
        "hasNewTumorAnatomicSite": ["Liver", "Pancrease"],
        "hasNewTumorEventType":{
            "filter": {
                "contains":"Recurrence"
            }
        }
    }
}

Response body

This request returns the response below. Note that it contains 79 cases objects: one for each case matching the query above.

{
  "_embedded": {
    "cases": [
      {
        "label": "0304D251-123A-456B-B175-C94C2F5B1B81",
        "id": "0304D251-123A-456B-B175-C94C2F5B1B81",
        "_links": {
          "self": {
            "href": "https://cgc-datasets-api.sbgenomics.com/datasets/tcga/v0/cases/0304D251-123A-456B-B175-C94C2F5B1B81"
          }
        }
      },
      {
        "label": "001867AA-36D0-463F-7890-DEC7043B4F2E",
        "id": "001867AA-36D0-463F-7890-DEC7043B4F2E",
        "_links": {
          "self": {
            "href": "https://cgc-datasets-api.sbgenomics.com/datasets/tcga/v0/cases/001867AA-36D0-463F-7890-DEC7043B4F2E"
          }
        }
      },
      {
        "label": "03DF105E-123A-4577-BFDB-9634758D778E",
        "id": "03DF105E-123A-4577-BFDB-9634758D778E",
        "_links": {
          "self": {
            "href": "https://cgc-datasets-api.sbgenomics.com/datasets/tcga/v0/cases/03DF105E-123A-4577-BFDB-9634758D778E"
          }
        }
      },
    <snip>
    ]
  },
  "count": 79
}

For each case returned, the response lists:

  • Its TCGA label
  • Its TCGA id
  • Its href: this is a path that can be used to obtain full information about the case.

Secondary request

Use a GET request to the href path obtain this information, as shown below.

GET /datasets/tcga/v0/cases/0004D251-3F70-4395-B175-C94C2F5B1B81 HTTP/1.1
Host: cgc-datasets-api.sbgenomics.com
X-SBG-Auth-Token: 3210a98c1db9304ea9d9273156740f74
{
  "hasNewTumorEventAfterInitialTreatment": "YES",
  "hasPriorDiagnosis": "No",
  "hasPathologicT": "T1",
  "hasIcdO3Site": "C22.0",
  "hasDaysToLastFollowUp": 2405,
  "hasInvestigation": "TCGA-LIHC",
  "hasGender": "MALE",
  "hasYearOfDiagnosis": 2007,
  "hasID": "TCGA-DD-AAVP",
  "hasProgram": "TCGA",
  "hasAgeAtDiagnosis": 48,
  "hasEthnicity": "NOT HISPANIC OR LATINO",
  "hasPathologicN": "N0",
  "hasPathologicStage": "Stage I",
  "hasPrimarySite": "Liver",
  "hasVitalStatus": "Alive",
  "_links": {
    "hasNewTumorEvent": {
      "href": "https://cgc-datasets-api.sbgenomics.com/datasets/tcga/v0/cases/0304D251-123A-456B-B175-C94C2F5B1B81/new_tumor_events"
    },
    "self": {
      "href": "https://cgc-datasets-api.sbgenomics.com/datasets/tcga/v0/cases/0304D251-123A-456B-B175-C94C2F5B1B81"
    },
    "hasSample": {
      "href": "https://cgc-datasets-api.sbgenomics.com/datasets/tcga/v0/cases/0304D251-123A-456B-B175-C94C2F5B1B81/samples"
    },
    "hasFile": {
      "href": "https://cgc-datasets-api.sbgenomics.com/datasets/tcga/v0/cases/0304D251-123A-456B-B175-C94C2F5B1B81/files"
    }
  },
  "hasBatchNumber": "425",
  "label": "0304D251-123A-456B-B175-C94C2F5B1B81",
  "hasHistologicalDiagnosis": "Hepatocellular Carcinoma",
  "hasRace": "ASIAN",
  "hasIcdO3Histology": "8170/3",
  "hasTumorStatus": "TUMOR FREE",
  "id": "0304D251-123A-456B-B175-C94C2F5B1B81",
  "hasIcd10": "C22.0",
  "hasPerformanceStatusScoreECOG": "0",
  "hasDiseaseType": "Liver Hepatocellular Carcinoma"
}
Language