<jupyter_start><jupyter_text>---  Mouse  Campbell<jupyter_code>campbell = cb.data.ExprDataSet.read_dataset("../../Datasets/data/Campbell/data.h5")
utils.peek(campbell, "build/brain/Campbell")
campbell.obs.head()
campbell.obs.dtypes
campbell_model = cb.directi.fit_DIRECTi(
    campbell, campbell.uns["seurat_genes"],
    **fixed_model_kwargs
)
campbell.latent = campbell_model.inference(campbell)
ax = campbell.visualize_latent("cell_ontology_class", scatter_kws=dict(rasterized=True))
ax.get_figure().savefig("build/brain/Campbell/cell_ontology_class.svg", dpi=utils.DPI, bbox_inches="tight")
ax = campbell.visualize_latent("cell_type1", scatter_kws=dict(rasterized=True))
ax.get_figure().savefig("build/brain/Campbell/cell_type1.svg", dpi=utils.DPI, bbox_inches="tight")
ax = campbell.visualize_latent("cell_type2", scatter_kws=dict(rasterized=True))
ax.get_figure().savefig("build/brain/Campbell/cell_type2.svg", dpi=utils.DPI, bbox_inches="tight")
ax = campbell.visualize_latent("diet", scatter_kws=dict(rasterized=True))
ax.get_figure().savefig("build/brain/Campbell/diet.svg", dpi=utils.DPI, bbox_inches="tight")
ax = campbell.visualize_latent("gender", scatter_kws=dict(rasterized=True))
ax.get_figure().savefig("build/brain/Campbell/gender.svg", dpi=utils.DPI, bbox_inches="tight")
ax = campbell.visualize_latent("batch", scatter_kws=dict(rasterized=True))
ax.get_figure().savefig("build/brain/Campbell/batch.svg", dpi=utils.DPI, bbox_inches="tight")
campbell.write_dataset("build/brain/Campbell/Campbell.h5")
%%capture capio
campbell_models = [campbell_model]
for i in range(1, cb.config.N_JOBS):
    print("==== Model %d ====" % i)
    campbell_models.append(cb.directi.fit_DIRECTi(
        campbell, campbell.uns["seurat_genes"],
        **fixed_model_kwargs,
        random_seed=i
    ))
campbell_blast = cb.blast.BLAST(campbell_models, campbell)
campbell_blast.save("build/brain/Campbell")
with open("build/brain/Campbell/stdout.txt", "w") as f:
    f.write(capio.stdout)
with open("build/brain/Campbell/stderr.txt", "w") as f:
    f.write(capio.stderr)
utils.self_projection(campbell_blast, "build/brain/Campbell")
%%writefile build/brain/Campbell/predictable.txt
cell_ontology_class
cell_type1
cell_type2
diet
gender<jupyter_output><empty_output><jupyter_text>Chen<jupyter_code>chen = cb.data.ExprDataSet.read_dataset("../../Datasets/data/Chen/data.h5")
utils.peek(chen, "build/brain/Chen")
chen.obs.head()
chen.obs.dtypes
chen_model = cb.directi.fit_DIRECTi(
    chen, chen.uns["seurat_genes"],
    **fixed_model_kwargs
)
chen.latent = chen_model.inference(chen)
ax = chen.visualize_latent("cell_ontology_class", scatter_kws=dict(rasterized=True))
ax.get_figure().savefig("build/brain/Chen/cell_ontology_class.svg", dpi=utils.DPI, bbox_inches="tight")
ax = chen.visualize_latent("cell_type1", scatter_kws=dict(rasterized=True))
ax.get_figure().savefig("build/brain/Chen/cell_type1.svg", dpi=utils.DPI, bbox_inches="tight")
#Exclusive endothelial cell markers include von Willebrand factor [19], 
#vascular endothelial cadherin (VE-cadherin, CD144), i.e. Cdh5 
ax = chen.visualize_latent("Cdh5", scatter_kws=dict(rasterized=True))
#plot.get_figure().savefig("Chen/cell_ontology_class.pdf", bbox_inches="tight")
#epithelial cell marker: CD227, i.e. Muc1
ax = chen.visualize_latent("Muc1", scatter_kws=dict(rasterized=True))
#plot.get_figure().savefig("Chen/cell_ontology_class.pdf", bbox_inches="tight")
ax = chen.visualize_latent("donor", scatter_kws=dict(rasterized=True))
ax.get_figure().savefig("build/brain/Chen/donor.svg", dpi=utils.DPI, bbox_inches="tight")
chen.write_dataset("build/brain/Chen/Chen.h5")
%%capture capio
chen_models = [chen_model]
for i in range(1, cb.config.N_JOBS):
    print("==== Model %d ====" % i)
    chen_models.append(cb.directi.fit_DIRECTi(
        chen, chen.uns["seurat_genes"],
        **fixed_model_kwargs,
        random_seed=i
    ))
chen_blast = cb.blast.BLAST(chen_models, chen)
chen_blast.save("build/brain/Chen")
with open("build/brain/Chen/stdout.txt", "w") as f:
    f.write(capio.stdout)
with open("build/brain/Chen/stderr.txt", "w") as f:
    f.write(capio.stderr)
utils.self_projection(chen_blast, "build/brain/Chen")
%%writefile build/brain/Chen/predictable.txt
cell_ontology_class
cell_type1<jupyter_output><empty_output><jupyter_text>Lake_2018<jupyter_code>lake_2018 = cb.data.ExprDataSet.read_dataset("../../Datasets/data/Lake_2018/data.h5")
utils.peek(lake_2018, "build/brain/Lake_2018")
lake_2018.obs.head()
lake_2018.obs.dtypes
lake_2018_model = cb.directi.fit_DIRECTi(
    lake_2018, lake_2018.uns["seurat_genes"],
    **fixed_model_kwargs
) 
lake_2018.latent = lake_2018_model.inference(lake_2018)
ax = lake_2018.visualize_latent("cell_ontology_class", scatter_kws=dict(rasterized=True))
ax.get_figure().savefig("build/brain/Lake_2018/cell_ontology_class.svg", dpi=utils.DPI, bbox_inches="tight")
ax = lake_2018.visualize_latent("cell_type1", scatter_kws=dict(rasterized=True))
ax.get_figure().savefig("build/brain/Lake_2018/cell_type1.svg", dpi=utils.DPI, bbox_inches="tight")
ax = lake_2018.visualize_latent("region", scatter_kws=dict(rasterized=True))
ax.get_figure().savefig("build/brain/Lake_2018/region.svg", dpi=utils.DPI, bbox_inches="tight")
ax = lake_2018.visualize_latent("donor", scatter_kws=dict(rasterized=True))
ax.get_figure().savefig("build/brain/Lake_2018/donor.svg", dpi=utils.DPI, bbox_inches="tight")
lake_2018.write_dataset("build/brain/Lake_2018/Lake_2018.h5")
%%capture capio
lake_2018_models = [lake_2018_model]
for i in range(1, cb.config.N_JOBS):
    print("==== Model %d ====" % i)
    lake_2018_models.append(cb.directi.fit_DIRECTi(
        lake_2018, lake_2018.uns["seurat_genes"],
        **fixed_model_kwargs,
        random_seed=i
    ))
lake_2018_blast = cb.blast.BLAST(lake_2018_models, lake_2018)
lake_2018_blast.save("build/brain/Lake_2018")
with open("build/brain/Lake_2018/stdout.txt", "w") as f:
    f.write(capio.stdout)
with open("build/brain/Lake_2018/stderr.txt", "w") as f:
    f.write(capio.stderr)
utils.self_projection(lake_2018_blast, "build/brain/Lake_2018")
%%writefile build/brain/Lake_2018/predictable.txt
cell_ontology_class
cell_type1
region<jupyter_output><empty_output><jupyter_text>Quake_Smart-seq2_Brain_Myeloid<jupyter_code>quake_smart_seq2_brain_myeloid = cb.data.ExprDataSet.read_dataset("../../Datasets/data/Quake_Smart-seq2_Brain_Myeloid/data.h5")
utils.peek(quake_smart_seq2_brain_myeloid, "build/brain/Quake_Smart-seq2_Brain_Myeloid")
quake_smart_seq2_brain_myeloid.obs.head()
quake_smart_seq2_brain_myeloid.obs["cluster"] = "cluster_" + quake_smart_seq2_brain_myeloid.obs["cluster"].astype(int).astype(str)
quake_smart_seq2_brain_myeloid.obs.dtypes
opt_model_kwargs = dict(batch_effect="donor")
quake_smart_seq2_brain_myeloid_model = cb.directi.fit_DIRECTi(
    quake_smart_seq2_brain_myeloid, quake_smart_seq2_brain_myeloid.uns["seurat_genes"],
    **fixed_model_kwargs, **opt_model_kwargs
) 
quake_smart_seq2_brain_myeloid.latent = quake_smart_seq2_brain_myeloid_model.inference(quake_smart_seq2_brain_myeloid)
ax = quake_smart_seq2_brain_myeloid.visualize_latent("cell_ontology_class", scatter_kws=dict(rasterized=True))
ax.get_figure().savefig("build/brain/Quake_Smart-seq2_Brain_Myeloid/cell_ontology_class.svg", dpi=utils.DPI, bbox_inches="tight")
ax = quake_smart_seq2_brain_myeloid.visualize_latent("cell_type1", scatter_kws=dict(rasterized=True))
ax.get_figure().savefig("build/brain/Quake_Smart-seq2_Brain_Myeloid/cell_type1.svg", dpi=utils.DPI, bbox_inches="tight")
ax = quake_smart_seq2_brain_myeloid.visualize_latent("cluster", scatter_kws=dict(rasterized=True))
ax.get_figure().savefig("build/brain/Quake_Smart-seq2_Brain_Myeloid/cluster.svg", dpi=utils.DPI, bbox_inches="tight")
ax = quake_smart_seq2_brain_myeloid.visualize_latent("donor", scatter_kws=dict(rasterized=True))
ax.get_figure().savefig("build/brain/Quake_Smart-seq2_Brain_Myeloid/donor.svg", dpi=utils.DPI, bbox_inches="tight")
ax = quake_smart_seq2_brain_myeloid.visualize_latent("region", scatter_kws=dict(rasterized=True))
ax.get_figure().savefig("build/brain/Quake_Smart-seq2_Brain_Myeloid/region.svg", dpi=utils.DPI, bbox_inches="tight")
quake_smart_seq2_brain_myeloid.write_dataset("build/brain/Quake_Smart-seq2_Brain_Myeloid/Quake_Smart-seq2_Brain_Myeloid.h5")
%%capture capio
quake_smart_seq2_brain_myeloid_models = [quake_smart_seq2_brain_myeloid_model]
for i in range(1, cb.config.N_JOBS):
    print("==== Model %d ====" % i)
    quake_smart_seq2_brain_myeloid_models.append(cb.directi.fit_DIRECTi(
        quake_smart_seq2_brain_myeloid, quake_smart_seq2_brain_myeloid.uns["seurat_genes"],
        **fixed_model_kwargs, **opt_model_kwargs,
        random_seed=i
    ))
quake_smart_seq2_brain_myeloid_blast = cb.blast.BLAST(quake_smart_seq2_brain_myeloid_models, quake_smart_seq2_brain_myeloid)
quake_smart_seq2_brain_myeloid_blast.save("build/brain/Quake_Smart-seq2_Brain_Myeloid")
with open("build/brain/Quake_Smart-seq2_Brain_Myeloid/stdout.txt", "w") as f:
    f.write(capio.stdout)
with open("build/brain/Quake_Smart-seq2_Brain_Myeloid/stderr.txt", "w") as f:
    f.write(capio.stderr)
utils.self_projection(quake_smart_seq2_brain_myeloid_blast, "build/brain/Quake_Smart-seq2_Brain_Myeloid")
%%writefile build/brain/Quake_Smart-seq2_Brain_Myeloid/predictable.txt
cell_ontology_class
cell_type1<jupyter_output><empty_output><jupyter_text>Quake_Smart-seq2_Brain_Non-Myeloid<jupyter_code>quake_smart_seq2_brain_non_myeloid = cb.data.ExprDataSet.read_dataset("../../Datasets/data/Quake_Smart-seq2_Brain_Non-Myeloid/data.h5")
utils.peek(quake_smart_seq2_brain_non_myeloid, "build/brain/Quake_Smart-seq2_Brain_Non-Myeloid")
quake_smart_seq2_brain_non_myeloid.obs.head()
quake_smart_seq2_brain_non_myeloid.obs["cluster"] = "cluster_" + quake_smart_seq2_brain_non_myeloid.obs["cluster"].astype(int).astype(str)
quake_smart_seq2_brain_non_myeloid.obs.dtypes
quake_smart_seq2_brain_non_myeloid_model = cb.directi.fit_DIRECTi(
    quake_smart_seq2_brain_non_myeloid, quake_smart_seq2_brain_non_myeloid.uns["seurat_genes"],
    **fixed_model_kwargs
) 
quake_smart_seq2_brain_non_myeloid.latent = quake_smart_seq2_brain_non_myeloid_model.inference(quake_smart_seq2_brain_non_myeloid)
ax = quake_smart_seq2_brain_non_myeloid.visualize_latent("cell_ontology_class", scatter_kws=dict(rasterized=True))
ax.get_figure().savefig("build/brain/Quake_Smart-seq2_Brain_Non-Myeloid/cell_ontology_class.svg", dpi=utils.DPI, bbox_inches="tight")
ax = quake_smart_seq2_brain_non_myeloid.visualize_latent("cell_type1", scatter_kws=dict(rasterized=True))
ax.get_figure().savefig("build/brain/Quake_Smart-seq2_Brain_Non-Myeloid/cell_type1.svg", dpi=utils.DPI, bbox_inches="tight")
ax = quake_smart_seq2_brain_non_myeloid.visualize_latent("cluster", scatter_kws=dict(rasterized=True))
ax.get_figure().savefig("build/brain/Quake_Smart-seq2_Brain_Non-Myeloid/cluster.svg", dpi=utils.DPI, bbox_inches="tight")
ax = quake_smart_seq2_brain_non_myeloid.visualize_latent("free_annotation", scatter_kws=dict(rasterized=True))
ax.get_figure().savefig("build/brain/Quake_Smart-seq2_Brain_Non-Myeloid/free_annotation.svg", dpi=utils.DPI, bbox_inches="tight")
ax = quake_smart_seq2_brain_non_myeloid.visualize_latent("donor", scatter_kws=dict(rasterized=True))
ax.get_figure().savefig("build/brain/Quake_Smart-seq2_Brain_Non-Myeloid/donor.svg", dpi=utils.DPI, bbox_inches="tight")
ax = quake_smart_seq2_brain_non_myeloid.visualize_latent("region", scatter_kws=dict(rasterized=True))
ax.get_figure().savefig("build/brain/Quake_Smart-seq2_Brain_Non-Myeloid/region.svg", dpi=utils.DPI, bbox_inches="tight")
quake_smart_seq2_brain_non_myeloid.write_dataset("build/brain/Quake_Smart-seq2_Brain_Non-Myeloid/Quake_Smart-seq2_Brain_Non-Myeloid.h5")
%%capture capio
quake_smart_seq2_brain_non_myeloid_models = [quake_smart_seq2_brain_non_myeloid_model]
for i in range(1, cb.config.N_JOBS):
    print("==== Model %d ====" % i)
    quake_smart_seq2_brain_non_myeloid_models.append(cb.directi.fit_DIRECTi(
        quake_smart_seq2_brain_non_myeloid, quake_smart_seq2_brain_non_myeloid.uns["seurat_genes"],
        **fixed_model_kwargs,
        random_seed=i
    ))
quake_smart_seq2_brain_non_myeloid_blast = cb.blast.BLAST(quake_smart_seq2_brain_non_myeloid_models, quake_smart_seq2_brain_non_myeloid)
quake_smart_seq2_brain_non_myeloid_blast.save("build/brain/Quake_Smart-seq2_Brain_Non-Myeloid")
with open("build/brain/Quake_Smart-seq2_Brain_Non-Myeloid/stdout.txt", "w") as f:
    f.write(capio.stdout)
with open("build/brain/Quake_Smart-seq2_Brain_Non-Myeloid/stderr.txt", "w") as f:
    f.write(capio.stderr)
utils.self_projection(quake_smart_seq2_brain_non_myeloid_blast, "build/brain/Quake_Smart-seq2_Brain_Non-Myeloid")
%%writefile build/brain/Quake_Smart-seq2_Brain_Non-Myeloid/predictable.txt
cell_ontology_class
cell_type1
cluster
free_annotation<jupyter_output><empty_output><jupyter_text>Lizard  Tosches_lizard<jupyter_code>tosches_lizard = cb.data.ExprDataSet.read_dataset("../../Datasets/data/Tosches_lizard/data.h5")
tosches_lizard.obs["donor"] = "donor_" + tosches_lizard.obs["donor"]
utils.peek(tosches_lizard, "build/brain/Tosches_lizard")
tosches_lizard.obs.head()
tosches_lizard.obs.dtypes
opt_model_kwargs = dict(batch_effect="donor")
tosches_lizard_model = cb.directi.fit_DIRECTi(
    tosches_lizard, tosches_lizard.uns["seurat_genes"],
    **fixed_model_kwargs, **opt_model_kwargs
) 
tosches_lizard.latent = tosches_lizard_model.inference(tosches_lizard)
ax = tosches_lizard.visualize_latent("cell_ontology_class", scatter_kws=dict(rasterized=True))
ax.get_figure().savefig("build/brain/Tosches_lizard/cell_ontology_class.svg", dpi=utils.DPI, bbox_inches="tight")
ax = tosches_lizard.visualize_latent("cell_type1", scatter_kws=dict(rasterized=True))
ax.get_figure().savefig("build/brain/Tosches_lizard/cell_type1.svg", dpi=utils.DPI, bbox_inches="tight")
ax = tosches_lizard.visualize_latent("donor", scatter_kws=dict(rasterized=True))
ax.get_figure().savefig("build/brain/Tosches_lizard/donor.svg", dpi=utils.DPI, bbox_inches="tight")
ax = tosches_lizard.visualize_latent("region", scatter_kws=dict(rasterized=True))
ax.get_figure().savefig("build/brain/Tosches_lizard/region.svg", dpi=utils.DPI, bbox_inches="tight")
tosches_lizard.write_dataset("build/brain/Tosches_lizard/Tosches_lizard.h5")
%%capture capio
tosches_lizard_models = [tosches_lizard_model]
for i in range(1, cb.config.N_JOBS):
    print("==== Model %d ====" % i)
    tosches_lizard_models.append(cb.directi.fit_DIRECTi(
        tosches_lizard, tosches_lizard.uns["seurat_genes"],
        **fixed_model_kwargs, **opt_model_kwargs,
        random_seed=i
    ))
tosches_lizard_blast = cb.blast.BLAST(tosches_lizard_models, tosches_lizard)
tosches_lizard_blast.save("build/brain/Tosches_lizard")
with open("build/brain/Tosches_lizard/stdout.txt", "w") as f:
    f.write(capio.stdout)
with open("build/brain/Tosches_lizard/stderr.txt", "w") as f:
    f.write(capio.stderr)
utils.self_projection(tosches_lizard_blast, "build/brain/Tosches_lizard")
%%writefile build/brain/Tosches_lizard/predictable.txt
cell_ontology_class
cell_type1<jupyter_output><empty_output><jupyter_text>Turtle  Tosches_turtle<jupyter_code>tosches_turtle = cb.data.ExprDataSet.read_dataset("../../Datasets/data/Tosches_turtle/data.h5")
tosches_turtle.obs["donor"] = "donor_" + tosches_turtle.obs["donor"]
utils.peek(tosches_turtle, "build/brain/Tosches_turtle")
tosches_turtle.obs.head()
tosches_turtle.obs.dtypes
opt_model_kwargs = dict(batch_effect="donor")
tosches_turtle_model = cb.directi.fit_DIRECTi(
    tosches_turtle, tosches_turtle.uns["seurat_genes"],
    **fixed_model_kwargs, **opt_model_kwargs
)
tosches_turtle.latent = tosches_turtle_model.inference(tosches_turtle)
ax = tosches_turtle.visualize_latent("cell_ontology_class", scatter_kws=dict(rasterized=True))
ax.get_figure().savefig("build/brain/Tosches_turtle/cell_ontology_class.svg", dpi=utils.DPI, bbox_inches="tight")
ax = tosches_turtle.visualize_latent("cell_type1", scatter_kws=dict(rasterized=True))
ax.get_figure().savefig("build/brain/Tosches_turtle/cell_type1.svg", dpi=utils.DPI, bbox_inches="tight")
ax = tosches_turtle.visualize_latent("region", scatter_kws=dict(rasterized=True))
ax.get_figure().savefig("build/brain/Tosches_turtle/region.svg", dpi=utils.DPI, bbox_inches="tight")
ax = tosches_turtle.visualize_latent("donor", scatter_kws=dict(rasterized=True))
ax.get_figure().savefig("build/brain/Tosches_turtle/donor.svg", dpi=utils.DPI, bbox_inches="tight")
tosches_turtle.write_dataset("build/brain/Tosches_turtle/Tosches_turtle.h5")
%%capture capio
tosches_turtle_models = [tosches_turtle_model]
for i in range(1, cb.config.N_JOBS):
    print("==== Model %d ====" % i)
    tosches_turtle_models.append(cb.directi.fit_DIRECTi(
        tosches_turtle, tosches_turtle.uns["seurat_genes"],
        **fixed_model_kwargs, **opt_model_kwargs,
        random_seed=i
    ))
tosches_turtle_blast = cb.blast.BLAST(tosches_turtle_models, tosches_turtle)
tosches_turtle_blast.save("build/brain/Tosches_turtle")
with open("build/brain/Tosches_turtle/stdout.txt", "w") as f:
    f.write(capio.stdout)
with open("build/brain/Tosches_turtle/stderr.txt", "w") as f:
    f.write(capio.stderr)
utils.self_projection(tosches_turtle_blast, "build/brain/Tosches_turtle")
%%writefile build/brain/Tosches_turtle/predictable.txt
cell_ontology_class
cell_type1
region<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13651779042363626, 'fraction_numerical': 0.017301833649479795, 'mean_word_length': 8.32368703108253, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, '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': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '343779', 'license': 'MIT', 'n_tokens_mistral': 7446, 'n_tokens_neox': 6996, 'n_words': 631, 'path': 'Notebooks/Database/brain.ipynb', 'repo_name': 'gao-lab/Cell_BLAST', 'size': '17397'}