3. Regulon and TF activity¶
Language: Python · Input: integrated .h5ad ·
Output: mouse_dorothea_AB.csv, decoupler_dorotheaAB_results_ulm.csv
In this step, we will estimate transcription factor (TF) activity for every cell using the DoRothEA regulon and decoupleR’s univariate linear model (ULM). The resulting TF activity scores are used for differential analysis with IntraTalker.
Load the DoRothEA regulon¶
IntraTalkerpy includes the complete mouse DoRothEA regulon. We recommend using only the highest-confidence interactions (confidence levels A and B), so filter the regulon before estimating TF activity.
Use only confidence levels A and B
The bundled regulon contains all confidence levels (A–D). Throughout this tutorial, only confidence levels A and B are used because they provide the most reliable transcription factor–target interactions. Using the complete regulon will produce different TF activity estimates and downstream results.
You can also use custom regulon databases instead of the DoRothEA regulons provided with the package.
from importlib.resources import files
import pandas as pd
import intratalkerpy
reg = pd.read_csv(
files("intratalkerpy.tf.data").joinpath("mouse_dorothea_reg.csv"))
reg = pd.read_csv(regulon_path)
reg = reg.loc[reg["confidence"].isin(["A", "B"]), ["source", "target", "weight"]]
reg.to_csv(TF_OUT / "mouse_dorothea_AB.csv", index=False)
The filtered regulon is saved for reuse in the downstream R workflow.
Estimate transcription factor activity¶
Next, we estimate transcription factor activity for every cell using decoupleR’s univariate linear model (ULM). This produces one activity score for every transcription factor in every cell.
import decoupler as dc
dc.mt.ulm(
data=adata,
net=reg,
verbose=True,
raw=False,
)
estimates = adata.obsm["score_ulm"]
estimates.to_csv(TF_OUT / "decoupler_dorotheaAB_results_ulm.csv")
The output is a cell-by-transcription factor activity matrix. Differential testing of these activity scores (KO versus WT within each cell type) is performed in the next step using R.
Handoff: Python → R
The IntraTalker and CrossTalkeR analysis of the workflow is implemented in R. Before continuing, make sure you have the following files:
bone_marrow_Il1rn_KOvsWT_harmony_integrated.rdsmouse_dorothea_AB.csvdecoupler_dorotheaAB_results_ulm.csvKO_lr_ready.csvWT_lr_ready.csv
Once these files are available, you can start the R workflow.