mkt.databases.cbioportal.KinaseMissenseMutations

class mkt.databases.cbioportal.KinaseMissenseMutations(bool_prefix: bool = True, list_col_explode: list[str] | None = None, pathfile: str | None = None, dict_replace: dict[str, str] = <factory>, str_blosom: str = 'BLOSUM80', pathfile_filter: str | None = None, *, study_id: str)[source]

Bases: Mutations

Class to get kinase mutations from a cBioPortal study.

__init__(bool_prefix: bool = True, list_col_explode: list[str] | None = None, pathfile: str | None = None, dict_replace: dict[str, str] = <factory>, str_blosom: str = 'BLOSUM80', pathfile_filter: 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 mutations 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.

annotate_kinase_regions(df, dict_in)

Annotate kinase regions in a DataFrame of mutations.

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.

convert_log_and_truncate(x, bool_log10, ...)

Convert a value to log10 and truncate if necessary.

filter_single_aa_missense_mutations(df)

Filter DataFrame for single amino acid missense mutations.

generate_pivot_table(colname, bool_onehot, ...)

Generate a pivot table of missense mutation counts by KLIFS region.

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_kinase_missense_mutations([bool_save])

Get cBioPortal kinase mutations and optionally save as a CSV file.

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_hgnc_gene_names(list_hgnc, dict_kinase)

Query HGNC gene names from a DataFrame of mutations.

query_sub_api()

Get mutations cBioPortal data.

regenerate_dataframe()

Regenerate DataFrame from API query.

remove_mismatched_uniprot_mutations(df, dict_in)

Remove mutations with mismatches to canonical Uniprot sequence.

return_adjusted_colname(colname[, prefix])

Return adjusted column name based on bool_prefix.

set_api_key()

Set API key for cBioPortal API.

try_except_middle_int(str_in)

Try to convert string [1:-1] characters to integer.

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).

_df_filter

DataFrame of kinase missense mutations; None if DataFrame could not be created (post-init).

bool_prefix

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

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).

pathfile_filter

Path to CSV file for filtered kinase missense mutations; default is None.

query_datetime

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

str_blosom

BLOSUM matrix to use for mutation analysis; default is "BLOSUM80".

url

cBioPortal API URL.

dict_replace

"WHR1"}.

study_id

cBioPortal study ID.

__init__(bool_prefix: bool = True, list_col_explode: list[str] | None = None, pathfile: str | None = None, dict_replace: dict[str, str] = <factory>, str_blosom: str = 'BLOSUM80', pathfile_filter: str | None = None, *, study_id: str) None
annotate_kinase_regions(df: DataFrame, dict_in: dict) DataFrame[source]

Annotate kinase regions in a DataFrame of mutations.

Parameters:
  • df (pd.DataFrame) – DataFrame of mutations

  • dict_in (dict) – Dictionary of HGNC gene names to KinaseInfo objects

Returns:

DataFrame of mutations with kinase regions annotated

Return type:

pd.DataFrame

static convert_log_and_truncate(x: int | float | str, bool_log10: bool, max_value: int | None) int | float | str[source]

Convert a value to log10 and truncate if necessary.

Parameters:
  • x (int | float | str) – Value to convert to log10

  • bool_truncate (bool) – Truncate the value to max_value if True; default is True

  • max_value (int) – Maximum value to truncate to if bool_truncate is True; default is 1.5

Returns:

Log10 converted value if numeric, otherwise original value; truncated to max_value if bool_truncate is True

Return type:

int | float | str

dict_replace: dict[str, str]

“WHR1”}.

Type:

Dictionary mapping cBioPortal to mkt gene names for mismatches; default is {“STK19”

filter_single_aa_missense_mutations(df: DataFrame) DataFrame[source]

Filter DataFrame for single amino acid missense mutations.

Parameters:

df (pd.DataFrame) – DataFrame of mutations

Returns:

DataFrame of single amino acid missense mutations

Return type:

pd.DataFrame

generate_pivot_table(colname: str, bool_onehot: bool, bool_log10: bool, max_value: int | None) DataFrame[source]

Generate a pivot table of missense mutation counts by KLIFS region.

Parameters:
  • colname (str) – Column name to pivot on; default is “klifs_region”

  • bool_onehot (bool) –

    Column name to pivot on; default is “klifs_region” (just counts);
    if “blosum_penalty”, the mean BLOSUM penalty is used instead;

    if starts with “_”, it is treated as a one-hot encoded column

  • bool_log10 (bool) – Convert counts to log10 if True; default is True

  • max_value (int | None) –

    Maximum value to truncate the log10 counts to if bool_log10 is True;

    if None, no truncation is applied; default is None

Returns:

Pivot table of missense mutation counts by KLIFS region

Return type:

pd.DataFrame

get_kinase_missense_mutations(bool_save=False) None | DataFrame[source]

Get cBioPortal kinase mutations and optionally save as a CSV file.

Parameters:

bool_save (bool) – Save cBioPortal kinase mutations as a CSV file if True

Returns:

DataFrame of kinase mutations if successful, otherwise None

Return type:

pd.DataFrame | None

pathfile_filter: str | None = None

Path to CSV file for filtered kinase missense mutations; default is None.

query_hgnc_gene_names(list_hgnc: list[str], dict_kinase: dict[str, object]) dict[str, str | None][source]

Query HGNC gene names from a DataFrame of mutations.

Parameters:
  • list_hgnc (list[str]) – List of HGNC gene names to query

  • dict_kinase (dict[str, object]) – Dictionary mapping kinase names to KinaseInfo objects

Returns:

Dictionary mapping HGNC gene names from cBioPortal to Uniprot IDs

Return type:

dict

remove_mismatched_uniprot_mutations(df: DataFrame, dict_in: dict) DataFrame[source]

Remove mutations with mismatches to canonical Uniprot sequence.

Parameters:
  • df (pd.DataFrame) – DataFrame of mutations

  • dict_in (dict) – Dictionary of HGNC gene names to Uniprot IDs

Returns:

DataFrame of mutations with mismatched Uniprot IDs removed

Return type:

pd.DataFrame

str_blosom: str = 'BLOSUM80'

BLOSUM matrix to use for mutation analysis; default is “BLOSUM80”.

study_id: str

cBioPortal study ID.

static try_except_middle_int(str_in)[source]

Try to convert string [1:-1] characters to integer.

Parameters:

str_in (str) – String to convert to integer

Returns:

Integer if successful, otherwise None

Return type:

int | None