1
$\begingroup$

I have been trying to access metadata from the Genomic Data Commons; however, not all of the information I want is showing up in the resulting tsv file. How do I get sample type and analyte type to show up in the tsv file? I have tried altering what I pass as a field (towards the top of the code), or adding a different filter, but nothing seems to change what shows up in the tsv file. Any help is appreciated!

import requests
import json

cases_endpt = "https://api.gdc.cancer.gov/cases"

# The 'fields' parameter is passed as a comma-separated string of single names.
fields = [
    "sample_ids",
    "submitter_sample_ids",
    "files.cases.sample_ids",
    "files.cases.submitter_sample_ids",
    "files.cases.samples.sample_id",
    "files.cases.samples.sample_type",
    "files.cases.samples.sample_type_id",
    "files.cases.samples.submitter_id",
    "samples.sample_id",
    "samples.sample_type",
    "samples.sample_type_id",
    "tissue_source_site.bcr_id",
    "tissue_source_site.code",
    "tissue_source_site.name",
    "tissue_source_site.project",
    "tissue_source_site.tissue_source_site_id",
    "diagnoses.classification_of_tumor",
    "diagnoses.tumor_stage",
    "diagnoses.tumor_grade",
    "files.cases.diagnoses.tumor_grade",
    "files.cases.diagnoses.tumor_stage",
    "files.cases.diagnoses.classification_of_tumor",
    "files.cases.samples.tumor_code",
    "files.cases.samples.tumor_code_id",
    "files.cases.samples.tumor_descriptor",
    "files.cases.samples.portions.slides.percent_tumor_cells",
    "files.cases.samples.portions.slides.percent_tumor_nuclei",
    "samples.tumor_code",
    "samples.tumor_code_id",
    "samples.tumor_descriptor",
    "samples.portions.slides.percent_tumor_cells",
    "samples.portions.slides.percent_tumor_nuclei",
    "files.cases.samples.oct_embedded",
    "samples.oct_embedded",
    "files.cases.samples.intermediate_dimension",
    "files.cases.samples.longest_dimension",
    "files.cases.samples.shortest_dimension",
    "samples.intermediate_dimension",
    "samples.longest_dimension",
    "samples.shortest_dimension",
    "files.cases.samples.portions.is_ffpe",
    "samples.is_ffpe",
    "samples.portions.is_ffpe",
    "files.cases.samples.pathology_report_uuid",
    "samples.pathology_report_uuid",
    "exposures.weight",
    "files.cases.exposures.weight",
    "files.cases.samples.current_weight",
    "files.cases.samples.initial_weight",
    "files.cases.samples.portions.weight",
    "samples.current_weight",
    "samples.initial_weight",
    "samples.portions.weight",
    "files.cases.samples.composition",
    "samples.composition",
    "files.cases.samples.freezing_method",
    "files.cases.samples.time_between_clamping_and_freezing",
    "files.cases.samples.time_between_excision_and_freezing",
    "samples.freezing_method",
    "samples.time_between_clamping_and_freezing",
    "samples.time_between_excision_and_freezing",
    "files.cases.samples.days_to_sample_procurement",
    "samples.days_to_sample_procurement",
    "files.cases.samples.preservation_method",
    "samples.preservation_method",
    "samples.days_to_collection",
    "files.cases.samples.days_to_collection",
    "files.cases.samples.portions.analytes.analyte_type",
    "files.cases.samples.portions.analytes.analyte_type_id",
    "files.cases.samples.portions.analytes.aliquots.analyte_type",
    "files.cases.samples.portions.analytes.aliquots.analyte_type_id",
    "samples.portions.analytes.analyte_type",
    "samples.portions.analytes.analyte_type_id",
    "samples.portions.analytes.aliquots.analyte_type",
    "samples.portions.analytes.aliquots.analyte_type_id",
    ]

fields = ','.join(fields)

filters = {
    "op": "in",
    "content": {"field": "cases.project.project_id",
                "value": ["TCGA-BRCA"]},
}

params = {"filters": json.dumps(filters),
          "format": "TSV",
          "size": "12000"}

response = requests.get(cases_endpt, params=params)
content = str(response.content, "utf-8")

with open("addingsampletype5.tsv", "w") as file:
    file.write(content)
$\endgroup$

1 Answer 1

0
$\begingroup$

When I visit the cases_endpt page you linked directly on Firefox v88, I get a filterable JSON file. Looking for "type" only comes up with "disease_type", not sample or analyte:

data    
 hits   
  0 
   disease_type "Adenomas and Adenocarcinomas"
  1 
   disease_type "Ductal and Lobular Neoplasms"
  2 
   disease_type "Ductal and Lobular Neoplasms"
  3 
   disease_type "Adenomas and Adenocarcinomas"
  4 
   disease_type "Squamous Cell Neoplasms"
  5 
   disease_type "Adenomas and Adenocarcinomas"
  6 
   disease_type "Squamous Cell Neoplasms"
  7 
   disease_type "Adenomas and Adenocarcinomas"
  8 
   disease_type "Squamous Cell Neoplasms"
  9 
   disease_type "Ductal and Lobular Neoplasms"
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.