mkt.databases.cbioportal.ClinicalSample

class mkt.databases.cbioportal.ClinicalSample(bool_prefix: bool = True, list_col_explode: list[str] | None = None, pathfile: str | None = None, *, study_id: str)[source]

Bases: Clinical

Class to get sample-level clinical information from a cBioPortal study.

__init__(bool_prefix: bool = True, list_col_explode: list[str] | None = None, pathfile: str | None = None, *, study_id: str) None

Methods

__eq__(other)

Return self==value.

__init__([bool_prefix, list_col_explode, ...])

__post_init__()

Post-initialization to get clinical info from cBioPortal.

_stamp_from_response(res)

Record query datetime + cache provenance from a requests-cache response.

_stamp_now()

Record current UTC datetime; cache provenance unknown.

check_entity_id()

Check if the study ID is valid.

check_response(res)

Check the response status code for errors.

convert_api_query_to_dataframe()

Convert API to query to a dataframe.

get_cbioportal()

Get cBioPortal API object.

get_data()

Get cBioPortal data.

get_df()

Get DataFrame of cBioPortal data in dataframe.

get_entity_id()

Get cBioPortal study ID.

get_instance()

Get cBioPortal instance.

get_url()

Get cBioPortal API URL.

load_from_csv([str_path])

Load DataFrame from CSV file.

maybe_get_token()

Get API token, if available.

query_api()

Query a Swagger API and return result.

query_sub_api()

Get clinical info cBioPortal data.

regenerate_dataframe()

Regenerate DataFrame from API query.

return_adjusted_colname(colname[, prefix])

Return adjusted column name based on bool_prefix.

set_api_key()

Set API key for cBioPortal API.

Attributes

__dataclass_fields__

__dataclass_params__

__match_args__

_cbioportal

cBioPortal API object (post-init).

_data

List of cBioPortal sub-API queries; None if ID not found (post-init).

_df

DataFrame of cBioPortal data; None if DataFrame could not be created (post-init).

bool_prefix

Add prefix to ABC column names if True; default is True.

bool_sample

If True, return sample-level clinical data; if False, return patient-level clinical data

from_cache

Whether the most recent response was served from requests-cache.

instance

cBioPortal instance.

list_col_explode

List of columns to explode in convert_api_query_to_dataframe; None if no columns to explode (post-init).

pathfile

Path to load dataframe from CSV file; if None, regenerate (post-init).

query_datetime

UTC datetime the underlying network query was made (cache creation time if served from cache).

url

cBioPortal API URL.

study_id

cBioPortal study ID.

__init__(bool_prefix: bool = True, list_col_explode: list[str] | None = None, pathfile: str | None = None, *, study_id: str) None
bool_sample: bool = True

If True, return sample-level clinical data; if False, return patient-level clinical data

study_id: str

cBioPortal study ID.