{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "bfb56630-274e-471e-8d73-6e819e3a2aa7", "metadata": { "tags": [] }, "outputs": [], "source": [ "import celltypist\n", "from celltypist import models\n", "import scanpy as sc\n", "import pandas as pd \n", "import numpy as np\n", "import anndata\n", "import re\n", "import h5py\n", "import scipy.sparse as scs\n", "import concurrent.futures\n", "import scanpy.external as sce\n", "import gc\n", "from concurrent.futures import ProcessPoolExecutor\n", "import copy" ] }, { "cell_type": "code", "execution_count": 2, "id": "5219cccf-6813-47d7-a30f-cc059789743e", "metadata": { "tags": [] }, "outputs": [], "source": [ "adata=sc.read_h5ad('/home/jupyter/reference_generating_new/NK/NKcells_processed_2023-11-22.h5ad')" ] }, { "cell_type": "code", "execution_count": 3, "id": "50571812-fb58-470c-aebc-237d2b02396f", "metadata": { "tags": [] }, "outputs": [ { "data": { "text/plain": [ "(159245, 57)" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "np.shape(adata.obs)" ] }, { "cell_type": "code", "execution_count": 4, "id": "d5d070d7-bebb-4a16-a83a-ac28ee3fa249", "metadata": { "tags": [] }, "outputs": [], "source": [ "NK_Cells_Annotation=pd.read_csv('NK_Cells_Res1.5_Annotation.csv')\n", "NK_Cells_Annotation['leiden_resolution_1.5']=[str (x) for x in NK_Cells_Annotation['leiden_resolution_1.5']]" ] }, { "cell_type": "code", "execution_count": 5, "id": "e402c976-5bc1-49e0-9ede-ac3a17beeca3", "metadata": { "tags": [] }, "outputs": [], "source": [ "NK_Cells_Annotation=NK_Cells_Annotation.query(\"AIFI_L2_Final=='Yes' & AIFI_L3_Final=='Yes'\")" ] }, { "cell_type": "code", "execution_count": 6, "id": "f89b4982-0282-43a5-bc0d-93a102adf023", "metadata": { "tags": [] }, "outputs": [], "source": [ "adata.obs=adata.obs.merge(NK_Cells_Annotation, on=[\"leiden_resolution_1.5\"], how=\"left\")" ] }, { "cell_type": "code", "execution_count": 7, "id": "bd7302cd-5994-4113-8ef7-006642570e3f", "metadata": { "tags": [] }, "outputs": [], "source": [ "df_Part_1=adata.obs[adata.obs['leiden_resolution_1.5'].isin(NK_Cells_Annotation['leiden_resolution_1.5'])]" ] }, { "cell_type": "code", "execution_count": 8, "id": "6e0f3ba5-a9a0-47b3-8752-644bc74dd92b", "metadata": { "tags": [] }, "outputs": [], "source": [ "df_Part_1.to_parquet(\"Annotation_Part_1.parquet\")" ] }, { "cell_type": "code", "execution_count": null, "id": "58e23d7d-6b59-442b-9e81-2b033a55f0cf", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python [conda env:root] *", "language": "python", "name": "conda-root-py" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.12" } }, "nbformat": 4, "nbformat_minor": 5 }