<jupyter_start><jupyter_text>Chronic Kidney Disease<jupyter_code>import pandas as pd
import ehrapy as ep
import seaborn as sns
import matplotlib.pyplot as plt
import warnings
warnings.filterwarnings("ignore")
pd.set_option("display.max_columns", None)<jupyter_output><empty_output><jupyter_text>Getting the dataset<jupyter_code>!wget -nc https://raw.githubusercontent.com/odsti/datasets/master/ckd/processed/ckd_full.csv<jupyter_output>File ‘ckd_full.csv’ already there; not retrieving.<jupyter_text>Data Wrangling<jupyter_code>data = pd.read_csv("ckd_full.csv")<jupyter_output><empty_output><jupyter_text>Since the dataset does not have a patient ID we add one.<jupyter_code>data["Patient_id"] = range(1, len(data) + 1)<jupyter_output><empty_output><jupyter_text>We replace nomial feartures with integers.<jupyter_code>data["Red Blood Cells"].replace(("normal", "abnormal"), (0, 1), inplace=True)
data["Pus Cell"].replace(("normal", "abnormal"), (0, 1), inplace=True)
data["Pus Cell clumps"].replace(("notpresent", "present"), (0, 1), inplace=True)
data["Bacteria"].replace(("notpresent", "present"), (0, 1), inplace=True)
data["Hypertension"].replace(("no", "yes"), (0, 1), inplace=True)
data["Diabetes Mellitus"].replace(("no", "yes"), (0, 1), inplace=True)
data["Coronary Artery Disease"].replace(("no", "yes"), (0, 1), inplace=True)
data["Appetite"].replace(("good", "poor"), (0, 1), inplace=True)
data["Pedal Edema"].replace(("no", "yes"), (0, 1), inplace=True)
data["Anemia"].replace(("no", "yes"), (0, 1), inplace=True)
data["Class"].replace(("notckd", "ckd"), (0, 1), inplace=True)
data.set_index("Patient_id", inplace=True)
data.to_csv("chronic_kidney_disease_prepared.csv")<jupyter_output><empty_output><jupyter_text>ehrapy sanity check<jupyter_code>adata = ep.io.read_csv("chronic_kidney_disease_prepared.csv",
                   index_column="Patient_id")
adata.var_names
ep.ad.type_overview(adata)
_ = ep.pp.qc_metrics(adata)
adata.obs
_ = sns.displot(adata.obs["missing_values_abs"])
plt.show()

_ = sns.displot(adata.obs["missing_values_pct"])
adata.var
ep.pp.knn_impute(adata)
ep.pp.norm_scale(adata)
ep.pp.pca(adata)
ep.pp.neighbors(adata)
ep.tl.umap(adata)
ep.tl.leiden(adata, resolution=0.5, key_added="leiden_0_5")
ep.pl.umap(adata, color=["leiden_0_5"], title="Leiden 0.5")
ep.pl.umap(adata, color=["Age", "Anemia", "Class",], ncols=1, wspace=0.75)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18583333333333332, 'fraction_numerical': 0.015, 'mean_word_length': 8.642570281124499, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 24, 'https://': 1, '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': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '83095', 'license': 'Apache-2.0', 'n_tokens_mistral': 973, 'n_tokens_neox': 920, 'n_words': 149, 'path': 'chronic_kidney_disease/chronic_kidney_disease.ipynb', 'repo_name': 'theislab/ehrapy-datasets', 'size': '2400'}