Using the CoRegTor package#
In this tutorial we demonstrate the use of the python package CoRegTor to predict coregulatory cluster for a target gene using gene expression data. We also describe how different parameter can be adjusted.
Installing the tool#
# Install coregtor if not already installed, then import it
try:
from coregtor import RunCoRegTor
except ImportError:
%pip install coregtor
from coregtor import RunCoRegTor
import io
import pandas as pd
import requests
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns
Preparing the data#
In this tutorial we directly fetch gene expression data for from the GTEx portal and the list of human transcription factors (from here). Please note that CoRegTor requires expression data with rows as samples and columns are gene names.
For simplicity, we use the “Description” col as gene name rather than their EnsemblId col name.
# 1. Fetch GTEx gene expression data
gtex_url = "https://storage.googleapis.com/adult-gtex/bulk-gex/v11/rna-seq/tpms-by-tissue/gene_tpm_adult_gtex_v11_liver.gct.gz"
response = requests.get(gtex_url, verify=False)
response.raise_for_status()
# 2. Load into DataFrame skipping GCT metadata rows
df_raw = pd.read_csv( io.BytesIO(response.content), sep='\t', skiprows=2, compression='gzip')
# 3. Drop Ensembl ID ('Name'), aggregate expression by Gene Symbol ('Description'), and transpose
df_matrix = (df_raw.drop(columns=['Name']).groupby('Description').mean().T)
df_matrix.columns.name = "Sample"
# 4. Fetch strict human TF list
tf_url = "https://raw.githubusercontent.com/aertslab/pySCENIC/master/resources/hs_hgnc_curated_tfs.txt"
tf_response = requests.get(tf_url, verify=False)
tf_response.raise_for_status()
# 5. Read strict TF list into DataFrame and convert to Python list
df_tfs = pd.read_csv(io.StringIO(tf_response.text),header=None,names=['TF_Symbol'])
# Extract cleaned list of sequence-specific TFs
tf_list = df_tfs['TF_Symbol'].dropna().str.strip().tolist()
df_matrix.head(2)
| Sample | 5S_rRNA | 5_8S_rRNA | 7SK | A1BG | A1BG-AS1 | A1CF | A2M | A2M-AS1 | A2ML1 | A2ML1-AS1 | ... | ZXDC | ZYG11A | ZYG11AP1 | ZYG11B | ZYX | ZYXP1 | ZZEF1 | ZZZ3 | hsa-mir-8069-1 | snoZ196 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| GTEX-111FC-1226-SM-HAV27 | 0.0 | 0.0 | 0.0 | 193.103 | 3.90616 | 20.3111 | 40.9842 | 3.22847 | 0.276122 | 0.0 | ... | 8.29606 | 0.537917 | 0.0 | 3.90875 | 26.7844 | 0.0 | 4.09897 | 1.95510 | 0.0 | 0.0 |
| GTEX-11DXY-0526-SM-5EGGQ | 0.0 | 0.0 | 0.0 | 442.279 | 5.75803 | 39.8927 | 208.5500 | 4.47446 | 0.127329 | 0.0 | ... | 13.84280 | 2.242130 | 0.0 | 10.09060 | 29.6591 | 0.0 | 5.29482 | 3.86624 | 0.0 | 0.0 |
2 rows × 73321 columns
print(f"{len(tf_list)} TFs")
found = len(set(tf_list).intersection(set(df_matrix.columns)))
print(f"{found} TFs found in data")
1390 TFs
1383 TFs found in data
import os
base = os.path.expandvars("$HOME/projects/coregtor-examples/input")
# df_matrix.to_csv(base/"liver_gtex_tpm.csv",index=False)
filtered_tf_list1 = filter_tfs_by_mean_and_variance(df_matrix, tf_list, min_mean =2, min_var = 0.75)
filtered_tf_list1
Total TFs evaluated: 1383
TFs passing filter (Mean >= 2, Variance >= 0.75): 569
['ADNP',
'ADNP2',
'AEBP2',
'AHCTF1',
'AHR',
'AR',
'ARID3B',
'ARID3C',
'ARID5A',
'ARID5B',
'ARNT',
'ASCL1',
'ATF1',
'ATF2',
'ATF3',
'ATF4',
'ATF5',
'ATF6',
'ATF6B',
'ATF7',
'ATOH7',
'ATOH8',
'BACH1',
'BATF',
'BBX',
'BCL6',
'BCL6B',
'BHLHA15',
'BHLHE40',
'BPTF',
'BRF2',
'CDC5L',
'CEBPA',
'CEBPB',
'CEBPD',
'CEBPG',
'CEBPZ',
'CENPB',
'CIC',
'CLOCK',
'CREB3',
'CREB3L2',
'CREB3L4',
'CREBL2',
'CREBZF',
'CREM',
'CTCF',
'CUX1',
'CUX2',
'CXXC1',
'DBP',
'DDIT3',
'DEAF1',
'DMRTA1',
'DNMT1',
'DNTTIP1',
'DR1',
'E2F3',
'E2F4',
'E2F6',
'E4F1',
'EBF4',
'EGR1',
'ELF1',
'ELF2',
'ELF3',
'ELK1',
'ELK3',
'ELK4',
'EPAS1',
'ERF',
'ESR1',
'ESRRA',
'ETS1',
'ETS2',
'ETV3',
'ETV5',
'ETV6',
'FBXL19',
'FLI1',
'FOS',
'FOSB',
'FOSL1',
'FOSL2',
'FOXA1',
'FOXA2',
'FOXA3',
'FOXF1',
'FOXJ2',
'FOXJ3',
'FOXK1',
'FOXK2',
'FOXN2',
'FOXN3',
'FOXO1',
'FOXO3',
'FOXO4',
'FOXP1',
'FOXP4',
'FOXQ1',
'GABPA',
'GATA4',
'GATA6',
'GLI4',
'GLIS2',
'GMEB2',
'GRHL1',
'GTF2B',
'GTF2I',
'GTF2IRD1',
'GTF3A',
'GZF1',
'HAND2',
'HBP1',
'HES1',
'HES4',
'HES6',
'HEY2',
'HEYL',
'HHEX',
'HIC1',
'HIF1A',
'HINFP',
'HIVEP1',
'HIVEP2',
'HLF',
'HLX',
'HMBOX1',
'HMG20A',
'HMG20B',
'HMGA1',
'HMGN3',
'HNF1A',
'HNF1B',
'HNF4A',
'HNF4G',
'HOMEZ',
'HSF1',
'HSF2',
'HSF4',
'IKZF5',
'IRF1',
'IRF2',
'IRF3',
'IRF5',
'IRF6',
'IRF7',
'IRF8',
'IRF9',
'JAZF1',
'JDP2',
'JUN',
'JUNB',
'JUND',
'KDM2A',
'KDM2B',
'KDM5B',
'KLF10',
'KLF11',
'KLF12',
'KLF13',
'KLF15',
'KLF16',
'KLF2',
'KLF3',
'KLF4',
'KLF6',
'KLF7',
'KLF9',
'KMT2A',
'LBX2',
'LHX2',
'MAF',
'MAFB',
'MAFF',
'MAFG',
'MAFK',
'MAX',
'MAZ',
'MBD1',
'MBD2',
'MBD4',
'MBNL2',
'MECP2',
'MEF2A',
'MEF2B',
'MEF2D',
'MEIS2',
'MLX',
'MLXIP',
'MLXIPL',
'MNT',
'MSC',
'MTERF1',
'MTF1',
'MXD1',
'MXD3',
'MXD4',
'MXI1',
'MYC',
'MYCL',
'MYNN',
'MYPOP',
'MYRF',
'MZF1',
'NFAT5',
'NFATC3',
'NFE2L1',
'NFE2L2',
'NFE2L3',
'NFIA',
'NFIB',
'NFIC',
'NFIL3',
'NFIX',
'NFKB1',
'NFKB2',
'NFYA',
'NFYB',
'NFYC',
'NPAS2',
'NR1D1',
'NR1D2',
'NR1H2',
'NR1H3',
'NR1H4',
'NR1I2',
'NR1I3',
'NR2C1',
'NR2F1',
'NR2F2',
'NR2F6',
'NR3C1',
'NR3C2',
'NR4A1',
'NR4A2',
'NR5A2',
'NRF1',
'ONECUT1',
'ONECUT2',
'PATZ1',
'PBX2',
'PBX3',
'PHF21A',
'PKNOX1',
'PLAGL2',
'POU5F1',
'POU6F1',
'PPARA',
'PPARD',
'PPARG',
'PRDM10',
'PRDM15',
'PRDM4',
'PROX1',
'PURA',
'RARA',
'RBAK',
'RBPJ',
'RELA',
'RELB',
'REST',
'RFX1',
'RFX5',
'RLF',
'RORA',
'RORC',
'RREB1',
'RUNX1',
'RXRA',
'RXRB',
'SALL1',
'SATB1',
'SCMH1',
'SETBP1',
'SETDB1',
'SIX5',
'SMAD1',
'SMAD3',
'SMAD4',
'SMAD5',
'SNAI1',
'SNAI2',
'SNAPC4',
'SNAPC5',
'SOX12',
'SOX13',
'SOX18',
'SOX4',
'SOX5',
'SOX7',
'SOX9',
'SP1',
'SP100',
'SP110',
'SP2',
'SP3',
'SPI1',
'SREBF1',
'SREBF2',
'SRF',
'STAT1',
'STAT2',
'STAT3',
'STAT4',
'STAT5A',
'STAT5B',
'STAT6',
'TBP',
'TBPL1',
'TBX15',
'TBX2',
'TBX3',
'TCF12',
'TCF3',
'TCF7',
'TCF7L1',
'TCF7L2',
'TCFL5',
'TEAD1',
'TEAD2',
'TEAD3',
'TEAD4',
'TEF',
'TERF1',
'TERF2',
'TFAP4',
'TFCP2',
'TFDP1',
'TFDP2',
'TFE3',
'TFEB',
'TGIF1',
'TGIF2',
'THAP1',
'THAP11',
'THAP12',
'THAP5',
'THRA',
'THRB',
'TOPORS',
'TP53',
'UBP1',
'USF1',
'USF2',
'VEZF1',
'XBP1',
'XPA',
'YBX1',
'YY1',
'ZBED1',
'ZBTB1',
'ZBTB11',
'ZBTB14',
'ZBTB16',
'ZBTB17',
'ZBTB18',
'ZBTB2',
'ZBTB22',
'ZBTB25',
'ZBTB33',
'ZBTB38',
'ZBTB39',
'ZBTB4',
'ZBTB40',
'ZBTB42',
'ZBTB43',
'ZBTB44',
'ZBTB45',
'ZBTB47',
'ZBTB48',
'ZBTB5',
'ZBTB7A',
'ZBTB7B',
'ZEB1',
'ZFP1',
'ZFP62',
'ZFP90',
'ZFP91',
'ZFPM1',
'ZFX',
'ZHX1',
'ZHX2',
'ZHX3',
'ZIC1',
'ZKSCAN1',
'ZKSCAN5',
'ZKSCAN8',
'ZNF10',
'ZNF12',
'ZNF121',
'ZNF131',
'ZNF133',
'ZNF141',
'ZNF143',
'ZNF146',
'ZNF160',
'ZNF174',
'ZNF18',
'ZNF181',
'ZNF182',
'ZNF189',
'ZNF195',
'ZNF202',
'ZNF205',
'ZNF207',
'ZNF211',
'ZNF212',
'ZNF213',
'ZNF217',
'ZNF219',
'ZNF22',
'ZNF224',
'ZNF226',
'ZNF23',
'ZNF232',
'ZNF24',
'ZNF248',
'ZNF25',
'ZNF251',
'ZNF254',
'ZNF263',
'ZNF266',
'ZNF267',
'ZNF274',
'ZNF275',
'ZNF276',
'ZNF280D',
'ZNF281',
'ZNF282',
'ZNF3',
'ZNF30',
'ZNF302',
'ZNF316',
'ZNF317',
'ZNF319',
'ZNF32',
'ZNF324',
'ZNF326',
'ZNF329',
'ZNF331',
'ZNF335',
'ZNF33A',
'ZNF33B',
'ZNF341',
'ZNF343',
'ZNF354A',
'ZNF354B',
'ZNF358',
'ZNF362',
'ZNF367',
'ZNF37A',
'ZNF384',
'ZNF385A',
'ZNF394',
'ZNF397',
'ZNF408',
'ZNF410',
'ZNF414',
'ZNF419',
'ZNF429',
'ZNF432',
'ZNF433',
'ZNF436',
'ZNF438',
'ZNF44',
'ZNF441',
'ZNF444',
'ZNF467',
'ZNF48',
'ZNF480',
'ZNF496',
'ZNF503',
'ZNF507',
'ZNF513',
'ZNF514',
'ZNF516',
'ZNF517',
'ZNF524',
'ZNF529',
'ZNF544',
'ZNF548',
'ZNF550',
'ZNF552',
'ZNF554',
'ZNF558',
'ZNF561',
'ZNF563',
'ZNF564',
'ZNF574',
'ZNF579',
'ZNF580',
'ZNF581',
'ZNF584',
'ZNF587',
'ZNF589',
'ZNF592',
'ZNF595',
'ZNF598',
'ZNF605',
'ZNF621',
'ZNF623',
'ZNF627',
'ZNF628',
'ZNF629',
'ZNF639',
'ZNF641',
'ZNF646',
'ZNF652',
'ZNF653',
'ZNF654',
'ZNF655',
'ZNF662',
'ZNF664',
'ZNF672',
'ZNF680',
'ZNF684',
'ZNF687',
'ZNF688',
'ZNF689',
'ZNF69',
'ZNF691',
'ZNF692',
'ZNF697',
'ZNF700',
'ZNF706',
'ZNF710',
'ZNF721',
'ZNF74',
'ZNF740',
'ZNF746',
'ZNF75A',
'ZNF75D',
'ZNF76',
'ZNF761',
'ZNF764',
'ZNF768',
'ZNF770',
'ZNF771',
'ZNF776',
'ZNF777',
'ZNF780B',
'ZNF784',
'ZNF785',
'ZNF786',
'ZNF787',
'ZNF789',
'ZNF79',
'ZNF791',
'ZNF800',
'ZNF814',
'ZNF823',
'ZNF830',
'ZNF837',
'ZNF84',
'ZNF841',
'ZNF844',
'ZSCAN16',
'ZSCAN18',
'ZSCAN21',
'ZSCAN25',
'ZSCAN26',
'ZSCAN29',
'ZSCAN30',
'ZSCAN32',
'ZSCAN9',
'ZXDB',
'ZXDC',
'ZZZ3']
# Convert to DataFrame and specify column names
df = pd.DataFrame(filtered_tf_list1, columns=['Name'])
# Save to CSV (index=False prevents writing the row numbers)
# df.to_csv('output.csv', index=False)
df.to_csv(base+"/liver_gtex_tf.csv",index=False)
Selecting Transcription factor sources#
The list of transcription factors contains all types of genes including General TFs and housekeeping genes. These genes typically are highly expressed across samples with a lower variance. Since the tool relies of a random forest model which when taking a decision picks a feature which leads to the highest reduction in impurity, it tends to pick up these highly expressed low variance TFs. This leads to the generation of false positives.
from coregtor import PlotExprData
PlotExprData(df_matrix, tf_list, log_scale=True)
Based on the plot we can likely classify genes in 4 categories:
low mean, low variance:
high mean, low variable:
low mean, high variance:
high mean, high variance:
We can use this information to filter the TF list.
def filter_tfs_by_mean_and_variance(df_matrix, tf_list, min_mean=1.5, min_var=0.5, log_transformed=True):
"""
Filters TFs using a joint Mean Expression and Variance cutoff on log2-transformed data.
"""
# Convert to Log2(TPM + 1) if not already done
data = df_matrix if log_transformed else np.log2(df_matrix + 1)
# 1. Strictly intersect candidates with valid TF list
tf_set = set(tf_list)
valid_tfs = [gene for gene in data.columns if gene in tf_set]
tf_data = data[valid_tfs]
# 2. Calculate stats
means = tf_data.mean(axis=0)
variances = tf_data.var(axis=0)
# 3. Apply dual filter
pass_mean = means >= min_mean
pass_var = variances >= min_var
selected_tfs = means[pass_mean & pass_var].index.tolist()
print(f"Total TFs evaluated: {len(valid_tfs)}")
print(f"TFs passing filter (Mean >= {min_mean}, Variance >= {min_var}): {len(selected_tfs)}")
return selected_tfs
filtered_tf_list = filter_tfs_by_mean_and_variance(df_matrix, tf_list, min_mean = 1.5, min_var = 0.75)
Total TFs evaluated: 1383
TFs passing filter (Mean >= 1.5, Variance >= 0.75): 602
Running CoRegTor the easy way#
To run the tool on a single target, the easist way is to run RunCoRegTor
import importlib
import coregtor
from coregtor import RunCoRegTor
importlib.reload(coregtor)
from coregtor import RunCoRegTor
target_gene = "CYP3A4"
target_gene1 = "TTR"
results, details = RunCoRegTor(df_matrix,filtered_tf_list,target_gene1,ensemble_options= {"random_state":100,"n_estimators":1000})
results
| cluster_uid | target | sources | n_source | silhouette_score | fi_score | note | cluster_note | |
|---|---|---|---|---|---|---|---|---|
| 0 | d7dd3c8533ba09 | TTR | ZFP1;NFIA | 2 | 0.04204 | 0.02800 | leiden | |
| 1 | d8959b05a42c0a | TTR | ARID3C;TEAD2;DBP | 3 | 0.12160 | 0.13587 | leiden | |
| 2 | bb6ef7a3c93095 | TTR | TEAD4;NR1I3;MLXIP;E2F4;ELF3;GLIS2;ZNF217;ESR1;... | 11 | 0.39537 | 0.00610 | leiden |
coreg_list = results.iloc[2]["sources"]
coreg_list
'TEAD4;NR1I3;MLXIP;E2F4;ELF3;GLIS2;ZNF217;ESR1;HMGN3;STAT3;ONECUT2'
Manual validation of a biological case study#
CYP3A4 is an important enzyme in humans, which is mainly found in the liver and interstine and is involved in drug metabolism. CYP3A4 changes the chemical structure of foreign molecule to help process them.
Key regulators / Biological pathways found :
Master Poineer factors in liver: “HNF4A, FOXA2, FOXA3” are master liver poineer factors. Foxa1/2/3 act as pioneer factors that bind and open closed chromatin, then sequentially and cooperatively recruit Hnf4α to adjacent Hnf4α-binding sites to activate liver-specific genes. (https://doi.org/10.1016/j.molcel.2020.07.012)
Drugs & Xenobiotics (Upregulate): When the liver detects foreign chemicals, nuclear receptors (like PXR, CAR, and NR3C1) bind to the CYP3A4 promoter to drastically increase its production. The goal is to metabolize and clear the invading chemical as fast as possible. (PMID: 12514743)
Hormonal Stress (Upregulates): Chronic psychological, metabolic, or starvation stress releases cortisol (glucocorticoids) into the bloodstream. This activates the Glucocorticoid Receptor (NR3C1), which synergizes with HNF4A to upregulate CYP3A4 expression. (PMID: 12815172)
NR3C1 (the Glucocorticoid Receptor or GR) handles the drug and stress-induced upregulation of CYP3A4. However, GR cannot bind effectively to the CYP3A4 promoter on its own; it requires HNF4A to act as a physical and epigenetic anchor
liver_CYP3A4_evidence = [
{"target":"CYP3A4","sources":["HNF4A","FOXA2","FOXA3"],"title":"PMID: 32755593"},
{"target":"CYP3A4","sources":["HNF4A","NR3C1"],"title":"PMCID: PMC2981672"}
]
from coregtor import PlotClusters
PlotClusters(results, details,liver_CYP3A4_evidence,{"figsize":(8,7),"font_size": 8,"title_prefix":"Liver (GTEx) "})
[<Figure size 800x700 with 1 Axes>]
Exploring the complete CoRegTor pipeline#
Main steps:
Generate model input
Train RF model
Extract trees from the forest and paths from the forest
Find most predictive nodes and gets generate context for comparasion
Transform context into gene frequency histogram and generate similarity matrix
Clustering to generate the final coregulatory clusters
from coregtor import create_model_input,create_model,tree_paths,create_context,transform_context,compare_context,identify_coregulators
target_gene = "CTSD"
X, Y = create_model_input(df_matrix,target_gene, filtered_tf_list)
print("CTSD" in df_matrix.columns)
print("PPARG" in filtered_tf_list)
print("CEBPA" in filtered_tf_list)
True
True
True
ensemble_method = "rf"
ensemble_options = {"random_state":100,"n_estimators":1000,"max_depth":5,"n_jobs":-1}
model, fi = create_model( X, Y, method=ensemble_method, options=ensemble_options)
paths = tree_paths(model, X, Y)
contexts = create_context(paths)
transformed = transform_context(contexts)
distance_measure = "canberra_distance"
matrix = compare_context(transformed, method=distance_measure, transformation_type="gene_frequency")
matrix
| YBX1 | ZNF219 | ATF6B | MBD2 | SP2 | TFE3 | NR1H2 | DNTTIP1 | CUX1 | HMG20A | ... | ZFP91 | CREBL2 | TERF2 | NFKB1 | HBP1 | MLX | ERG | TFCP2 | DEAF1 | ZNF664 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| YBX1 | 0.000000 | 332.181490 | 253.082356 | 419.666318 | 385.886185 | 460.700980 | 450.821560 | 233.378400 | 248.832909 | 417.947598 | ... | 487.696746 | 536.874446 | 532.797166 | 406.980229 | 497.215448 | 450.377514 | 514.678629 | 532.537825 | 533.497858 | 548.982269 |
| ZNF219 | 332.181490 | 0.000000 | 321.730051 | 377.738136 | 333.360181 | 380.248591 | 363.953705 | 328.310608 | 329.612886 | 360.515381 | ... | 389.819154 | 415.990929 | 422.822410 | 338.679764 | 387.387984 | 356.637332 | 400.945510 | 410.901287 | 419.702015 | 428.358010 |
| ATF6B | 253.082356 | 321.730051 | 0.000000 | 437.016544 | 389.363873 | 465.445773 | 452.267204 | 242.679486 | 248.624925 | 437.375279 | ... | 492.990379 | 541.760149 | 532.798987 | 409.270185 | 491.869520 | 450.086576 | 516.943465 | 536.482112 | 534.398107 | 552.539627 |
| MBD2 | 419.666318 | 377.738136 | 437.016544 | 0.000000 | 309.700191 | 254.046801 | 290.254233 | 442.771311 | 437.735386 | 278.012232 | ... | 266.531541 | 255.831958 | 260.568625 | 280.195244 | 282.354725 | 270.652173 | 275.988852 | 247.782355 | 273.769072 | 262.493758 |
| SP2 | 385.886185 | 333.360181 | 389.363873 | 309.700191 | 0.000000 | 282.503211 | 299.432995 | 399.756665 | 388.864669 | 298.658323 | ... | 301.910928 | 296.322058 | 298.458019 | 288.612948 | 314.540277 | 292.639244 | 317.273512 | 300.335269 | 306.443660 | 305.589781 |
| TFE3 | 460.700980 | 380.248591 | 465.445773 | 254.046801 | 282.503211 | 0.000000 | 260.465135 | 480.262129 | 469.424627 | 270.837091 | ... | 218.852457 | 201.382084 | 199.083829 | 292.140043 | 249.581763 | 252.068809 | 231.105999 | 209.970684 | 233.283792 | 205.234445 |
| NR1H2 | 450.821560 | 363.953705 | 452.267204 | 290.254233 | 299.432995 | 260.465135 | 0.000000 | 453.477111 | 447.256167 | 284.587511 | ... | 253.400125 | 247.596290 | 261.367023 | 297.315883 | 262.020763 | 280.711767 | 277.367102 | 251.936705 | 259.663210 | 251.194711 |
| DNTTIP1 | 233.378400 | 328.310608 | 242.679486 | 442.771311 | 399.756665 | 480.262129 | 453.477111 | 0.000000 | 202.312622 | 442.524751 | ... | 510.042041 | 564.937054 | 556.856879 | 418.486499 | 512.173643 | 463.918002 | 524.920771 | 557.651346 | 551.390276 | 574.468439 |
| CUX1 | 248.832909 | 329.612886 | 248.624925 | 437.735386 | 388.864669 | 469.424627 | 447.256167 | 202.312622 | 0.000000 | 420.312506 | ... | 501.189978 | 551.405553 | 543.709029 | 408.255767 | 504.495465 | 462.268505 | 518.610314 | 550.158766 | 540.732085 | 562.717838 |
| HMG20A | 417.947598 | 360.515381 | 437.375279 | 278.012232 | 298.658323 | 270.837091 | 284.587511 | 442.524751 | 420.312506 | 0.000000 | ... | 258.472330 | 258.384624 | 249.389829 | 279.382909 | 280.712501 | 269.313605 | 276.598347 | 262.420697 | 277.747336 | 260.863778 |
| SP100 | 360.031476 | 331.856229 | 375.612627 | 323.938448 | 317.883807 | 308.838101 | 332.234406 | 379.052495 | 371.995149 | 293.814130 | ... | 316.667136 | 328.601043 | 319.156430 | 319.134461 | 339.689268 | 311.444002 | 324.987007 | 331.078797 | 344.646922 | 338.515377 |
| ETV5 | 479.733393 | 383.149169 | 478.934318 | 275.313665 | 307.432726 | 228.582378 | 283.548691 | 498.582797 | 491.391856 | 275.379046 | ... | 215.864594 | 172.575944 | 183.935435 | 320.327626 | 228.437753 | 240.949622 | 209.168383 | 185.573984 | 196.190522 | 171.185630 |
| NFE2L1 | 497.335720 | 386.208086 | 493.096654 | 274.943100 | 289.368036 | 201.884760 | 264.956671 | 515.839685 | 510.878733 | 288.553716 | ... | 202.338225 | 161.183041 | 158.410660 | 294.953229 | 220.685956 | 238.776009 | 192.258436 | 160.495116 | 170.254858 | 150.929689 |
| STAT6 | 497.619660 | 390.539658 | 506.441649 | 272.853575 | 315.059662 | 231.529093 | 273.191776 | 521.794912 | 515.051166 | 276.685990 | ... | 220.611503 | 157.812743 | 170.670263 | 308.757068 | 233.279210 | 251.396466 | 205.576381 | 165.618628 | 192.870305 | 152.433151 |
| KDM5B | 530.735279 | 418.898149 | 533.683651 | 256.166096 | 311.327891 | 216.122083 | 260.414641 | 557.201103 | 549.241993 | 259.826282 | ... | 166.985638 | 87.486497 | 112.299850 | 304.299676 | 189.531997 | 229.086041 | 163.593114 | 113.758047 | 124.509229 | 84.402149 |
| RELA | 528.165403 | 420.535499 | 530.412299 | 251.191519 | 295.492520 | 207.288478 | 252.619045 | 550.114977 | 537.179666 | 270.966014 | ... | 161.376955 | 114.506896 | 116.707019 | 291.185500 | 202.323254 | 235.871902 | 175.138634 | 115.780049 | 146.193291 | 105.780415 |
| LYL1 | 523.375635 | 416.658857 | 529.957862 | 273.845633 | 316.253090 | 234.173578 | 281.639060 | 545.303932 | 536.571154 | 263.452511 | ... | 193.092794 | 131.845726 | 151.963518 | 317.401869 | 203.197809 | 251.526342 | 186.374383 | 142.441993 | 151.235452 | 123.589955 |
| ZFP91 | 487.696746 | 389.819154 | 492.990379 | 266.531541 | 301.910928 | 218.852457 | 253.400125 | 510.042041 | 501.189978 | 258.472330 | ... | 0.000000 | 163.541497 | 164.304392 | 291.099036 | 206.690580 | 226.965816 | 198.827140 | 160.939662 | 185.227423 | 156.168043 |
| CREBL2 | 536.874446 | 415.990929 | 541.760149 | 255.831958 | 296.322058 | 201.382084 | 247.596290 | 564.937054 | 551.405553 | 258.384624 | ... | 163.541497 | 0.000000 | 85.234835 | 290.466234 | 178.554690 | 223.270094 | 148.747300 | 90.312799 | 107.821613 | 61.605128 |
| TERF2 | 532.797166 | 422.822410 | 532.798987 | 260.568625 | 298.458019 | 199.083829 | 261.367023 | 556.856879 | 543.709029 | 249.389829 | ... | 164.304392 | 85.234835 | 0.000000 | 289.675180 | 191.060533 | 218.771417 | 167.058986 | 109.135276 | 135.248617 | 83.543678 |
| NFKB1 | 406.980229 | 338.679764 | 409.270185 | 280.195244 | 288.612948 | 292.140043 | 297.315883 | 418.486499 | 408.255767 | 279.382909 | ... | 291.099036 | 290.466234 | 289.675180 | 0.000000 | 320.207267 | 289.254708 | 312.580124 | 296.628752 | 302.354292 | 298.764823 |
| HBP1 | 497.215448 | 387.387984 | 491.869520 | 282.354725 | 314.540277 | 249.581763 | 262.020763 | 512.173643 | 504.495465 | 280.712501 | ... | 206.690580 | 178.554690 | 191.060533 | 320.207267 | 0.000000 | 253.918682 | 211.573432 | 180.975049 | 199.640043 | 177.633680 |
| MLX | 450.377514 | 356.637332 | 450.086576 | 270.652173 | 292.639244 | 252.068809 | 280.711767 | 463.918002 | 462.268505 | 269.313605 | ... | 226.965816 | 223.270094 | 218.771417 | 289.254708 | 253.918682 | 0.000000 | 232.010514 | 223.505170 | 223.390175 | 222.222270 |
| ERG | 514.678629 | 400.945510 | 516.943465 | 275.988852 | 317.273512 | 231.105999 | 277.367102 | 524.920771 | 518.610314 | 276.598347 | ... | 198.827140 | 148.747300 | 167.058986 | 312.580124 | 211.573432 | 232.010514 | 0.000000 | 151.386516 | 163.258831 | 147.376966 |
| TFCP2 | 532.537825 | 410.901287 | 536.482112 | 247.782355 | 300.335269 | 209.970684 | 251.936705 | 557.651346 | 550.158766 | 262.420697 | ... | 160.939662 | 90.312799 | 109.135276 | 296.628752 | 180.975049 | 223.505170 | 151.386516 | 0.000000 | 118.787193 | 82.722700 |
| DEAF1 | 533.497858 | 419.702015 | 534.398107 | 273.769072 | 306.443660 | 233.283792 | 259.663210 | 551.390276 | 540.732085 | 277.747336 | ... | 185.227423 | 107.821613 | 135.248617 | 302.354292 | 199.640043 | 223.390175 | 163.258831 | 118.787193 | 0.000000 | 98.313349 |
| ZNF664 | 548.982269 | 428.358010 | 552.539627 | 262.493758 | 305.589781 | 205.234445 | 251.194711 | 574.468439 | 562.717838 | 260.863778 | ... | 156.168043 | 61.605128 | 83.543678 | 298.764823 | 177.633680 | 222.222270 | 147.376966 | 82.722700 | 98.313349 | 0.000000 |
27 rows × 27 columns
# print("NR1I2" in filtered_tf_list)
# print("NR1I3" in filtered_tf_list)
print("PPARG" in filtered_tf_list)
print("CEBPA" in filtered_tf_list)
True
True
matrix.columns
Index(['YBX1', 'ZNF219', 'ATF6B', 'MBD2', 'SP2', 'TFE3', 'NR1H2', 'DNTTIP1',
'CUX1', 'HMG20A', 'SP100', 'ETV5', 'NFE2L1', 'STAT6', 'KDM5B', 'RELA',
'LYL1', 'ZFP91', 'CREBL2', 'TERF2', 'NFKB1', 'HBP1', 'MLX', 'ERG',
'TFCP2', 'DEAF1', 'ZNF664'],
dtype='object')
paths
| tree | source | target | path_length | node1 | node2 | node3 | node4 | node5 | node6 | node7 | node8 | node9 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 0 | NFE2L2 | CYP3A4 | 6 | DDIT3 | TEAD2 | HOMEZ | ZNF581 | NFE2L2 | None | None | None | None |
| 1 | 0 | NFE2L2 | CYP3A4 | 10 | DDIT3 | TEAD2 | HLF | ZNF74 | MEF2A | DBP | HAND2 | HHEX | RXRA |
| 2 | 0 | NFE2L2 | CYP3A4 | 9 | DDIT3 | TEAD2 | HOMEZ | GTF2IRD1 | NFIX | HES6 | ZNF584 | ZNF710 | None |
| 3 | 0 | NFE2L2 | CYP3A4 | 10 | DDIT3 | TEAD2 | HOMEZ | GTF2IRD1 | NFIX | HES6 | ZNF655 | HSF4 | FOSL1 |
| 4 | 0 | NFE2L2 | CYP3A4 | 10 | DDIT3 | TEAD2 | HOMEZ | GTF2IRD1 | NFIX | MYC | THAP5 | KLF2 | TEF |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 49097 | 999 | LTF | CYP3A4 | 10 | XPA | TEAD2 | SNAPC5 | TCF7 | ZNF274 | FOXN3 | RELB | HOXB4 | CREB3L2 |
| 49098 | 999 | LTF | CYP3A4 | 9 | XPA | TEAD2 | SNAPC5 | TCF7 | ZNF274 | FOXN3 | ZXDB | HES4 | None |
| 49099 | 999 | LTF | CYP3A4 | 7 | XPA | TEAD2 | SNAPC5 | TCF7 | ZNF529 | ZNF224 | None | None | None |
| 49100 | 999 | LTF | CYP3A4 | 10 | XPA | TEAD2 | SNAPC5 | TCF7 | ZNF529 | ZNF334 | NFIC | ZNF202 | RARG |
| 49101 | 999 | LTF | CYP3A4 | 8 | XPA | TEAD2 | ZNF513 | KLF15 | ZNF205 | ZNF628 | ZNF688 | None | None |
49102 rows × 13 columns
for col in paths.columns:
print(col)
print("PPARG" in paths[col])
tree
False
source
False
target
False
path_length
False
node1
False
node2
False
node3
False
node4
False
node5
False
node6
False
node7
False
node8
False
node9
False
cluster_method = "community_detection"
cluster_options = {"edge_creation_method": "threshold_percentile","edge_creation_value": 0.25, "resolution": 0.5}
results = identify_coregulators(matrix, target_gene, cluster_method, cluster_options, feature_importance=fi)
results
| cluster_uid | target | sources | n_source | silhouette_score | fi_score | note | cluster_note | |
|---|---|---|---|---|---|---|---|---|
| 0 | d1c8a342cb550d | CTSD | DNTTIP1;CUX1;ATF6B;YBX1;SP100;ZNF219;NFKB1;SP2... | 24 | 0.27569 | 0.02816 | leiden |
results.iloc[-1]["sources"]
'DNTTIP1;CUX1;ATF6B;YBX1;SP100;ZNF219;NFKB1;SP2;HMG20A;NR1H2;MBD2;TFE3;HBP1;MLX;LYL1;ETV5;ERG;NFE2L1;STAT6;ZFP91;DEAF1;RELA;TERF2;KDM5B'