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:
MutationsClass 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 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___cbioportalcBioPortal API object (post-init).
_dataList of cBioPortal sub-API queries; None if ID not found (post-init).
_dfDataFrame of cBioPortal data; None if DataFrame could not be created (post-init).
_df_filterDataFrame of kinase missense mutations; None if DataFrame could not be created (post-init).
bool_prefixAdd prefix to ABC column names if True; default is True.
from_cacheWhether the most recent response was served from requests-cache.
instancecBioPortal instance.
list_col_explodeList of columns to explode in convert_api_query_to_dataframe; None if no columns to explode (post-init).
pathfilePath to load dataframe from CSV file; if None, regenerate (post-init).
Path to CSV file for filtered kinase missense mutations; default is None.
query_datetimeUTC datetime the underlying network query was made (cache creation time if served from cache).
BLOSUM matrix to use for mutation analysis; default is "BLOSUM80".
urlcBioPortal API URL.
"WHR1"}.
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.