tl — tools

Rule fitting and analysis tools.

bobaT.tl.reorder_binary_decision_tree(old_regulator_order, regulators)[source]
bobaT.tl.detect_irrelevant_regulator(regulators, rule, threshold=0.1, heat=None)[source]
bobaT.tl.get_rules_scvelo(data, data_t1, vertex_dict, plot=False, show_plot=False, save_plot=True, threshold=0, save_dir='rules', hlines=None)[source]
bobaT.tl.get_rules(data, vertex_dict, plot=False, threshold=0, save_dir='rules', save_plot=True, show_plot=False, hlines=None, pseudocount_mode='max_heat', pseudocount_c=1.0, pseudocount_target='uniform')[source]
pseudocount_mode: controls how much WEIGHT the pseudo-observation gets for a given leaf.

“max_heat” (default, original behavior): weight = 1-max(heat[:, leaf]) – a leaf only escapes the pull toward the anchor (see pseudocount_target) if at least one single cell is a confident (near-1 heat) match for it. “aggregate”: weight = pseudocount_c / (pseudocount_c + sum(heat[:, leaf])), a Beta-style pseudocount tied to the leaf’s TOTAL weighted evidence rather than its single best-matching cell – a leaf with many moderately-confident cells accumulates enough aggregate weight to escape the pull even with no single confident match. On the SCLC 6667 network, this mode alone (isolated from an earlier, unrelated remove_selfloops network-loading mismatch – barcode 7777) showed no measurable benefit on external validation once that mismatch was corrected; kept as an option, not a recommendation.

pseudocount_c: only used when pseudocount_mode=”aggregate”. Roughly, the number of

fully-confident-cells’-worth of aggregate evidence a leaf needs before the prior’s pull toward the anchor meaningfully fades.

pseudocount_target: controls what VALUE the pseudo-observation is anchored to.

“uniform” (default, original behavior): 0.5, i.e. an agnostic prior with no information about which way an under-evidenced leaf should lean. “marginal_rate”: the gene’s own marginal rate (data[gene].mean(), its overall on/off frequency across all training cells) – an empirical-Bayes anchor appropriate for single-cell data, where most genes are not naturally balanced 50/50, so pulling a thin-evidence leaf toward 0.5 can be a systematic bias for a gene that’s rarely (or almost always) on.

bobaT.tl.save_rules(rules, regulators_dict, fname='rules.txt', delimiter='|')[source]
bobaT.tl.parent_heatmap(data, regulators_dict, gene)[source]
bobaT.tl.roc(validation, node, n_thresholds=10, plot=False, show_plot=False, save=False, save_dir=None)[source]
bobaT.tl.calc_roc(validation, threshold)[source]
bobaT.tl.auc(fpr, tpr)[source]
bobaT.tl.save_auc_by_gene(area_all, nodes, save_dir)[source]
bobaT.tl.fit_validation(data_test, nodes, regulators_dict, rules, data_test_t1=None, save=False, save_dir=None, fname='', clusters=None, plot=True, plot_clusters=False, show_plots=False, save_df=False, n_thresholds=50, customPalette=[(0.4, 0.7607843137254902, 0.6470588235294118), (0.9882352941176471, 0.5529411764705883, 0.3843137254901961), (0.5529411764705883, 0.6274509803921569, 0.796078431372549), (0.9058823529411765, 0.5411764705882353, 0.7647058823529411), (0.6509803921568628, 0.8470588235294118, 0.32941176470588235), (1.0, 0.8509803921568627, 0.1843137254901961), (0.8980392156862745, 0.7686274509803922, 0.5803921568627451), (0.7019607843137254, 0.7019607843137254, 0.7019607843137254)])[source]
bobaT.tl.roc_from_file(validation_dir, nodes, n_thresholds=50, plot=False, show_plots=False, save=False, save_dir=None)[source]
bobaT.tl.get_sklearn_metrics(VAL_DIR, plot_cm=True, show=False, save=True, save_stats=True, verbose=False)[source]
bobaT.tl.get_sample_avg_curve(fpr_all, tpr_all, num_nodes, area_all, remove_sources=True, vertex_dict=None, graph=None)[source]
bobaT.tl.plot_cohort_roc_with_ci(sample_fprs, sample_tprs, n_boot=2000, ci=95, save=False, save_dir=None, show_plot=False, fname='')[source]
bobaT.tl.find_attractors(binarized_data, rules, nodes, regulators_dict, tf_basin, save_dir=None, threshold=0.5, on_nodes=[], off_nodes=[])[source]
bobaT.tl.write_attractor_dict(attractor_dict, nodes, outfile)[source]
bobaT.tl.filter_attractors(attractor_dir, nodes, clusters)[source]
bobaT.tl.find_avg_states(binarized_data, nodes, save_dir)[source]
bobaT.tl.perturbations_summary(attractor_dict, perturbations_dir, show=False, save=True, plot_by_attractor=False, save_dir='clustered_perturb_plots', save_full=True, significance='both', fname='', ncols=5, mean_threshold=-0.3)[source]