Treatments#

The module treatments provides functions related to Treatments section of cBioPortal Web Public API.

pybioportal.treatments.fetch_all_patient_level_treatments(study_view_filter, tier='Agent')#

Fetch all patient level treatments.

Parameters:
  • study_view_filter – Study view filter.

  • tier (str) –

    Tier for treatment.

    Possible values:

    • ”Agent”: Display treatments by agent (default).

    • ”AgentClass”: Display treatments by agent class.

    • ”AgentTarget”: Display treatments by agent target.

Returns:

A DataFrame containing patient treatment rows.

Return type:

pandas.DataFrame

pybioportal.treatments.fetch_all_sample_level_treatments(study_view_filter, tier='Agent')#

Fetch all sample level treatments.

Parameters:
  • study_view_filter – Study view filter.

  • tier (str) –

    Tier for treatment.

    Possible values:

    • ”Agent”: Display treatments by agent (default).

    • ”AgentClass”: Display treatments by agent class.

    • ”AgentTarget”: Display treatments by agent target.

Returns:

A DataFrame containing sample treatment rows.

Return type:

pandas.DataFrame

pybioportal.treatments.fetch_status_display_patient_trts(study_ids, tier='Agent')#

Check if patient level treatments should be displayed.

Parameters:
  • study_ids (list of str) – List of Study IDs.

  • tier (str) –

    Tier for treatment.

    Possible values:

    • ”Agent”: Display treatments by agent (default).

    • ”AgentClass”: Display treatments by agent class.

    • ”AgentTarget”: Display treatments by agent target.

Returns:

True if patient level treatments should be displayed, False otherwise.

Return type:

bool

pybioportal.treatments.fetch_status_display_sample_trts(study_ids, tier='Agent')#

Check if sample level treatments should be displayed.

Parameters:
  • study_ids (list of str) – List of Study IDs.

  • tier (str) –

    Tier for treatment.

    Possible values:

    • ”Agent”: Display treatments by agent (default).

    • ”AgentClass”: Display treatments by agent class.

    • ”AgentTarget”: Display treatments by agent target.

Returns:

True if sample level treatments should be displayed, False otherwise.

Return type:

bool


Examples#

from pybioportal import treatments as trt

Get the Study IDs of all studies

from pybioportal import studies as std
studies = std.get_all_studies(projection="DETAILED")
std_ids = studies["studyId"].to_list()
print(f"First Study IDs of {len(std_ids)}: {std_ids[0:5]}")
First Study IDs of 393: ['acc_tcga', 'laml_tcga', 'blca_tcga', 'kirc_tcga', 'cesc_tcga']
trt.fetch_status_display_patient_trts(study_ids=std_ids)
True
trt.fetch_status_display_sample_trts(study_ids=std_ids)
True
filter1a = {"studyIds": std_ids}
df1a = trt.fetch_all_patient_level_treatments(study_view_filter=filter1a)
df1a
treatment count patientId sampleId studyId
0 CCNU + thalidomide 1 P01 P01_Pri lgg_ucsf_2014
1 CCNU + thalidomide 1 P01 P01_Rec lgg_ucsf_2014
2 MK-3475 2 P-19 121441-2T-19 mel_tsam_liang_2017
3 MK-3475 2 P-17 101984-1T-17 mel_tsam_liang_2017
4 Doxorubicin HCL 1 HTA9_1 HTA9_1-Bx3 brca_hta9_htan_2022
... ... ... ... ... ...
21974 Megestrol Acetate 17 TCGA-B5-A11I TCGA-B5-A11I-01 ucec_tcga_pan_can_atlas_2018
21975 Megestrol Acetate 17 TCGA-AP-A0LL TCGA-AP-A0LL-01 ucec_tcga_pan_can_atlas_2018
21976 Megestrol Acetate 17 TCGA-B5-A11Q TCGA-B5-A11Q-01 ucec_tcga_pan_can_atlas_2018
21977 Plfe 1 TCGA-D7-8570 TCGA-D7-8570-01 stad_tcga_pan_can_atlas_2018
21978 Ondansetron 1 TCGA-EB-A57M TCGA-EB-A57M-01 skcm_tcga_pan_can_atlas_2018

21979 rows × 5 columns

filter1b = {"patientTreatmentFilters": {
    "filters": [
      {
        "filters": [
          {
            "treatment": "Palbociclib"
          }
        ]
      }
    ]
  },
  "studyIds": std_ids}

df1b = trt.fetch_all_patient_level_treatments(study_view_filter=filter1b)
df1b
treatment count patientId sampleId studyId
0 Doxorubicin HCL 1 HTA9_1 HTA9_1-Bx3 brca_hta9_htan_2022
1 Doxorubicin HCL 1 HTA9_1 HTA9_1-Bx4 brca_hta9_htan_2022
2 Doxorubicin HCL 1 HTA9_1 HTA9_1-Bx1 brca_hta9_htan_2022
3 Doxorubicin HCL 1 HTA9_1 HTA9_1-Bx2 brca_hta9_htan_2022
4 Doxorubicin HCL 1 HTA9_1 HTA9_1-PR brca_hta9_htan_2022
... ... ... ... ... ...
116 Letrozole 6 37916 37916 pog570_bcgsc_2020
117 Letrozole 6 38725 38725 pog570_bcgsc_2020
118 Letrozole 6 37844 37844 pog570_bcgsc_2020
119 Letrozole 6 36621 36621 pog570_bcgsc_2020
120 Letrozole 6 31509 31509 pog570_bcgsc_2020

121 rows × 5 columns

filter2b = {"sampleTreatmentFilters": {
    "filters": [
      {
        "filters": [
          {
            "time": "Pre",
            "treatment": "Palbociclib"
          },
          {
            "time": "Post",
            "treatment": "Palbociclib"
          }
        ]
      }
    ]
  },
  "studyIds": ["brca_tcga"]}

df2b = trt.fetch_all_sample_level_treatments(study_view_filter=filter2b)
df2b
time treatment count patientId sampleId studyId timeTaken
0 Post DOXORUBICIN 1 TCGA-60-2697 TCGA-60-2697-01 lusc_tcga_pan_can_atlas_2018 93
1 Pre pemetrexed+bevacizumab+erlotinib 2 MSK_LX25 P-0000636-T01-IM3 lung_msk_pdx 203
2 Pre pemetrexed+bevacizumab+erlotinib 2 MSK_LX25 MSK_LX25 lung_msk_pdx 203
3 Pre BICALUTAMIDE 9 MPCPROJECT_0319 RP-1532_PCProject_0319_T1_v2_Exome_OnPrem mpcproject_broad_2021 0
4 Pre BICALUTAMIDE 9 MPCPROJECT_0130 RP-1532_PCProject_0130_T1_v3_Exome_OnPrem mpcproject_broad_2021 0
... ... ... ... ... ... ... ...
12784 Pre Vemurafenib 11 TCGA-GN-A4U7 TCGA-GN-A4U7-06 skcm_tcga_pan_can_atlas_2018 163
12785 Pre TARCEVA/ERLOTINIB 1 TCGA-18-3412 TCGA-18-3412-01 lusc_tcga_pan_can_atlas_2018 0
12786 Pre CPT-11 1 TCGA-38-4632 TCGA-38-4632-01 luad_tcga_pan_can_atlas_2018 0
12787 Pre ZOLEDRONIC ACID 1 MPCPROJECT_0031 RP-1532_PCProject_0031_T1_v2_Exome_OnPrem mpcproject_broad_2021 0
12788 Post carboplatin+pemetrexed (maintenance) +bevacizumab 1 MSK_LX301 MSK_LX301B lung_msk_pdx 1786

12789 rows × 7 columns