Set up¶
In [ ]:
import scanpy as sc
import pandas as pd
import gc
Load the data¶
In [ ]:
src_dir = '../../data/Preprocessed_data'
methods = ['raw', 'scanorama', 'harmony', 'mnn', 'bbknn']
In [ ]:
tmp = pd.read_csv(f'{src_dir}/harmony_cellmarkers.csv', index_col=0)
tmp.head()
Out[Â ]:
batch | n_genes_by_counts | total_counts | total_counts_mt | pct_counts_mt | leiden | cell_type | |
---|---|---|---|---|---|---|---|
AAACCTGCACATCCAA-1 | GSM4932159_sample1 | 4037 | 22429.0 | 1991.0 | 8.876901 | 1 | Interstitial progenitor cell |
AAACCTGGTCGTCTTC-1 | GSM4932159_sample1 | 3238 | 13236.0 | 1065.0 | 8.046237 | 3 | Interstitial progenitor cell |
AAACCTGGTTCTGAAC-1 | GSM4932159_sample1 | 3490 | 14580.0 | 1470.0 | 10.082304 | 3 | Interstitial progenitor cell |
AAACCTGTCACTGGGC-1 | GSM4932159_sample1 | 4126 | 19526.0 | 1615.0 | 8.271023 | 1 | Interstitial progenitor cell |
AAACCTGTCCCTGACT-1 | GSM4932159_sample1 | 5123 | 34047.0 | 1737.0 | 5.101771 | 7 | Cartilage progenitor cell |
Clustering comparison between different batch correction methods¶
In [ ]:
for method in methods:
adata = sc.read(f'{src_dir}/preprocessed_{method}.h5ad')
adata.obs['cell_type'] = tmp.cell_type
adata.obs['cell_type'] = adata.obs['cell_type'].astype('category')
sc.pl.umap(adata, color=['batch', 'cell_type'], title=['Batches', f'{method} UMAP'],
frameon=False, legend_fontweight='normal', legend_fontsize=15)
gc.collect()
/Users/Shared/anaconda3/envs/IDIMENSIONS/lib/python3.9/site-packages/anndata/_core/anndata.py:1818: UserWarning: Observation names are not unique. To make them unique, call `.obs_names_make_unique`. utils.warn_names_duplicates("obs")
/Users/Shared/anaconda3/envs/IDIMENSIONS/lib/python3.9/site-packages/anndata/_core/anndata.py:1818: UserWarning: Observation names are not unique. To make them unique, call `.obs_names_make_unique`. utils.warn_names_duplicates("obs")
/Users/Shared/anaconda3/envs/IDIMENSIONS/lib/python3.9/site-packages/anndata/_core/anndata.py:1818: UserWarning: Observation names are not unique. To make them unique, call `.obs_names_make_unique`. utils.warn_names_duplicates("obs")
/Users/Shared/anaconda3/envs/IDIMENSIONS/lib/python3.9/site-packages/anndata/_core/anndata.py:1818: UserWarning: Observation names are not unique. To make them unique, call `.obs_names_make_unique`. utils.warn_names_duplicates("obs")
/Users/Shared/anaconda3/envs/IDIMENSIONS/lib/python3.9/site-packages/anndata/_core/anndata.py:1818: UserWarning: Observation names are not unique. To make them unique, call `.obs_names_make_unique`. utils.warn_names_duplicates("obs")