
Identify the TF to gene regulation
identify_tf_to_genes.RdGenerates the TF to gene associations from the importance matrix produced by the tree-based regression models. Two filtering strategies are available:
Threshold (
method = "threshold"): For each gene, computes mean +n_sd* SD of the importance scores across all TFs and retains only pairs exceeding that threshold. This adapts to the per-gene importance distribution and is less sensitive to differences between learners.Top-k (
method = "top_k"): Selects the topk_tfsTFs per gene and/or the topk_genesgenes per TF. Both margins can be combined (union). At least one ofk_tfsork_genesmust be provided.
Both methods accept an optional min_importance floor.
Usage
identify_tf_to_genes(
x,
method = c("threshold", "top_k"),
k_tfs = NULL,
k_genes = NULL,
n_sd = 2,
min_importance = NULL,
.verbose = TRUE
)
# S3 method for class 'ScenicGrn'
identify_tf_to_genes(
x,
method = c("threshold", "top_k"),
k_tfs = NULL,
k_genes = NULL,
n_sd = 2,
min_importance = NULL,
.verbose = TRUE
)Arguments
- x
ScenicGrnobject.- method
Character. Either
"top_k"or"threshold".- k_tfs
Optional integer. Top TFs per gene (only used when
method = "top_k").- k_genes
Optional integer. Top genes per TF (only used when
method = "top_k").- n_sd
Numeric. Number of standard deviations above the per-gene mean to use as the threshold (only used when
method = "threshold"). Default is2.- min_importance
Optional numeric in [0, 1]. Absolute minimum importance score for inclusion.
- .verbose
Boolean. Controls verbosity of the function.
Examples
# keep the three strongest TFs per gene
sc <- demo_single_cells()
grn <- scenic_grn_sc(
sc,
tf_ids = sprintf("gene_%02d", 1:5),
scenic_params = params_scenic(
min_counts = 1L,
learner_params = list(n_trees = 20L)
),
.verbose = FALSE
)
grn <- identify_tf_to_genes(
grn,
method = "top_k",
k_tfs = 3L,
.verbose = FALSE
)
head(get_tf_to_gene(grn))
#> tf gene importance
#> <char> <char> <num>
#> 1: gene_01 gene_01 0.4643152
#> 2: gene_03 gene_01 0.3568220
#> 3: gene_04 gene_01 0.1553617
#> 4: gene_02 gene_02 0.4926334
#> 5: gene_03 gene_02 0.2651168
#> 6: gene_04 gene_02 0.1317756
unlink(sc@dir_data, recursive = TRUE, force = TRUE)