### Install The Kinase Library Source: https://github.com/thekinaselibrary/kinase-library/blob/master/README.md Install the kinase-library package using pip. This command fetches and installs the latest stable version from PyPI. ```bash pip install kinase-library ``` -------------------------------- ### Import Kinase Library and Pandas Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/data.ipynb Initializes the kinase_library and pandas for data manipulation. Ensure these libraries are installed. ```python import kinase_library as kl import pandas as pd ``` -------------------------------- ### Load Libraries and Initialize Environment Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/differential_phosphorylation.ipynb Imports necessary libraries and sets up the environment for autoreloading. This is a standard setup for interactive analysis. ```python import os import kinase_library as kl import pandas as pd import matplotlib.pyplot as plt %load_ext autoreload %autoreload 2 ``` -------------------------------- ### Import kinase_library Source: https://context7.com/thekinaselibrary/kinase-library/llms.txt Import the library for use in Python scripts. This is typically done after installation. ```python import kinase_library as kl ``` -------------------------------- ### Import Libraries Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/binary_enrichment.ipynb Imports necessary libraries for data manipulation and analysis. Ensure these are installed in your environment. ```python import kinase_library as kl import pandas as pd import matplotlib.pyplot as plt ``` -------------------------------- ### Initialize PhosphoProteomics Data and Calculate Percentiles Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/mea.ipynb Initializes the PhosphoProteomics data object and calculates percentile ranks for 'ser_thr' substrates. This is a one-time setup step. ```python pps_data = kl.PhosphoProteomics(all_inhibitors_data, seq_col='PTM_seq') ser_thr_percentiles = pps_data.percentile('ser_thr', values_only=True) ``` -------------------------------- ### Get Kinase Percentiles for a Substrate Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/substrate.ipynb Calculate the percentile ranks for a substrate against a list of kinases. This indicates how the substrate's score compares to others. ```python s.percentile() ``` -------------------------------- ### Get Tyrosine Kinase Matrices Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/data.ipynb Retrieves all matrices associated with tyrosine kinases. Ensure the kinase library is initialized. ```python kl.get_all_matrices('tyrosine', non_canonical=True) ``` -------------------------------- ### Get Kinase Ranks for a Substrate Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/substrate.ipynb Calculate the rank of a substrate against a list of kinases. The `method` parameter can be set to 'percentile' to rank based on percentile. ```python s.rank(method='percentile') ``` -------------------------------- ### Get Densitometry Data Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/data.ipynb Retrieves densitometry data for a specific kinase. ```APIDOC ## get_densitometry ### Description Retrieves densitometry data for a given kinase. ### Method Signature `kl.get_densitometry(kinase_name: str)` ### Parameters - **kinase_name** (str) - Required - The name of the kinase for which to retrieve densitometry data. ### Example Usage ```python densitometry_data = kl.get_densitometry('SRPK1') print(densitometry_data) ``` ### Response Example ``` 1 2 3 4 5 \ A 28110774.26 5533898.03 5.190162e+07 14014265.68 38944077.57 B 9113697.57 7792375.59 1.000829e+08 24395453.76 19379665.48 C 9414055.77 15355795.30 9.289063e+06 16297080.15 9219070.57 D 7605444.94 8319717.21 6.825433e+06 7957765.63 6707409.25 E 6819382.21 7903154.81 4.863507e+06 11464585.20 7215988.18 F 7658431.00 7347649.44 6.778664e+06 19003952.80 5953528.54 G 8618142.81 10368831.56 5.796659e+06 13932166.37 12523935.64 H 6708412.12 9377821.41 7.973707e+06 8087493.82 14251639.08 I 14394405.56 24678756.28 1.246738e+08 18740727.56 26622947.63 J 15677798.20 17317358.76 1.363687e+07 15632294.54 26868111.29 K 9488256.61 10298226.29 6.084842e+06 20103273.20 14748246.72 L 10337170.17 7921481.05 4.176594e+06 7201788.69 5145077.20 ``` ``` -------------------------------- ### Get Phosphoproteome Information Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/data.ipynb Retrieves metadata and statistics for all available phosphoproteomes, including dates, descriptions, and site counts. No arguments are required. ```python kl.get_phosphoproteomes_info() ``` -------------------------------- ### Set Up Plotting for Multiple Comparisons Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/mea.ipynb Configures matplotlib for plotting within a Jupyter Notebook and defines a list of inhibitors for subsequent bubblemap visualization. This setup is useful for comparing results across multiple experimental conditions. ```python %matplotlib inline plt.rcParams['figure.figsize'] = [10, 5] #For Jupyter Notebook # inhibitors = all_inhibitors_data.columns[:62] inhibitors = ['MEKi_PD0325901_0-1', 'MEKi_PD0325901_1', 'MEKi_Cobimetinib_0-1', 'MEKi_Cobimetinib_1', 'MEKi_U0126_0-1', 'MEKi_U0126_1'] ``` -------------------------------- ### Get Densitometry Data for SRPK1 Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/data.ipynb Fetches densitometry data for the kinase SRPK1. The result is returned as a pandas DataFrame, suitable for further analysis or visualization. ```python kl.get_densitometry('SRPK1') ``` -------------------------------- ### Get Enriched Substrates for Multiple Kinases Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/differential_phosphorylation.ipynb Retrieves enriched substrates for a list of specified kinases. This function allows for the analysis of multiple kinases simultaneously. ```python braf_inh_24h_enr_res.enriched_subs(kinases=['ERK1','ERK2','ERK5','ERK7'], activity_type='inhibited') ``` -------------------------------- ### Get All Kinome Information Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/data.ipynb Retrieves a DataFrame containing information for all kinases in the library. This includes details like UniProt ID, gene name, and kinase type. ```python kl.get_kinome_info() ``` -------------------------------- ### Get Enriched Substrates for a Specific Kinase Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/differential_phosphorylation.ipynb Retrieves enriched substrates for a specific kinase, returning results as a pandas DataFrame. This can be used to explore downstream effects of kinase activity. ```python braf_inh_24h_enr_res.enriched_subs(kinases='ERK2', activity_type='inhibited', as_dataframe=True) ``` -------------------------------- ### Look Up Kinase Metadata with kl.get_kinase_info() Source: https://context7.com/thekinaselibrary/kinase-library/llms.txt Use kl.get_kinase_info() to get metadata for a kinase. You can specify name_type='gene' to look up by gene name. kl.get_kinase_type() returns the kinase type ('ser_thr' or 'tyrosine'). ```python import kinase_library as kl info = kl.get_kinase_info('SRPK1') print(info['UNIPROT_ID']) # Q96SB4 print(info['FAM']) # CMGC print(info['ENSEMBL_GENE_ID']) # ENSG00000096063 # Look up by gene name instead of matrix name info_by_gene = kl.get_kinase_info('SRPK1', name_type='gene') # Get kinase type ('ser_thr' or 'tyrosine') ktype = kl.get_kinase_type('EGFR') # 'tyrosine' ``` -------------------------------- ### Get Kinase Object with kl.get_kinase() Source: https://context7.com/thekinaselibrary/kinase-library/llms.txt Use `kl.get_kinase()` as a factory function to retrieve a `Kinase` object by its name. It automatically detects the kinase type and loads the appropriate matrix. You can specify `mat_type` if needed. ```python import kinase_library as kl akt1 = kl.get_kinase('AKT1') # ser/thr kinase, auto-detected egfr = kl.get_kinase('EGFR') # tyrosine kinase srpk1 = kl.get_kinase('SRPK1', mat_type='log2') ``` -------------------------------- ### Get Kinase Family Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/data.ipynb Retrieves the family classification of a specified kinase. Requires the kinase identifier. ```python kl.get_kinase_family('CDK1') ``` -------------------------------- ### Initialize Substrate Object Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/substrate.ipynb Instantiate a Substrate object with a given amino acid sequence. The sequence can represent a protein and may include phosphorylation sites indicated by lowercase letters. Phosphopriming can be enabled by setting `pp=True`. ```python import kinase_library as kl s = kl.Substrate('PSVEPPLsQETFSDL') #p53 S33 ``` ```python s_pp = kl.Substrate('QQQSYLDsGIHsGAT', pp=True) #beta-catenin (CTNNB1) S33 ``` -------------------------------- ### Substrate Initialization Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/substrate.ipynb Initialize a Substrate object with a given amino acid sequence. Phosphorylation sites are indicated by lowercase letters. The `pp` parameter can be set to `True` to incorporate phosphopriming information. ```APIDOC ## Substrate Initialization ### Description Initializes a Substrate object with a given amino acid sequence. Phosphorylation sites are indicated by lowercase letters. The `pp` parameter can be set to `True` to incorporate phosphopriming information. ### Method `kl.Substrate(sequence, pp=False)` ### Parameters * **sequence** (str) - Required - The amino acid sequence of the substrate. * **pp** (bool) - Optional - If True, incorporates phosphopriming information. Defaults to False. ### Request Example ```python import kinase_library as kl s = kl.Substrate('PSVEPPLsQETFSDL') # p53 S33 s_pp = kl.Substrate('QQQSYLDsGIHsGAT', pp=True) # beta-catenin (CTNNB1) S33 ``` ``` -------------------------------- ### Create PhosphoProteomics Object (Default Settings) Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/phosphoproteomics.ipynb Initializes a PhosphoProteomics object with phosphosite data. Sequences are processed according to default rules: peripheral s/t/y are capitalized, central phosphoacceptors are lowercased, and sequences are trimmed or padded to 15-mers. Invalid entries are omitted. ```python pps = kl.PhosphoProteomics(phosphosites_data, seq_col='sequence window') pps.data.head() ``` -------------------------------- ### Get Scored Phosphoproteome (Serine/Threonine) Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/data.ipynb Retrieves the scored phosphoproteome data specifically for serine and threonine kinases. ```APIDOC ## get_scored_phosphoproteome ### Description Retrieves the scored phosphoproteome data, with an option to filter by kinase type. ### Method ```python kl.get_scored_phosphoproteome(kin_type='ser_thr') ``` ### Parameters #### Query Parameters - **kin_type** (string) - Required - Specifies the type of kinases to retrieve data for (e.g., 'ser_thr'). ``` -------------------------------- ### Get Inhibited Kinases Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/differential_phosphorylation.ipynb Retrieves a list of kinases that were inhibited. Use the `save_to_excel` flag to directly save the results. ```python braf_inh_24h_enr_res.inhibited_kins() ``` -------------------------------- ### Load Phosphoproteomics Data with kl.PhosphoProteomics.from_file() Source: https://context7.com/thekinaselibrary/kinase-library/llms.txt Use kl.PhosphoProteomics.from_file() to load data directly from various file formats. Specify the separator and sequence column if needed. ```python import kinase_library as kl # Tab-separated file pps = kl.PhosphoProteomics.from_file('my_data.txt', sep='\t', seq_col='Sequence') # CSV pps = kl.PhosphoProteomics.from_file('my_data.csv', seq_col='Sequence') # Parquet pps = kl.PhosphoProteomics.from_file('my_data.parquet') ``` -------------------------------- ### Initialize Kinase Object Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/kinase.ipynb Initiate a Kinase object by calling an existing kinase from the library using its name. ```python kin = kl.get_kinase('AKT1') ``` -------------------------------- ### kl.PhosphoProteomics.from_file() Source: https://context7.com/thekinaselibrary/kinase-library/llms.txt Class method to load phosphoproteomics data directly from a file (TSV, CSV, Parquet). ```APIDOC ## kl.PhosphoProteomics.from_file() ### Description Load phosphoproteomics data directly from a file (TSV, CSV, Parquet) into a `PhosphoProteomics` object. ### Method `kl.PhosphoProteomics.from_file(filepath: str, sep: str = '\t', seq_col: str, **kwargs)` ### Parameters #### Path Parameters - **filepath** (str) - The path to the data file. - **sep** (str, optional) - The separator for the file. Defaults to '\t' (tab). - **seq_col** (str) - The name of the column containing 15-mer peptide sequences. - **kwargs** - Additional keyword arguments to pass to the `PhosphoProteomics` constructor. ### Request Example ```python import kinase_library as kl # Tab-separated file pps = kl.PhosphoProteomics.from_file('my_data.txt', sep='\t', seq_col='Sequence') # CSV pps = kl.PhosphoProteomics.from_file('my_data.csv', seq_col='Sequence') # Parquet pps = kl.PhosphoProteomics.from_file('my_data.parquet') ``` ### Response Returns a `PhosphoProteomics` object loaded with data from the specified file. ``` -------------------------------- ### Get All Serine/Threonine Kinases Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/data.ipynb Retrieves a list of all kinases classified as serine/threonine. This function returns a list of kinase names. ```python kl.get_kinase_list('ser_thr') ``` -------------------------------- ### Create PhosphoProteomics Object (Phosphopriming Enabled) Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/phosphoproteomics.ipynb Initializes a PhosphoProteomics object with phosphopriming enabled (pp=True). This preserves the lowercase of peripheral s/t/y, indicating phosphopriming. Other sequence processing steps remain the same. ```python pps_pp = kl.PhosphoProteomics(phosphosites_data, seq_col='sequence window', pp=True) pps_pp.data.head() ``` -------------------------------- ### Get Scored Phosphoproteome (Tyrosine) with Info Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/data.ipynb Retrieves the scored phosphoproteome data for tyrosine kinases, including additional information. ```APIDOC ## get_scored_phosphoproteome ### Description Retrieves the scored phosphoproteome data, with options to filter by kinase type and include additional information. ### Method ```python kl.get_scored_phosphoproteome(kin_type='tyrosine', with_info=True) ``` ### Parameters #### Query Parameters - **kin_type** (string) - Required - Specifies the type of kinases to retrieve data for (e.g., 'tyrosine'). - **with_info** (boolean) - Optional - If True, includes additional information in the response. ``` -------------------------------- ### Initialize RankedPhosData Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/mea.ipynb Initializes the RankedPhosData object with phosphoproteomics data. Specify the column containing the treatment data for ranking and the column with PTM sequences. ```python treatment = 'MEKi_Cobimetinib_0-1' #MEK inhibitor ranked_phos = kl.RankedPhosData(dp_data=all_inhibitors_data, rank_col=treatment, seq_col='PTM_seq') ``` -------------------------------- ### Get Kinase Type Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/data.ipynb Retrieves the specific type (e.g., 'ser_thr', 'tyrosine') of a given kinase. Requires the kinase identifier. ```python kl.get_kinase_type('AKT1') ``` -------------------------------- ### Load Libraries and Extensions Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/mea.ipynb Imports necessary Python libraries and loads Jupyter extensions for code reloading. ```python import os import kinase_library as kl import numpy as np import pandas as pd import matplotlib.pyplot as plt %load_ext autoreload %autoreload 2 ``` -------------------------------- ### Get Specific Kinase Information Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/data.ipynb Fetches detailed information for a single kinase by its identifier. Requires the kinase identifier as an argument. ```python kl.get_kinase_info('EGFR') ``` -------------------------------- ### Analyze Kinase Specificity with kl.Kinase Source: https://context7.com/thekinaselibrary/kinase-library/llms.txt Load a Kinase object using `kl.get_kinase()` to analyze its substrate specificity. Use `score()` to score a list of substrates, `percentile()` for percentile ranks, and `plot_data()` for combined visualizations (sequence logo, heatmap, S/T favorability). `heatmap()` and `seq_logo()` generate specific visualizations. `get_value()` retrieves a single matrix value. ```python import kinase_library as kl # Load a kinase by name (auto-detects type and loads norm/log2 matrix) kin = kl.get_kinase('AKT1') print(kin.name) # 'AKT1' print(kin.kin_type) # 'ser_thr' print(kin.family) # 'AGC' print(kin.st_fav) # {'S': 0.35, 'T': 0.65} (S/T favorability) # Score a list of substrates for this kinase substrates = ['RARNTFIsSFSNTKE', 'VVGARRssWRVISsI', 'LHCLRRDsHKIDNYL'] scores = kin.score(substrates, log2_score=True) print(scores) # RARNTFIsSFSNTKE 3.45 # VVGARRssWRVISsI -1.21 # LHCLRRDsHKIDNYL 0.87 # Percentile rank for each substrate percentiles = kin.percentile(substrates) print(percentiles) # RARNTFIsSFSNTKE 96.4 # VVGARRssWRVISsI 32.1 # LHCLRRDsHKIDNYL 58.7 # Visualize: sequence logo + heatmap + S/T favorability in one figure kin.plot_data(seq_logo=True, heatmap=True, st_fav=True, save_fig='AKT1_profile.png') # Matrix heatmap only kin.heatmap(mat_scale='log', title='AKT1 Substrate Specificity') # Sequence logo only kin.seq_logo(logo_type='ratio_to_median') # Retrieve a single matrix value at position -2, amino acid R val = kin.get_value(pos=-2, aa='R') print(val) # e.g. 0.3147 ``` -------------------------------- ### Get Ser/Thr Phosphoacceptor Favorability Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/data.ipynb Retrieves the favorability of Ser/Thr phosphoacceptors. This function requires a list of kinases, which can be obtained using `kl.get_kinase_list('ser_thr')`. ```python kl.get_st_fav(kinases=kl.get_kinase_list('ser_thr')) ``` -------------------------------- ### Get Kinase List Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/data.ipynb Retrieves a list of kinases. Can be filtered by type, family, and subtype. The `non_canonical` parameter can be used to include non-canonical kinases. ```APIDOC ## get_kinase_list ### Description Retrieves a list of kinases based on specified criteria. ### Method Signature `kl.get_kinase_list(kinase_type: str, family: Optional[str] = None, subtype: Optional[str] = None, non_canonical: Optional[bool] = False)` ### Parameters - **kinase_type** (str) - Required - The type of kinase to retrieve (e.g., 'ser_thr', 'tyrosine'). - **family** (str, optional) - Filters kinases by a specific family (e.g., 'CMGC'). Defaults to None. - **subtype** (str, optional) - Filters kinases by a specific subtype (e.g., 'nRTK'). Defaults to None. - **non_canonical** (bool, optional) - Whether to include non-canonical kinases. Defaults to False. ### Example Usage ```python # Get all serine/threonine kinases ser_thr_kinases = kl.get_kinase_list('ser_thr') # Get CMGC family serine/threonine kinases cmgc_kinases = kl.get_kinase_list('ser_thr', family='CMGC') # Get non-canonical tyrosine kinases non_canonical_tyrosine = kl.get_kinase_list('tyrosine', subtype='nRTK', non_canonical=True) ``` ``` -------------------------------- ### Combine MEA Enrichment Results and Plot Bubblemap Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/mea.ipynb Combines MEA enrichment results and generates a bubble map visualization. Use this to visualize significant kinase-substrate relationships. Ensure 'kl_en_res' is pre-defined. ```python lff_data,pval_data = kl.combine_mea_enrichment_results(kl_en_res, adj_pval=True) kl.plot_bubblemap(lff_data=lff_data, pval_data=pval_data, max_pval_size=None, num_panels=4, only_sig_kins=True, title='MEK Inhibitors', sig_pval=0.1, bubblesize_range=(50,200), max_window=False, constrained_layout=True) ``` -------------------------------- ### Score and Predict Substrates with kl.Substrate Source: https://context7.com/thekinaselibrary/kinase-library/llms.txt Create a Substrate object from a peptide sequence to score and predict kinase activity. Use `pp=True` if phospho-priming residues are present. The `score()` method returns log2-scaled scores, `percentile()` returns percentile ranks, and `predict()` provides a comprehensive table. `un_primed()` returns the sequence with all phospho-residues replaced by unmodified ones. ```python import kinase_library as kl # 'T' at position 8 (index 7) is the phosphoacceptor; lowercase 't' = phospho-primed residue seq = 'PFADRRVtPXYsPKH' sub = kl.Substrate(seq, pp=True) # pp=True: phospho-priming residues present print(sub.kin_type) # 'ser_thr' print(sub.phos_res) # 't' # Score against all serine/threonine kinases (log2 scale) scores = sub.score() print(scores.head(5)) # PKA 5.2341 # AKT1 4.8932 # ... # Percentile rank against the PhosphoSitePlus phosphoproteome percentiles = sub.percentile(kinases=['AKT1', 'AKT2', 'PKA']) print(percentiles) # AKT1 94.21 # AKT2 91.05 # PKA 87.63 # Full prediction table: Score, Score Rank, Percentile, Percentile Rank prediction = sub.predict(sort_by='percentile') print(prediction.head(10)) # Score Score Rank Percentile Percentile Rank # AKT1 4.8932 2 94.21 1 # AKT2 4.7101 3 91.05 2 # ... # Rank by score only rank = sub.rank(method='score', sort_by='value') print(rank.head(5)) # Get the un-primed sequence (all phospho-residues replaced with unmodified) print(sub.un_primed()) # 'PFADRRVTPXYsPKH' -> 'PFADRRVTPXYSPKH' ``` -------------------------------- ### Create EnrichmentData Object Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/binary_enrichment.ipynb Initializes an EnrichmentData object with the foreground substrates and specifies the column containing flanking sequences for analysis. If no background is provided, the kinase library's default phosphoproteome will be used. ```python enrich_data = kl.EnrichmentData(foreground=fg_subs, fg_seq_col='site.flanking') ``` -------------------------------- ### Get Kinase Scores for a Substrate Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/substrate.ipynb Calculate the phosphorylation scores for a substrate against a list of kinases. The `kinases` parameter can be used to filter for specific kinases. ```python s.score() ``` -------------------------------- ### Load Custom Kinase Matrix from File Source: https://context7.com/thekinaselibrary/kinase-library/llms.txt Load a custom kinase matrix from a TSV file into a `kl.Kinase` object. Allows specifying matrix type, name, and other parameters for custom analysis. ```python import kinase_library as kl # Load a custom TSV matrix file as a kl.Kinase object custom_kin = kl.get_matrix_from_file( file='my_custom_kinase_matrix.tsv', name='MY_KIN', kin_type='ser_thr', mat_type='norm', # 'densitometry', 'raw', 'norm', 'log2', or 'customized' pp=True, transpose=False ) print(custom_kin.name) custom_kin.heatmap() custom_kin.seq_logo() ``` -------------------------------- ### Plot Volcano and Generate Kinome Tree Source: https://context7.com/thekinaselibrary/kinase-library/llms.txt Basic plotting functions for volcano plots and kinome trees using results objects. ```python results.plot_volcano(sig_lff=0, sig_pval=0.05, save_fig='volcano_binary.png') ``` ```python results.generate_tree('kinome_tree.png', sort_by='fisher_pval', filter_top=20) ``` -------------------------------- ### Get Raw Kinase Matrix Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/data.ipynb Retrieves the raw matrix for a specific kinase. Specify the kinase name and optionally the matrix type and position range. ```python kl.get_matrix('SRPK1', mat_type='raw', pos=[-2,-1,1,2]) ``` -------------------------------- ### Initialize and Calculate Percentiles for Tyrosine Kinase Phosphoproteome Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/binary_enrichment.ipynb Loads the tyrosine phosphoproteome and calculates percentiles. This is a prerequisite for enrichment analysis. ```python kl_phosprot = kl.get_phosphoproteome(kin_type='tyrosine') kl_phosprot_pps = kl.PhosphoProteomics(kl_phosprot) kl_phosprot_tyr_percentiles = kl_phosprot_pps.percentile(kin_type='tyrosine', values_only=True) ``` -------------------------------- ### Get Serine/Threonine Favorability Scores for Kinases Source: https://context7.com/thekinaselibrary/kinase-library/llms.txt Retrieve serine/threonine favorability scores for one or multiple kinases. The `as_dict=True` argument returns scores as a dictionary. ```python import kinase_library as kl # S/T favorability for one kinase st = kl.get_st_fav('AKT1') print(st) # S T # AKT1 0.35 0.65 # Multiple kinases st_multi = kl.get_st_fav(['AKT1', 'AKT2', 'CDK2'], as_dict=True) # {'AKT1': {'S': 0.35, 'T': 0.65}, ...} ``` -------------------------------- ### kl.get_matrix_from_file() Source: https://context7.com/thekinaselibrary/kinase-library/llms.txt Loads a custom kinase matrix from a file into a Kinase object. ```APIDOC ## `kl.get_matrix_from_file()` — Load a custom kinase matrix ### Description This function loads a custom kinase matrix from a specified file path. It allows users to define the matrix name, type, and format, and returns a `kl.Kinase` object that can be used for further analysis and visualization. ### Parameters - **file** (str) - Path to the custom TSV matrix file. - **name** (str) - A name for the custom kinase object. - **kin_type** (str) - The type of kinases in the matrix ('ser_thr' or 'tyrosine'). - **mat_type** (str) - The type of matrix data ('densitometry', 'raw', 'norm', 'log2', or 'customized'). - **pp** (bool) - Whether to perform post-processing. - **transpose** (bool) - Whether to transpose the matrix. ### Usage ```python import kinase_library as kl # Load a custom TSV matrix file as a kl.Kinase object custom_kin = kl.get_matrix_from_file( file='my_custom_kinase_matrix.tsv', name='MY_KIN', kin_type='ser_thr', mat_type='norm', # 'densitometry', 'raw', 'norm', 'log2', or 'customized' pp=True, transpose=False ) print(custom_kin.name) custom_kin.heatmap() custom_kin.seq_logo() ``` ``` -------------------------------- ### Perform Binary Enrichment with Custom Background Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/binary_enrichment.ipynb Conducts kinase enrichment analysis using a custom background dataset. This allows for more specific comparisons. Ensure foreground and background data are properly formatted and relevant sequence columns are specified. ```python enrich_data = kl.EnrichmentData(foreground=fg_subs, background=phospho_signatures, fg_seq_col='site.flanking', bg_seq_col='site.flanking', suppress_warnings=True) kin_type = 'ser_thr' method = 'percentile_rank' thresh = 15 enrich_results = enrich_data.kinase_enrichment(kin_type=kin_type, kl_method=method, kl_thresh=thresh) enrich_results.plot_volcano(title='UV Light (upregulated)') ``` -------------------------------- ### Get Scored Phosphoproteome (Serine/Threonine) Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/data.ipynb Retrieves the scored phosphoproteome data specifically for serine/threonine kinases. This function is useful for analyzing phosphorylation sites on serine and threonine residues. ```python kl.get_scored_phosphoproteome(kin_type='ser_thr') ``` -------------------------------- ### Accessing Ser/Thr Substrate Data Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/phosphoproteomics.ipynb Once a PhosphoProteomics object is initialized, its 'ser_thr_data' attribute can be accessed to retrieve all identified Serine/Threonine substrates. This is useful for focused analysis of these specific phosphorylation sites. ```python print('Ser/Thr data:') pps.ser_thr_data ``` -------------------------------- ### Get Normalized Kinase Matrix Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/data.ipynb Retrieves the normalized matrix for a specific kinase. Specify the kinase name, matrix type, and optionally amino acid residues to filter by. ```python kl.get_matrix('ABL', mat_type='norm', aa=['R','K','H']) ``` -------------------------------- ### Calculate MEA for Tyrosine Kinases Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/mea.ipynb Initializes RankedPhosData and calculates MEA for tyrosine kinases using percentile rank. Use this for small datasets where traditional methods might be less effective. ```python treatment = 'EGFRi_Erlotinib_0-1' #EGFR inhibitor ranked_phos = kl.RankedPhosData(dp_data=all_inhibitors_data, rank_col=treatment, seq_col='PTM_seq') tyr_mea_res = ranked_phos.mea(kin_type='tyrosine', kl_method='percentile_rank', kl_thresh=8) ``` -------------------------------- ### Get Non-Receptor Tyrosine Kinases Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/data.ipynb Retrieves a list of non-receptor tyrosine kinases (nRTK), including non-canonical ones. This function is useful for studying RTK signaling pathways. ```python kl.get_kinase_list('tyrosine', subtype='nRTK', non_canonical=True) ``` -------------------------------- ### Batch Scoring with kl.PhosphoProteomics Source: https://context7.com/thekinaselibrary/kinase-library/llms.txt The kl.PhosphoProteomics class enables batch scoring of phosphoproteomics data. Initialize with a DataFrame containing a 'Sequence' column of 15-mers. Use methods like score(), percentile(), rank(), predict(), and promiscuity_index(). ```python import pandas as pd import kinase_library as kl # Load your phosphoproteomics data (must have a 'Sequence' column with 15-mers) df = pd.read_csv('my_phosphoproteomics.tsv', sep='\t') # df must have column 'Sequence' with 15-mer peptides centered on phosphoacceptor pps = kl.PhosphoProteomics(df, seq_col='Sequence', pp=False, drop_invalid_subs=True) # ser_thr substrates print(len(pps.ser_thr_substrates)) # number of S/T sites print(len(pps.tyrosine_substrates)) # number of Y sites # Score all ser_thr sites against all ser_thr kinases scored_df = pps.score(kin_type='ser_thr') # Returns original data + kinase score columns # Score only specific kinases scored_df = pps.score(kinases=['AKT1', 'AKT2', 'PKA']) # Percentile for all sites against the PhosphoSitePlus background percentile_df = pps.percentile(kin_type='ser_thr') # Full prediction table (scores + percentiles + ranks + promiscuity index) prediction_df = pps.predict( kin_type='ser_thr', metric=['score', 'percentile'], score_promiscuity_threshold=1, percentile_promiscuity_threshold=90 ) # Promiscuity index: count of kinases above threshold for each site promis = pps.promiscuity_index(kin_type='ser_thr', metric='percentile', threshold=90) ``` -------------------------------- ### kl.get_kinase_list() Source: https://context7.com/thekinaselibrary/kinase-library/llms.txt List all available kinases, with options to filter by type and family. ```APIDOC ## kl.get_kinase_list() ### Description List all available kinases, with options to filter by type ('ser_thr' or 'tyrosine') and family. ### Method `kl.get_kinase_list(kin_type: str, family: str = None, non_canonical: bool = False)` ### Parameters #### Path Parameters - **kin_type** (str) - The type of kinases to list. Options: 'ser_thr', 'tyrosine'. - **family** (str, optional) - The kinase family to filter by (e.g., 'AGC'). - **non_canonical** (bool, optional) - Whether to include non-canonical kinases. Defaults to False. ### Request Example ```python import kinase_library as kl # All serine/threonine kinases st_kinases = kl.get_kinase_list('ser_thr') print(len(st_kinases)) # 311 # Only AGC family agc_kinases = kl.get_kinase_list('ser_thr', family='AGC') print(agc_kinases[:5]) # ['AKT1', 'AKT2', 'AKT3', ...] # All tyrosine kinases including non-canonical tyr_kinases = kl.get_kinase_list('tyrosine', non_canonical=True) ``` ### Response Returns a list of kinase names. ``` -------------------------------- ### Get Processed Matrix Data Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/data.ipynb Retrieves matrix data for a specified gene. Supports raw, normalized, and log-scaled formats. Use this function to access processed expression data. ```python kl.get_matrix('SRPK1') ``` -------------------------------- ### Retrieve Raw Kinase Matrix with kl.get_matrix() Source: https://context7.com/thekinaselibrary/kinase-library/llms.txt Use kl.get_matrix() to fetch kinase matrices. Specify 'log2' for log2-scaled data (default) or 'norm' for linear-scale normalized data. You can also subset by amino acids and positions. ```python import kinase_library as kl # Get log2-scaled matrix (default) mat = kl.get_matrix('CDK2', mat_type='log2') print(mat.head()) # Get normalized (linear-scale) matrix mat_norm = kl.get_matrix('CDK2', mat_type='norm') # Get only specific amino acids and positions mat_subset = kl.get_matrix('CDK2', aa=['R','K','S','T','P'], pos=[-3,-2,-1,1,2,3]) ``` -------------------------------- ### Get CMGC Family Serine/Threonine Kinases Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/data.ipynb Filters the list of serine/threonine kinases to include only those belonging to the CMGC family. This is useful for targeted analysis within a specific kinase group. ```python kl.get_kinase_list('ser_thr', family='CMGC') ``` -------------------------------- ### kl.get_kinase() — Retrieve a Kinase object by name Source: https://context7.com/thekinaselibrary/kinase-library/llms.txt A factory function to load and initialize a `kl.Kinase` object for a specified kinase name from the bundled database. ```APIDOC ## `kl.get_kinase()` — Retrieve a `Kinase` object by name ### Description Convenience factory that loads the named kinase's matrix from the bundled database and returns a fully initialized `kl.Kinase` object. ### Parameters - **`name`** (str): The name of the kinase to load (e.g., 'AKT1', 'EGFR'). - **`mat_type`** (str, optional): The type of matrix to load ('log2' or 'norm'). Defaults to 'log2'. ### Returns - **`kl.Kinase`**: An initialized Kinase object. ### Example ```python import kinase_library as kl akt1 = kl.get_kinase('AKT1') # ser/thr kinase, auto-detected egfr = kl.get_kinase('EGFR') # tyrosine kinase srpk1 = kl.get_kinase('SRPK1', mat_type='log2') ``` ``` -------------------------------- ### Accessing Background Phosphoproteome Data Source: https://context7.com/thekinaselibrary/kinase-library/llms.txt Functions to retrieve and manage background phosphoproteome data, including listing available databases, getting unscored or pre-scored data, and adding custom phosphoproteomes. ```python import kinase_library as kl import pandas as pd # List available phosphoproteome databases print(kl.get_phosphoproteomes_list()) # ['PSP_07_2021', ...] # Get phosphoproteome data as DataFrame (unscored) phosprot = kl.get_phosphoproteome(kin_type='ser_thr') print(phosprot.shape) # (N, columns) # Get pre-scored phosphoproteome (substrates × kinases) scored = kl.get_scored_phosphoproteome(kin_type='ser_thr') print(scored.shape) # (N_sites, N_kinases) # Set a different phosphoproteome as default for percentile calculation kl.set_current_phosphoproteome('PSP_07_2021') kl.get_current_phosphoproteome() # prints current # Add a custom phosphoproteome for percentile reference custom_prot = pd.read_csv('my_proteome.tsv', sep=' ') kl.add_scored_phosphoproteome( phosprot_data=custom_prot, phosprot_name='my_custom_bg', seq_col='Sequence', description='My experiment background' ) ``` -------------------------------- ### Initialize and Access ScoredPhosphoProteome Data Source: https://context7.com/thekinaselibrary/kinase-library/llms.txt Instantiate a ScoredPhosphoProteome object and access serine/threonine and tyrosine kinase scores. This object is useful for analyzing pre-scored phosphoproteome data. ```python import kinase_library as kl spp = kl.ScoredPhosphoProteome(phosprot_name='PSP_07_2021') # Access scores for ser_thr kinases print(spp.ser_thr_scores.shape) # (N_sites, N_kinases) print(spp.ser_thr_scores.head()) # Access scores for tyrosine kinases print(spp.tyrosine_scores.shape) # Merge site data with scores merged = spp.merge_data_scores(kin_type='ser_thr') print(merged.columns.tolist()) ``` -------------------------------- ### Retrieve Downstream Substrates for a Kinase Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/mea.ipynb Use the `enriched_subs` method to get the downstream substrates for a specific kinase. The `save_to_excel` flag can be used to directly save the results. This method returns a pandas DataFrame. ```python ser_thr_mea_res.enriched_subs(kinases='RSK2')['RSK2'] ``` -------------------------------- ### Define Foreground Substrates Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/binary_enrichment.ipynb Filters the loaded phosphosite data to define the foreground set of substrates based on a specific pathway and site direction (upregulated or downregulated). ```python pathway = 'PERT-PSP_UV' #Phosphosites associated with UV light direction = 'u' #Upregulated phosphosites ('d' for downregulated phosphosites) fg_subs = phospho_signatures[(phospho_signatures['signature'] == pathway) & (phospho_signatures['site.direction'] == direction)] ``` -------------------------------- ### Predict Kinase Data with Phosphopriming Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/substrate.ipynb Calculate prediction data for a substrate, incorporating phosphopriming information by setting `pp=True` during Substrate initialization. This refines predictions by considering residues around the phosphoacceptor site. ```python s_pp.predict() ``` -------------------------------- ### Retrieve Full Kinome Information and Families Source: https://context7.com/thekinaselibrary/kinase-library/llms.txt Get a table containing information for all kinases or filter by kinase type (serine/threonine or tyrosine). Also retrieves available kinase families for a given type. ```python import kinase_library as kl # All kinase information all_info = kl.get_kinome_info() print(all_info.columns.tolist()) # ['MATRIX_NAME', 'GENENAME', 'TYPE', 'FAM', 'UNIPROT_ID', ...] # Filter by type st_info = kl.get_kinome_info(kin_type='ser_thr') tyr_info = kl.get_kinome_info(kin_type='tyrosine') # Get available kinase families families = kl.get_families('ser_thr') print(families) # ['AGC', 'CAMK', 'CMGC', 'CK1', 'STE', 'TK', 'TKL', 'Other'] ``` -------------------------------- ### Run Binary Enrichment Analysis Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/binary_enrichment.ipynb This snippet shows how to run a binary enrichment analysis. For tyrosine kinase enrichment, use nominal p-value with a significance threshold of 0.05. ```python from pathlib import Path from kinase_library.enrichment import binary_enrichment # Load data data_path = Path("/mnt/data/data/kinase_data/data.csv") # Load kinase-gene mapping kinase_gene_mapping_path = Path("/mnt/data/data/kinase_data/kinase_gene_mapping.csv") # Load gene-protein mapping gene_protein_mapping_path = Path("/mnt/data/data/kinase_data/gene_protein_mapping.csv") # Load protein-protein interaction network ppi_path = Path("/mnt/data/data/kinase_data/ppi.csv") # Load gene ontology annotations go_path = Path("/mnt/data/data/kinase_data/go.csv") # Load kinase-gene scores kinase_gene_scores_path = Path("/mnt/data/data/kinase_data/kinase_gene_scores.csv") # Run enrichment results = binary_enrichment( data_path=data_path, kinase_gene_mapping_path=kinase_gene_mapping_path, gene_protein_mapping_path=gene_protein_mapping_path, ppi_path=ppi_path, go_path=go_path, kinase_gene_scores_path=kinase_gene_scores_path, output_path=Path("/mnt/data/data/kinase_data/enrichment_results.csv"), significance_threshold=0.05, use_nominal_pvalue=True, n_jobs=1, random_state=42, ) ``` -------------------------------- ### List Available Phosphoproteomes Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/data.ipynb Retrieves a list of all available phosphoproteome datasets that can be used for analysis. No arguments are required. ```python kl.get_phosphoproteomes_list() ``` -------------------------------- ### Get Scored Phosphoproteome (Tyrosine) with Info Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/data.ipynb Retrieves the scored phosphoproteome data for tyrosine kinases, including associated information. Use this when you need to analyze tyrosine phosphorylation sites along with protein and gene identifiers. ```python kl.get_scored_phosphoproteome(kin_type='tyrosine', with_info=True) ``` -------------------------------- ### Save Binary Enrichment Analysis to Excel Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/binary_enrichment.ipynb To save the enrichment results to an Excel file, set `save_to_excel=True` and provide an `output_dir` and `file_prefix`. This method supports analyzing multiple kinases simultaneously, with each kinase's results in a separate sheet. ```python enrich_results.enriched_subs(kinases=['PKCE','PKCH','PKCI'], save_to_excel=True, output_dir='/Users/usr/Desktop/', file_prefix='Phorbol Ester subs') ``` -------------------------------- ### Perform Kinase Enrichment for Phorbol Ester Pathway Source: https://github.com/thekinaselibrary/kinase-library/blob/master/src/notebooks/binary_enrichment.ipynb Conducts kinase enrichment analysis for the phorbol ester pathway using serine/threonine kinase data. This example demonstrates analysis for a specific pathway and kinase type. ```python pathway = 'PERT-PSP_PHORBOL_ESTER' direction = 'u' fg_subs = phospho_signatures[(phospho_signatures['signature'] == pathway) & (phospho_signatures['site.direction'] == direction)] enrich_data = kl.EnrichmentData(foreground=fg_subs, fg_seq_col='site.flanking', suppress_warnings=True) kin_type = 'ser_thr' method = 'percentile_rank' thresh = 15 enrich_results = enrich_data.kinase_enrichment(kin_type=kin_type, kl_method=method, kl_thresh=thresh) enrich_results.plot_volcano(title='Phorbol Ester (upregulated)') ```