<jupyter_start><jupyter_text>Interaction model   Figure 1 (d): Modeling cell communication as spatial cell state dependencies.<jupyter_code>gs_linear = ncem.train.GridSearchContainer(
    dir_gs, 
    gs_ids=[
        "210422_INTERACTIONS_BASELINE_MAX_NODES_IMAGE_1_SCHUERCH",
        "210422_INTERACTIONS_MAX_NODES_IMAGE_1_SCHUERCH",
    ],
    lateral_resolution = 0.377442
)
gs_linear.load_gs()

gs_linear.plot_best_model_by_hyperparam(
    partition_show="test",
    metric_show="r_squared_linreg",
    partition_select="val",
    metric_select="r_squared_linreg",
    param_x="um_radius",
    param_hue="model",
    graph_model_class='interactions',
    baseline_model_class='interactions_baseline',
    rename_levels = [
        ("model", {
            "INTERACTIONS_BASELINE_MAX_NODES_IMAGE_1": "baseline",
            "INTERACTIONS_MAX_NODES_IMAGE_1": "interactions",
        })
    ],
    plot_mode = 'lineplot',
    palette = {"baseline": "C0", "interactions": "C1"},
    xticks=[0,9,18,45,188,754],
)<jupyter_output>210422_INTERACTIONS_BASELINE_MAX_NODES_IMAGE_1_SCHUERCH: loaded 1 runs with 3-fold cross validation
210422_INTERACTIONS_MAX_NODES_IMAGE_1_SCHUERCH: loaded 6 runs with 3-fold cross validation
subset was empty, available values for model are ['INTERACTIONS_MAX_NODES_IMAGE_1'], given was ['INTERACTIONS_BASELINE_MAX_NODES_IMAGE_1']
subset was empty, available values for model are ['INTERACTIONS_MAX_NODES_IMAGE_1'], given was ['INTERACTIONS_BASELINE_MAX_NODES_IMAGE_1']
subset was empty, available values for model are ['INTERACTIONS_MAX_NODES_IMAGE_1'], given was ['INTERACTIONS_BASELINE_MAX_NODES_IMAGE_1']
subset was empty, available values for model are ['INTERACTIONS_MAX_NODES_IMAGE_1'], given was ['INTERACTIONS_BASELINE_MAX_NODES_IMAGE_1']
subset was empty, available values for model are ['INTERACTIONS_MAX_NODES_IMAGE_1'], given was ['INTERACTIONS_BASELINE_MAX_NODES_IMAGE_1']<jupyter_text>Paired t-test between baseline model and best spatial model<jupyter_code>test_id_interaction = gs_linear.get_best_model_id(
    subset_hyperparameters=[("model", "INTERACTIONS_MAX_NODES_IMAGE_1")]
)
interaction_test_r2 = np.array(
    gs_linear.summary_table[gs_linear.summary_table["run_id"] ==test_id_interaction]['test_r_squared_linreg']
)
test_id_baseline = gs_linear.get_best_model_id(
    subset_hyperparameters=[("model", "INTERACTIONS_BASELINE_MAX_NODES_IMAGE_1")]
)
baseline_test_r2 = np.array(
    gs_linear.summary_table[gs_linear.summary_table["run_id"] ==test_id_baseline]['test_r_squared_linreg']
)

print(ttest_rel(interaction_test_r2, baseline_test_r2))<jupyter_output>Ttest_relResult(statistic=6.047849331719845, pvalue=0.02626752133879902)<jupyter_text>Supp. Fig. 4 (e): Length scales of dependencies for different target cell-types.<jupyter_code>gs_linear.load_target_cell_evaluation()
gs_linear.target_cell_table = gs_linear.target_cell_table[gs_linear.target_cell_table['target_cell'] != 'undefined']
gs_linear.target_cell_table = gs_linear.target_cell_table[gs_linear.target_cell_table['target_cell'] != 'dirt']

gs_linear.plot_target_cell_evaluation(
    metric_show="r_squared_linreg",
    metric_select="r_squared_linreg",
    param_x="um_radius",
)<jupyter_output><empty_output><jupyter_text>Linear model Supp. Fig. 3: Linear models for spatial cell state dependencies.<jupyter_code>gs_linear = ncem.train.GridSearchContainer(
    dir_gs, 
    gs_ids=[
        "210520_LINEAR_BASELINE_MAX_NODES_IMAGE_1_SCHUERCH",
        "210520_LINEAR_MAX_NODES_IMAGE_1_SCHUERCH",
    ],
    lateral_resolution = 0.377442
)
gs_linear.load_gs()

gs_linear.plot_best_model_by_hyperparam(
    partition_show="test",
    metric_show="r_squared_linreg",
    partition_select="val",
    metric_select="r_squared_linreg",
    param_x="um_radius",
    param_hue="model",
    graph_model_class='linear',
    baseline_model_class='linear_baseline',
    rename_levels = [
        ("model", {
            "LINEAR_BASELINE_MAX_NODES_IMAGE_1": "baseline",
            "LINEAR_MAX_NODES_IMAGE_1": "linear",
        })
    ],
    plot_mode = 'lineplot',
    palette = {"baseline": "C0", "linear": "C1"},
    xticks=[0,9,18,45,188,754],
)<jupyter_output>210520_LINEAR_BASELINE_MAX_NODES_IMAGE_1_SCHUERCH: loaded 1 runs with 3-fold cross validation
210520_LINEAR_MAX_NODES_IMAGE_1_SCHUERCH: loaded 6 runs with 3-fold cross validation
subset was empty, available values for model are ['LINEAR_MAX_NODES_IMAGE_1'], given was ['LINEAR_BASELINE_MAX_NODES_IMAGE_1']
subset was empty, available values for model are ['LINEAR_MAX_NODES_IMAGE_1'], given was ['LINEAR_BASELINE_MAX_NODES_IMAGE_1']
subset was empty, available values for model are ['LINEAR_MAX_NODES_IMAGE_1'], given was ['LINEAR_BASELINE_MAX_NODES_IMAGE_1']
subset was empty, available values for model are ['LINEAR_MAX_NODES_IMAGE_1'], given was ['LINEAR_BASELINE_MAX_NODES_IMAGE_1']
subset was empty, available values for model are ['LINEAR_MAX_NODES_IMAGE_1'], given was ['LINEAR_BASELINE_MAX_NODES_IMAGE_1']
{'fraction_non_alphanumeric': 0.09785442149588931, 'fraction_numerical': 0.03469019450571486, 'mean_word_length': 6.733333333333333, 'pattern_counts': {'":': 8, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '225159', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1869, 'n_tokens_neox': 1796, 'n_words': 286, 'path': 'notebooks/model_benchmarks/model_benchmarks_codex_cancer.ipynb', 'repo_name': 'theislab/ncem_benchmarks', 'size': '4987'}