<jupyter_start><jupyter_text>Figure Extended Data 9<jupyter_code>%load_ext autoreload
%autoreload 2
import scanpy as sc
from pathlib import Path
import numpy as np
import pandas as pd
import scrublet as scr

import matplotlib
import seaborn as sns
import matplotlib.pyplot as plt

%matplotlib inline
sns.set_style("white")

sc.settings.verbosity=3
import os, sys
sys.path.append(f"{os.getcwd()}/../code")
from plotting.plot_settings import *
from plotting.palettes import *
from plotting.util import fix_main_adata_annos
from plotting.chord import sankey
from plotting.fig1 import summary_figure_1d, summary_figure_1e<jupyter_output><empty_output><jupyter_text>Load data<jupyter_code>data_dir = f"{os.getcwd()}/../data"
org = sc.read(f"{data_dir}/org.h5ad")
idx = ~org.obs.source.isin(["tissue"])
org = org[idx].copy()
fig_dir = f"{os.getcwd()}/../figures"
key = "sample_type_rename"
src, dst = "nan", "UD"
cats = ["Ctrl", "EuE", "EcP", "EcPA"] + [dst]
org.obs[key] = org.obs[key].astype(str)
org.obs.loc[org.obs[key].isin([src]), key] = dst
org.obs[key] = org.obs[key].astype("category")
org.obs[key] = org.obs[key].cat.reorder_categories(cats)
org.obs["PID"] = org.obs["PID"].astype(str).fillna("MIX").astype("category")
org.obs["sampleid"].value_counts()<jupyter_output><empty_output><jupyter_text>Fig S9a<jupyter_code>sample_type_key = "sample_type_rename"
patient_key = "PID"
figX = summary_figure_1d(
    org, patient_key, sample_type_key, 
    x_palette=[], 
    left_palette=patient_palette, 
    right_palette=sample_type_palette,
    use_log=True,
    violin_limits = {
        "patient":     {"umis": (1000, 10000, 100000), "genes": (1000, 3000, 12000), "cells": (0, 2500, 5000)},
        "sample_type": {"umis": (1000, 10000, 100000), "genes": (1000, 3000, 12000), "cells": (0, 2000, 4000)},
    }
)
figX.savefig(f"{fig_dir}/figSX-pdo.pdf")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16578108395324123, 'fraction_numerical': 0.04410201912858661, 'mean_word_length': 5.872262773722627, 'pattern_counts': {'":': 8, '<': 13, '<?xml version=': 0, '>': 13, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '417735', 'license': 'MIT', 'n_tokens_mistral': 818, 'n_tokens_neox': 726, 'n_words': 139, 'path': 'notebooks/figure_ED9.ipynb', 'repo_name': 'TheJacksonLaboratory/endometriosis-scrnaseq', 'size': '1882'}