import celltypist
from celltypist import models
import scanpy as sc
import pandas as pd
import numpy as np
import anndata
import re
import h5py
import scipy.sparse as scs
import concurrent.futures
import scanpy.external as sce
import gc
from concurrent.futures import ProcessPoolExecutor
import copy
adata=sc.read_h5ad('/home/jupyter/reference_generating_new/NK/NKcells_processed_2023-11-22.h5ad')
np.shape(adata.obs)
(159245, 57)
NK_Cells_Annotation=pd.read_csv('NK_Cells_Res1.5_Annotation.csv')
NK_Cells_Annotation['leiden_resolution_1.5']=[str (x) for x in NK_Cells_Annotation['leiden_resolution_1.5']]
NK_Cells_Annotation=NK_Cells_Annotation.query("AIFI_L2_Final=='Yes' & AIFI_L3_Final=='Yes'")
adata.obs=adata.obs.merge(NK_Cells_Annotation, on=["leiden_resolution_1.5"], how="left")
df_Part_1=adata.obs[adata.obs['leiden_resolution_1.5'].isin(NK_Cells_Annotation['leiden_resolution_1.5'])]
df_Part_1.to_parquet("Annotation_Part_1.parquet")