<jupyter_start><jupyter_text>Read data<jupyter_code>rna = anndata.read_h5ad("../../data/dataset/Cao-2020.h5ad")
atac = anndata.read_h5ad("../../data/dataset/Domcke-2020.h5ad")
rna_pp = anndata.read_h5ad("s01_preprocessing/rna.h5ad", backed="r")
atac_pp = anndata.read_h5ad("s01_preprocessing/atac.h5ad", backed="r")
graph = nx.read_graphml("s01_preprocessing/full.graphml.gz")<jupyter_output><empty_output><jupyter_text>Update meta<jupyter_code>rna.var["highly_variable"] = [item in rna_pp.var_names for item in rna.var_names]
atac.var["highly_variable"] = [item in atac_pp.var_names for item in atac.var_names]
rna.obs["pseudocell"] = rna_pp.obs["pseudocell"]
atac.obs["pseudocell"] = atac_pp.obs["pseudocell"]
rna.obs["organ_balancing"] = rna_pp.obs["organ_balancing"]
atac.obs["organ_balancing"] = atac_pp.obs["organ_balancing"]
rna.obs["n_cells"] = 1
atac.obs["n_cells"] = 1
rna.obsm["X_pca"] = rna_pp.obsm["X_pca"]
rna.obsm["X_umap"] = rna_pp.obsm["X_umap"]
atac.obsm["X_lsi"] = atac_pp.obsm["X_lsi"]
atac.obsm["X_umap"] = atac_pp.obsm["X_umap"]<jupyter_output><empty_output><jupyter_text>Aggregation<jupyter_code>rna_agg = scglue.data.aggregate_obs(
    rna, by="pseudocell", X_agg="sum",
    obs_agg={
        "cell_type": "majority", "Organ": "majority", "domain": "majority",
        "n_cells": "sum", "organ_balancing": "sum"
    },
    obsm_agg={"X_pca": "mean", "X_umap": "mean"}
)
rna_agg
atac_agg = scglue.data.aggregate_obs(
    atac, by="pseudocell", X_agg="sum",
    obs_agg={
        "cell_type": "majority", "tissue": "majority", "domain": "majority",
        "n_cells": "sum", "organ_balancing": "sum"
    },
    obsm_agg={"X_lsi": "mean", "X_umap": "mean"}
)
atac_agg<jupyter_output><empty_output><jupyter_text>Convert data<jupyter_code>atac2rna = anndata.AnnData(
    X=atac.X @ biadjacency_matrix(graph, atac.var_names, rna.var_names),
    obs=atac.obs, var=rna.var
)
atac2rna_agg = anndata.AnnData(
    X=atac_agg.X @ biadjacency_matrix(graph, atac_agg.var_names, rna_agg.var_names),
    obs=atac_agg.obs, var=rna_agg.var
)<jupyter_output><empty_output><jupyter_text>Save data<jupyter_code>rna.write(f"{PATH}/rna.h5ad", compression="gzip")
atac.write(f"{PATH}/atac.h5ad", compression="gzip")
atac2rna.write(f"{PATH}/atac2rna.h5ad", compression="gzip")
rna_agg.write(f"{PATH}/rna_agg.h5ad", compression="gzip")
atac_agg.write(f"{PATH}/atac_agg.h5ad", compression="gzip")
atac2rna_agg.write(f"{PATH}/atac2rna_agg.h5ad", compression="gzip")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18667201926936974, 'fraction_numerical': 0.014452027298273785, 'mean_word_length': 6.861198738170347, 'pattern_counts': {'":': 14, '<': 21, '<?xml version=': 0, '>': 21, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '529721', 'license': 'MIT', 'n_tokens_mistral': 1143, 'n_tokens_neox': 1116, 'n_words': 119, 'path': 'experiments/Atlas/e01_preprocessing.ipynb', 'repo_name': 'gao-lab/GLUE', 'size': '2491'}