<jupyter_start><jupyter_text>Get data for only hepatocytes and rerun harmony+umap<jupyter_code># Reprocess t cell data
for ds in DS_LIST:
    print(ds)
    ind_select = dic_data_raw[ds].obs['cell_ontology_class']=='hepatocyte'
    adata = dic_data_raw[ds][ind_select,:].copy()
    sc.pp.filter_cells(adata, min_genes=250)
    sc.pp.filter_genes(adata, min_cells=50)
    adata.obs['batch_harmony'] = adata.obs['mouse.id']
    adata.obs['batch_harmony'] = adata.obs['batch_harmony'].astype('category')

    sc.pp.highly_variable_genes(adata, subset = False, min_disp=.5, 
                                min_mean=.0125, max_mean=10, n_bins=20, n_top_genes=None)
    sc.pp.scale(adata, max_value=10, zero_center=False)
    sc.pp.pca(adata, n_comps=50, use_highly_variable=True, svd_solver='arpack')
    sc.external.pp.harmony_integrate(adata, key='batch_harmony', max_iter_harmony=20)
    sc.pp.neighbors(adata, n_neighbors=50, n_pcs=20, use_rep="X_pca_harmony")
#     sc.pp.neighbors(adata, n_neighbors=50, n_pcs=20, use_rep="X_pca")
    sc.tl.leiden(adata, resolution=0.7)   
    sc.tl.umap(adata)
    sc.pl.umap(adata, color='cell_ontology_class')
    sc.pl.umap(adata, color='leiden')
    sc.pl.umap(adata, color=['age', 'sex', 'mouse.id', 'n_genes', 'subtissue'])
    adata.write('/n/holystore01/LABS/price_lab/Users/mjzhang/scTRS_data/single_cell_data/tms_proc/'
                'hep.%s.h5ad'%ds)
adata = read_h5ad('/n/holystore01/LABS/price_lab/Users/mjzhang/scTRS_data/single_cell_data/tms_proc/hep.droplet.h5ad')
# dic_cluster = {'0':'4', '1':'3','2':'1','3':'5','4':'0','5':'2'}
# adata.obs['leiden_old'] = adata.obs['leiden'].values
# adata.obs['leiden'] = [dic_cluster[x] for x in adata.obs['leiden_old']]
adata.obs = adata.obs.join(dic_score['droplet'])
sc.pl.umap(adata, color='leiden')
sc.pl.umap(adata, color='UKB_460K.biochemistry_LDLdirect.norm_score')
# sc.pl.umap(adata, color=['Pecam1', 'Nrp1', 'Kdr', 'Oit3'])
# sc.pl.umap(adata, color=['Clec4f', 'Cd68', 'Irf7'])
# sc.pl.umap(adata, color=['Alb', 'Ttr', 'Apoa1', 'Serpina1c'])
# adata.write('/n/holystore01/LABS/price_lab/Users/mjzhang/scTRS_data/single_cell_data/tms_proc/hep.facs_annot.h5ad')
temp_df = dic_data_raw['facs'][dic_data_raw['facs'].obs['cell_ontology_class']=='hepatocyte']\
    .obs.groupby(['subtissue', 'mouse.id']).agg({'cell':len})
temp_df.loc[~temp_df['cell'].isna()]<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1934673366834171, 'fraction_numerical': 0.02680067001675042, 'mean_word_length': 5.527322404371585, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '667962', 'license': 'MIT', 'n_tokens_mistral': 1082, 'n_tokens_neox': 1013, 'n_words': 109, 'path': 'experiments/job.case_hepatocyte/s1_reprocess_tms_droplet_hep.ipynb', 'repo_name': 'martinjzhang/scDRS', 'size': '2388'}