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)