{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## 数据处理:SMILES信息在Gene里,CP里面没有,所以首先在这里实现映射和对齐" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import pandas as pd\n", "import matplotlib.pyplot as plt\n", "import seaborn as sns\n", "import os\n", "import h5py\n", "\n", "def load_from_HDF(fname):\n", " \"\"\"Load data from a HDF5 file to a dictionary.\"\"\"\n", " data = dict()\n", " with h5py.File(fname, 'r') as f:\n", " for key in f:\n", " data[key] = np.asarray(f[key])\n", " if isinstance(data[key][0], np.bytes_):\n", " data[key] = data[key].astype(str)\n", " return data" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(18540, 606) (6929, 980)\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
pert_dosedet_plateCPD_SMILES221227_x_at212345_s_at218597_s_at217140_s_at209253_at214404_x_at219888_at...218397_at202996_at204608_at211071_s_at203341_at202801_at206414_s_at204978_at205379_at203897_at
050.0PAC001_U2OS_6H_X1_B1_UNI4445LCC(C)[C@H](CO)Nc1nc(Nc2cc(N)cc(Cl)c2)c2ncn(C(C...-0.118505-0.293445-0.2940880.292745-0.1458960.973580.247915...-0.5299050.8049920.430269-0.97559-1.7406050.3403820.4987780.3521520.535910.52484
112.7PAC001_U2OS_6H_X1_B1_UNI4445LIc1cccc(CSc2nnc(o2)-c2ccncc2)c10.043264-0.264945-0.0006330.0009350.177604-0.504720.214315...0.228895-0.3813080.5569690.25051-0.025625-0.024428-0.2251220.533052-0.19329-0.25436
250.0PAC001_U2OS_6H_X1_B1_UNI4445LClc1cc(Cl)c(NC(=O)Nc2ccncc2)c(Cl)c1-0.0708050.1957550.004606-0.040855-0.067346-0.19872-0.053195...-0.031795-0.051728-0.0177410.056810.1306950.005919-0.408722-0.057177-0.256990.31004
316.2PAC001_U2OS_6H_X1_B1_UNI4445LCOc1ccc(CNC(=O)Nc2ncc(s2)[N+]([O-])=O)cc10.027165-0.1495450.173113-0.100695-0.309296-0.20782-0.323985...-0.013787-0.1776080.219869-0.161290.365195-0.040848-0.2511220.0407320.17091-0.05144
412.5PAC001_U2OS_6H_X1_B1_UNI4445LOC(=O)c1ccc2c3nc4ccccc4n3c(=O)c3cccc1c230.3032940.254455-0.055418-0.0536350.000455-0.109080.031425...-0.052585-0.1961080.2454690.007840.093595-0.3034180.474878-0.022947-0.285890.06423
\n", "

5 rows × 980 columns

\n", "
" ], "text/plain": [ " pert_dose det_plate \\\n", "0 50.0 PAC001_U2OS_6H_X1_B1_UNI4445L \n", "1 12.7 PAC001_U2OS_6H_X1_B1_UNI4445L \n", "2 50.0 PAC001_U2OS_6H_X1_B1_UNI4445L \n", "3 16.2 PAC001_U2OS_6H_X1_B1_UNI4445L \n", "4 12.5 PAC001_U2OS_6H_X1_B1_UNI4445L \n", "\n", " CPD_SMILES 221227_x_at \\\n", "0 CC(C)[C@H](CO)Nc1nc(Nc2cc(N)cc(Cl)c2)c2ncn(C(C... -0.118505 \n", "1 Ic1cccc(CSc2nnc(o2)-c2ccncc2)c1 0.043264 \n", "2 Clc1cc(Cl)c(NC(=O)Nc2ccncc2)c(Cl)c1 -0.070805 \n", "3 COc1ccc(CNC(=O)Nc2ncc(s2)[N+]([O-])=O)cc1 0.027165 \n", "4 OC(=O)c1ccc2c3nc4ccccc4n3c(=O)c3cccc1c23 0.303294 \n", "\n", " 212345_s_at 218597_s_at 217140_s_at 209253_at 214404_x_at 219888_at \\\n", "0 -0.293445 -0.294088 0.292745 -0.145896 0.97358 0.247915 \n", "1 -0.264945 -0.000633 0.000935 0.177604 -0.50472 0.214315 \n", "2 0.195755 0.004606 -0.040855 -0.067346 -0.19872 -0.053195 \n", "3 -0.149545 0.173113 -0.100695 -0.309296 -0.20782 -0.323985 \n", "4 0.254455 -0.055418 -0.053635 0.000455 -0.10908 0.031425 \n", "\n", " ... 218397_at 202996_at 204608_at 211071_s_at 203341_at 202801_at \\\n", "0 ... -0.529905 0.804992 0.430269 -0.97559 -1.740605 0.340382 \n", "1 ... 0.228895 -0.381308 0.556969 0.25051 -0.025625 -0.024428 \n", "2 ... -0.031795 -0.051728 -0.017741 0.05681 0.130695 0.005919 \n", "3 ... -0.013787 -0.177608 0.219869 -0.16129 0.365195 -0.040848 \n", "4 ... -0.052585 -0.196108 0.245469 0.00784 0.093595 -0.303418 \n", "\n", " 206414_s_at 204978_at 205379_at 203897_at \n", "0 0.498778 0.352152 0.53591 0.52484 \n", "1 -0.225122 0.533052 -0.19329 -0.25436 \n", "2 -0.408722 -0.057177 -0.25699 0.31004 \n", "3 -0.251122 0.040732 0.17091 -0.05144 \n", "4 0.474878 -0.022947 -0.28589 0.06423 \n", "\n", "[5 rows x 980 columns]" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "CP_path = './CP_data.parquet'\n", "GE_path = './GE_data.parquet'\n", "\n", "CP_CSV = pd.read_parquet(CP_path)\n", "GE_CSV = pd.read_parquet(GE_path)\n", "print(CP_CSV.shape, GE_CSV.shape)\n", "GE_CSV.head()" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Metadata_moaMetadata_mmoles_per_liter2SMILESMetadata_PlateCells_AreaShape_Center_XCells_AreaShape_CompactnessCells_AreaShape_ExtentCells_AreaShape_FormFactorCells_AreaShape_OrientationCells_AreaShape_Perimeter...Nuclei_Texture_SumEntropy_DNA_10_0Nuclei_Texture_SumEntropy_ER_10_0Nuclei_Texture_SumEntropy_Mito_3_0Nuclei_Texture_SumEntropy_RNA_5_0Nuclei_Texture_SumVariance_ER_10_0Nuclei_Texture_SumVariance_RNA_10_0Nuclei_Texture_Variance_AGP_10_0Nuclei_Texture_Variance_ER_10_0Nuclei_Texture_Variance_Mito_10_0Nuclei_Texture_Variance_RNA_10_0
0local anesthetic6.05CCCOc1cc(N)ccc1C(=O)OCCN(CC)CC24277-0.0703460.256710-0.114990-0.237090-0.0379280.525950...0.0990290.271039-0.0104270.1189970.006318-0.024573-0.362861-0.199743-0.3298320.066800
1cannabinoid receptor antagonist10.00COc1cc(C)cc(OC)c1[C@@H]1C=C(C)CC[C@H]1C(C)=C242770.0413800.0509620.051053-0.0337330.0647110.298818...-0.0424740.254293-0.0585600.065822-0.089380-0.041392-0.220610-0.154711-0.1160720.174417
2None10.00COc1cc(O)cc(\\C=C\\c2ccccc2)c124277-0.130346-0.0981850.0442120.164668-0.1309040.001828...0.0979920.2303310.0298910.0797770.020954-0.0896330.075818-0.021001-0.0286610.115051
3interleukin inhibitor10.00COc1c(O)cc2C(=O)O[C@H]3[C@@H](O)[C@H](O)[C@@H]...24277-0.3165550.410722-0.236208-0.055084-0.0998760.503035...0.3890630.2083470.0154080.3391000.0311780.103611-0.070876-0.044751-0.0095910.322316
4bacterial cell wall synthesis inhibitor4.39CCOc1ccc2ccccc2c1C(=O)N[C@H]1[C@H]2SC(C)(C)[C@...24277-0.0475870.248559-0.0200580.0857720.0963940.545575...0.6103440.4268260.1188730.4156230.3397940.238471-0.157253-0.002357-0.0573820.437593
\n", "

5 rows × 606 columns

\n", "
" ], "text/plain": [ " Metadata_moa Metadata_mmoles_per_liter2 \\\n", "0 local anesthetic 6.05 \n", "1 cannabinoid receptor antagonist 10.00 \n", "2 None 10.00 \n", "3 interleukin inhibitor 10.00 \n", "4 bacterial cell wall synthesis inhibitor 4.39 \n", "\n", " SMILES Metadata_Plate \\\n", "0 CCCOc1cc(N)ccc1C(=O)OCCN(CC)CC 24277 \n", "1 COc1cc(C)cc(OC)c1[C@@H]1C=C(C)CC[C@H]1C(C)=C 24277 \n", "2 COc1cc(O)cc(\\C=C\\c2ccccc2)c1 24277 \n", "3 COc1c(O)cc2C(=O)O[C@H]3[C@@H](O)[C@H](O)[C@@H]... 24277 \n", "4 CCOc1ccc2ccccc2c1C(=O)N[C@H]1[C@H]2SC(C)(C)[C@... 24277 \n", "\n", " Cells_AreaShape_Center_X Cells_AreaShape_Compactness \\\n", "0 -0.070346 0.256710 \n", "1 0.041380 0.050962 \n", "2 -0.130346 -0.098185 \n", "3 -0.316555 0.410722 \n", "4 -0.047587 0.248559 \n", "\n", " Cells_AreaShape_Extent Cells_AreaShape_FormFactor \\\n", "0 -0.114990 -0.237090 \n", "1 0.051053 -0.033733 \n", "2 0.044212 0.164668 \n", "3 -0.236208 -0.055084 \n", "4 -0.020058 0.085772 \n", "\n", " Cells_AreaShape_Orientation Cells_AreaShape_Perimeter ... \\\n", "0 -0.037928 0.525950 ... \n", "1 0.064711 0.298818 ... \n", "2 -0.130904 0.001828 ... \n", "3 -0.099876 0.503035 ... \n", "4 0.096394 0.545575 ... \n", "\n", " Nuclei_Texture_SumEntropy_DNA_10_0 Nuclei_Texture_SumEntropy_ER_10_0 \\\n", "0 0.099029 0.271039 \n", "1 -0.042474 0.254293 \n", "2 0.097992 0.230331 \n", "3 0.389063 0.208347 \n", "4 0.610344 0.426826 \n", "\n", " Nuclei_Texture_SumEntropy_Mito_3_0 Nuclei_Texture_SumEntropy_RNA_5_0 \\\n", "0 -0.010427 0.118997 \n", "1 -0.058560 0.065822 \n", "2 0.029891 0.079777 \n", "3 0.015408 0.339100 \n", "4 0.118873 0.415623 \n", "\n", " Nuclei_Texture_SumVariance_ER_10_0 Nuclei_Texture_SumVariance_RNA_10_0 \\\n", "0 0.006318 -0.024573 \n", "1 -0.089380 -0.041392 \n", "2 0.020954 -0.089633 \n", "3 0.031178 0.103611 \n", "4 0.339794 0.238471 \n", "\n", " Nuclei_Texture_Variance_AGP_10_0 Nuclei_Texture_Variance_ER_10_0 \\\n", "0 -0.362861 -0.199743 \n", "1 -0.220610 -0.154711 \n", "2 0.075818 -0.021001 \n", "3 -0.070876 -0.044751 \n", "4 -0.157253 -0.002357 \n", "\n", " Nuclei_Texture_Variance_Mito_10_0 Nuclei_Texture_Variance_RNA_10_0 \n", "0 -0.329832 0.066800 \n", "1 -0.116072 0.174417 \n", "2 -0.028661 0.115051 \n", "3 -0.009591 0.322316 \n", "4 -0.057382 0.437593 \n", "\n", "[5 rows x 606 columns]" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "CP_CSV.head()" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "((20342,), (21782,))" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "CP_CSV['SMILES'].unique().shape, GE_CSV['CPD_SMILES'].unique().shape # 包含 NaN的" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "((1917,), (1917,))" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# 填充nan为 DMSO\n", "CP_CSV['SMILES'] = CP_CSV['SMILES'].fillna('DMSO')\n", "GE_CSV['CPD_SMILES'] = GE_CSV['CPD_SMILES'].fillna('DMSO')\n", "\n", "CP_CSV['SMILES'].unique().shape, GE_CSV['CPD_SMILES'].unique().shape # 包含 NaN的" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# 确保这两个CSV包含相同的SMILES" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "交集数量: 1917\n", "示例交集: ['COc1ccc2c(c1)occc2=O', 'OC(=O)\\\\C=C\\\\c1ccc(Cn2ccnc2)cc1', 'Cc1ccccc1C(=O)c1ccc(Nc2ccc(Br)cc2N)cc1Cl']\n" ] } ], "source": [ "# 转换成集合\n", "set_cp = set(CP_CSV['SMILES'].unique())\n", "set_ge = set(GE_CSV['CPD_SMILES'].dropna().unique())\n", "\n", "# 求交集\n", "common_smiles = set_cp & set_ge\n", "\n", "print(f\"交集数量: {len(common_smiles)}\")\n", "print(\"示例交集:\", list(common_smiles)[:3]) # 只看前10个" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(6929, 980) (18540, 606)\n" ] } ], "source": [ "# 删除Gene中不在交集的行\n", "GE_CSV_matched = GE_CSV[GE_CSV['CPD_SMILES'].isin(common_smiles)].copy()\n", "# 删除CellPainting中不在交集的行\n", "CP_CSV_matched = CP_CSV[CP_CSV['SMILES'].isin(common_smiles)].copy()\n", "print(GE_CSV_matched.shape, CP_CSV_matched.shape) # (113416, 898) (68120, 980)" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "# 更新文件, 后续可以用来做数据填补\n", "\n", "CP_CSV_matched.to_parquet('./CP_data.parquet', index=False)\n", "GE_CSV_matched.to_parquet('./GE_data.parquet', index=False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 数据对齐\n", "\n", "### 对齐逻辑:数据清洗,各自生成对齐数据即可" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "DataFrame 中存在 NaN 值\n", "包含 NaN 的列: 12\n", "包含 NaN 的行:\n", " 8627\n", "整个 DataFrame 中 NaN 的总数: 11896\n" ] } ], "source": [ "# 检查整个 DataFrame 中是否存在 NaN\n", "if CP_CSV_matched.isna().any().any():\n", " print(\"DataFrame 中存在 NaN 值\")\n", "else:\n", " print(\"DataFrame 中不存在 NaN 值\")\n", "\n", "# 检查每一列是否存在 NaN\n", "nan_columns = CP_CSV_matched.columns[CP_CSV_matched.isna().any()].tolist()\n", "print(\"包含 NaN 的列:\", len(nan_columns))\n", "\n", "# 检查每一行是否存在 NaN\n", "nan_rows = CP_CSV_matched[CP_CSV_matched.isna().any(axis=1)]\n", "print(\"包含 NaN 的行:\\n\", len(nan_rows))\n", "\n", "# 检查整个 DataFrame 中 NaN 的总数\n", "total_nans = CP_CSV_matched.isna().sum().sum()\n", "print(f\"整个 DataFrame 中 NaN 的总数: {total_nans}\")" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "清洗后 DataFrame 形状: (18540, 605)\n", "NaN 剩余数量: 3754\n" ] } ], "source": [ "import pandas as pd\n", "\n", "# 假设 CP_CSV_matched 已经加载好了\n", "df = CP_CSV_matched.copy()\n", "\n", "# 1. 删除 NaN 占比 > 20% 的列\n", "col_thresh = 0.2\n", "row_thresh = 0.2\n", "\n", "# 列筛选\n", "valid_cols = df.columns[df.isnull().mean() <= col_thresh]\n", "\n", "# 行筛选\n", "valid_rows = df.index[df.isnull().mean(axis=1) <= row_thresh]\n", "\n", "# 保留行和列\n", "df = df.loc[valid_rows, valid_cols]\n", "\n", "print(f\"清洗后 DataFrame 形状: {df.shape}\")\n", "print(\"NaN 剩余数量:\", df.isnull().sum().sum())" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(18540, 605) (18540, 606)\n" ] } ], "source": [ "print(df.shape, CP_CSV_matched.shape)" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "NaN 剩余数量: 3754\n" ] } ], "source": [ "print(\"NaN 剩余数量:\", df.isnull().sum().sum())" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Metadata_moaMetadata_mmoles_per_liter2SMILESMetadata_PlateCells_AreaShape_Center_XCells_AreaShape_CompactnessCells_AreaShape_ExtentCells_AreaShape_FormFactorCells_AreaShape_OrientationCells_AreaShape_Perimeter...Nuclei_Texture_SumEntropy_DNA_10_0Nuclei_Texture_SumEntropy_ER_10_0Nuclei_Texture_SumEntropy_Mito_3_0Nuclei_Texture_SumEntropy_RNA_5_0Nuclei_Texture_SumVariance_ER_10_0Nuclei_Texture_SumVariance_RNA_10_0Nuclei_Texture_Variance_AGP_10_0Nuclei_Texture_Variance_ER_10_0Nuclei_Texture_Variance_Mito_10_0Nuclei_Texture_Variance_RNA_10_0
0local anesthetic6.05CCCOc1cc(N)ccc1C(=O)OCCN(CC)CC24277-0.0703460.256710-0.114990-0.237090-0.0379280.525950...0.0990290.271039-0.0104270.1189970.006318-0.024573-0.362861-0.199743-0.3298320.066800
1cannabinoid receptor antagonist10.00COc1cc(C)cc(OC)c1[C@@H]1C=C(C)CC[C@H]1C(C)=C242770.0413800.0509620.051053-0.0337330.0647110.298818...-0.0424740.254293-0.0585600.065822-0.089380-0.041392-0.220610-0.154711-0.1160720.174417
2None10.00COc1cc(O)cc(\\C=C\\c2ccccc2)c124277-0.130346-0.0981850.0442120.164668-0.1309040.001828...0.0979920.2303310.0298910.0797770.020954-0.0896330.075818-0.021001-0.0286610.115051
3interleukin inhibitor10.00COc1c(O)cc2C(=O)O[C@H]3[C@@H](O)[C@H](O)[C@@H]...24277-0.3165550.410722-0.236208-0.055084-0.0998760.503035...0.3890630.2083470.0154080.3391000.0311780.103611-0.070876-0.044751-0.0095910.322316
4bacterial cell wall synthesis inhibitor4.39CCOc1ccc2ccccc2c1C(=O)N[C@H]1[C@H]2SC(C)(C)[C@...24277-0.0475870.248559-0.0200580.0857720.0963940.545575...0.6103440.4268260.1188730.4156230.3397940.238471-0.157253-0.002357-0.0573820.437593
\n", "

5 rows × 606 columns

\n", "
" ], "text/plain": [ " Metadata_moa Metadata_mmoles_per_liter2 \\\n", "0 local anesthetic 6.05 \n", "1 cannabinoid receptor antagonist 10.00 \n", "2 None 10.00 \n", "3 interleukin inhibitor 10.00 \n", "4 bacterial cell wall synthesis inhibitor 4.39 \n", "\n", " SMILES Metadata_Plate \\\n", "0 CCCOc1cc(N)ccc1C(=O)OCCN(CC)CC 24277 \n", "1 COc1cc(C)cc(OC)c1[C@@H]1C=C(C)CC[C@H]1C(C)=C 24277 \n", "2 COc1cc(O)cc(\\C=C\\c2ccccc2)c1 24277 \n", "3 COc1c(O)cc2C(=O)O[C@H]3[C@@H](O)[C@H](O)[C@@H]... 24277 \n", "4 CCOc1ccc2ccccc2c1C(=O)N[C@H]1[C@H]2SC(C)(C)[C@... 24277 \n", "\n", " Cells_AreaShape_Center_X Cells_AreaShape_Compactness \\\n", "0 -0.070346 0.256710 \n", "1 0.041380 0.050962 \n", "2 -0.130346 -0.098185 \n", "3 -0.316555 0.410722 \n", "4 -0.047587 0.248559 \n", "\n", " Cells_AreaShape_Extent Cells_AreaShape_FormFactor \\\n", "0 -0.114990 -0.237090 \n", "1 0.051053 -0.033733 \n", "2 0.044212 0.164668 \n", "3 -0.236208 -0.055084 \n", "4 -0.020058 0.085772 \n", "\n", " Cells_AreaShape_Orientation Cells_AreaShape_Perimeter ... \\\n", "0 -0.037928 0.525950 ... \n", "1 0.064711 0.298818 ... \n", "2 -0.130904 0.001828 ... \n", "3 -0.099876 0.503035 ... \n", "4 0.096394 0.545575 ... \n", "\n", " Nuclei_Texture_SumEntropy_DNA_10_0 Nuclei_Texture_SumEntropy_ER_10_0 \\\n", "0 0.099029 0.271039 \n", "1 -0.042474 0.254293 \n", "2 0.097992 0.230331 \n", "3 0.389063 0.208347 \n", "4 0.610344 0.426826 \n", "\n", " Nuclei_Texture_SumEntropy_Mito_3_0 Nuclei_Texture_SumEntropy_RNA_5_0 \\\n", "0 -0.010427 0.118997 \n", "1 -0.058560 0.065822 \n", "2 0.029891 0.079777 \n", "3 0.015408 0.339100 \n", "4 0.118873 0.415623 \n", "\n", " Nuclei_Texture_SumVariance_ER_10_0 Nuclei_Texture_SumVariance_RNA_10_0 \\\n", "0 0.006318 -0.024573 \n", "1 -0.089380 -0.041392 \n", "2 0.020954 -0.089633 \n", "3 0.031178 0.103611 \n", "4 0.339794 0.238471 \n", "\n", " Nuclei_Texture_Variance_AGP_10_0 Nuclei_Texture_Variance_ER_10_0 \\\n", "0 -0.362861 -0.199743 \n", "1 -0.220610 -0.154711 \n", "2 0.075818 -0.021001 \n", "3 -0.070876 -0.044751 \n", "4 -0.157253 -0.002357 \n", "\n", " Nuclei_Texture_Variance_Mito_10_0 Nuclei_Texture_Variance_RNA_10_0 \n", "0 -0.329832 0.066800 \n", "1 -0.116072 0.174417 \n", "2 -0.028661 0.115051 \n", "3 -0.009591 0.322316 \n", "4 -0.057382 0.437593 \n", "\n", "[5 rows x 606 columns]" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "CP_CSV_matched.head()\n", "\n", "# nan_count = CP_CSV_matched['Metadata_mmoles_per_liter2'].isna().sum()\n", "# print(f\"NaN count in SMILES: {nan_count}\")" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "清洗后 DataFrame 形状: (18540, 605)\n", "NaN 剩余数量 (第一轮清洗后): 3754\n", "DataFrame 最终填充完成。\n", "NaN 剩余数量 (最终): 0\n", "最终 DataFrame 形状: (18540, 605)\n" ] } ], "source": [ "import pandas as pd\n", "import numpy as np\n", "\n", "# 你的初始数据清洗步骤\n", "# 假设 CP_CSV_matched 已经加载好了\n", "df = CP_CSV_matched.copy()\n", "\n", "# 1. 删除 NaN 占比 > 20% 的列和行\n", "col_thresh = 0.2\n", "row_thresh = 0.2\n", "\n", "# 列筛选\n", "valid_cols = df.columns[df.isnull().mean() <= col_thresh]\n", "df = df[valid_cols]\n", "\n", "# 行筛选\n", "valid_rows = df.index[df.isnull().mean(axis=1) <= row_thresh]\n", "df = df.loc[valid_rows]\n", "\n", "print(f\"清洗后 DataFrame 形状: {df.shape}\")\n", "print(\"NaN 剩余数量 (第一轮清洗后):\", df.isnull().sum().sum())\n", "\n", "# --- 最终填充方案 ---\n", "\n", "# 2. 强制转换所有列为数值类型\n", "# `errors='coerce'` 会将任何非数值数据(如空字符串、'-')强制转换为 NaN\n", "# 这一步是关键,它将所有需要填充的数据统一为 NaN\n", "# 我们需要保留 SMILES 列,因为它不是数值\n", "smiles_col = 'SMILES' # 假设 SMILES 列名为 canonical_smiles\n", "if smiles_col in df.columns:\n", " df_numeric = df.drop(columns=[smiles_col]).apply(pd.to_numeric, errors='coerce')\n", " df_numeric[smiles_col] = df[smiles_col]\n", "else:\n", " df_numeric = df.apply(pd.to_numeric, errors='coerce')\n", "\n", "# 3. 用中位数填充剩余的 NaN\n", "# 中位数对异常值不敏感,是填充数据的好选择\n", "# fillna() 会用 Series 的中位数来填充其 NaN 值\n", "# .median() 会自动跳过 NaN 值进行计算\n", "df_filled = df_numeric.fillna(df_numeric.median(numeric_only=True))\n", "\n", "# 4. 再次检查,确保没有剩余的 NaN\n", "# 如果有某一列在转换后全变成了 NaN(比如该列原本都是非数值),那么它的中位数也会是 NaN\n", "# 我们可以将这些剩余的 NaN 填充为 0\n", "df_filled = df_filled.fillna(0)\n", "\n", "print(\"DataFrame 最终填充完成。\")\n", "print(\"NaN 剩余数量 (最终):\", df_filled.isnull().sum().sum())\n", "print(\"最终 DataFrame 形状:\", df_filled.shape)" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Metadata_mmoles_per_liter2Metadata_PlateCells_AreaShape_Center_XCells_AreaShape_CompactnessCells_AreaShape_ExtentCells_AreaShape_FormFactorCells_AreaShape_OrientationCells_AreaShape_PerimeterCells_AreaShape_SolidityCells_AreaShape_Zernike_1_1...Nuclei_Texture_SumEntropy_ER_10_0Nuclei_Texture_SumEntropy_Mito_3_0Nuclei_Texture_SumEntropy_RNA_5_0Nuclei_Texture_SumVariance_ER_10_0Nuclei_Texture_SumVariance_RNA_10_0Nuclei_Texture_Variance_AGP_10_0Nuclei_Texture_Variance_ER_10_0Nuclei_Texture_Variance_Mito_10_0Nuclei_Texture_Variance_RNA_10_0SMILES
06.0524277-0.0703460.256710-0.114990-0.237090-0.0379280.5259500.0727950.008488...0.271039-0.0104270.1189970.006318-0.024573-0.362861-0.199743-0.3298320.066800CCCOc1cc(N)ccc1C(=O)OCCN(CC)CC
110.00242770.0413800.0509620.051053-0.0337330.0647110.2988180.145941-0.070826...0.254293-0.0585600.065822-0.089380-0.041392-0.220610-0.154711-0.1160720.174417COc1cc(C)cc(OC)c1[C@@H]1C=C(C)CC[C@H]1C(C)=C
210.0024277-0.130346-0.0981850.0442120.164668-0.1309040.0018280.0947360.119333...0.2303310.0298910.0797770.020954-0.0896330.075818-0.021001-0.0286610.115051COc1cc(O)cc(\\C=C\\c2ccccc2)c1
310.0024277-0.3165550.410722-0.236208-0.055084-0.0998760.5030350.154239-0.172400...0.2083470.0154080.3391000.0311780.103611-0.070876-0.044751-0.0095910.322316COc1c(O)cc2C(=O)O[C@H]3[C@@H](O)[C@H](O)[C@@H]...
44.3924277-0.0475870.248559-0.0200580.0857720.0963940.5455750.214587-0.086168...0.4268260.1188730.4156230.3397940.238471-0.157253-0.002357-0.0573820.437593CCOc1ccc2ccccc2c1C(=O)N[C@H]1[C@H]2SC(C)(C)[C@...
\n", "

5 rows × 605 columns

\n", "
" ], "text/plain": [ " Metadata_mmoles_per_liter2 Metadata_Plate Cells_AreaShape_Center_X \\\n", "0 6.05 24277 -0.070346 \n", "1 10.00 24277 0.041380 \n", "2 10.00 24277 -0.130346 \n", "3 10.00 24277 -0.316555 \n", "4 4.39 24277 -0.047587 \n", "\n", " Cells_AreaShape_Compactness Cells_AreaShape_Extent \\\n", "0 0.256710 -0.114990 \n", "1 0.050962 0.051053 \n", "2 -0.098185 0.044212 \n", "3 0.410722 -0.236208 \n", "4 0.248559 -0.020058 \n", "\n", " Cells_AreaShape_FormFactor Cells_AreaShape_Orientation \\\n", "0 -0.237090 -0.037928 \n", "1 -0.033733 0.064711 \n", "2 0.164668 -0.130904 \n", "3 -0.055084 -0.099876 \n", "4 0.085772 0.096394 \n", "\n", " Cells_AreaShape_Perimeter Cells_AreaShape_Solidity \\\n", "0 0.525950 0.072795 \n", "1 0.298818 0.145941 \n", "2 0.001828 0.094736 \n", "3 0.503035 0.154239 \n", "4 0.545575 0.214587 \n", "\n", " Cells_AreaShape_Zernike_1_1 ... Nuclei_Texture_SumEntropy_ER_10_0 \\\n", "0 0.008488 ... 0.271039 \n", "1 -0.070826 ... 0.254293 \n", "2 0.119333 ... 0.230331 \n", "3 -0.172400 ... 0.208347 \n", "4 -0.086168 ... 0.426826 \n", "\n", " Nuclei_Texture_SumEntropy_Mito_3_0 Nuclei_Texture_SumEntropy_RNA_5_0 \\\n", "0 -0.010427 0.118997 \n", "1 -0.058560 0.065822 \n", "2 0.029891 0.079777 \n", "3 0.015408 0.339100 \n", "4 0.118873 0.415623 \n", "\n", " Nuclei_Texture_SumVariance_ER_10_0 Nuclei_Texture_SumVariance_RNA_10_0 \\\n", "0 0.006318 -0.024573 \n", "1 -0.089380 -0.041392 \n", "2 0.020954 -0.089633 \n", "3 0.031178 0.103611 \n", "4 0.339794 0.238471 \n", "\n", " Nuclei_Texture_Variance_AGP_10_0 Nuclei_Texture_Variance_ER_10_0 \\\n", "0 -0.362861 -0.199743 \n", "1 -0.220610 -0.154711 \n", "2 0.075818 -0.021001 \n", "3 -0.070876 -0.044751 \n", "4 -0.157253 -0.002357 \n", "\n", " Nuclei_Texture_Variance_Mito_10_0 Nuclei_Texture_Variance_RNA_10_0 \\\n", "0 -0.329832 0.066800 \n", "1 -0.116072 0.174417 \n", "2 -0.028661 0.115051 \n", "3 -0.009591 0.322316 \n", "4 -0.057382 0.437593 \n", "\n", " SMILES \n", "0 CCCOc1cc(N)ccc1C(=O)OCCN(CC)CC \n", "1 COc1cc(C)cc(OC)c1[C@@H]1C=C(C)CC[C@H]1C(C)=C \n", "2 COc1cc(O)cc(\\C=C\\c2ccccc2)c1 \n", "3 COc1c(O)cc2C(=O)O[C@H]3[C@@H](O)[C@H](O)[C@@H]... \n", "4 CCOc1ccc2ccccc2c1C(=O)N[C@H]1[C@H]2SC(C)(C)[C@... \n", "\n", "[5 rows x 605 columns]" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_filled.head()" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
SMILESMetadata_mmoles_per_liter2Metadata_PlateCells_AreaShape_Center_XCells_AreaShape_CompactnessCells_AreaShape_ExtentCells_AreaShape_FormFactorCells_AreaShape_OrientationCells_AreaShape_PerimeterCells_AreaShape_Solidity...Nuclei_Texture_SumEntropy_DNA_10_0Nuclei_Texture_SumEntropy_ER_10_0Nuclei_Texture_SumEntropy_Mito_3_0Nuclei_Texture_SumEntropy_RNA_5_0Nuclei_Texture_SumVariance_ER_10_0Nuclei_Texture_SumVariance_RNA_10_0Nuclei_Texture_Variance_AGP_10_0Nuclei_Texture_Variance_ER_10_0Nuclei_Texture_Variance_Mito_10_0Nuclei_Texture_Variance_RNA_10_0
0CCCOc1cc(N)ccc1C(=O)OCCN(CC)CC6.0524277-0.0703460.256710-0.114990-0.237090-0.0379280.5259500.072795...0.0990290.271039-0.0104270.1189970.006318-0.024573-0.362861-0.199743-0.3298320.066800
1COc1cc(C)cc(OC)c1[C@@H]1C=C(C)CC[C@H]1C(C)=C10.00242770.0413800.0509620.051053-0.0337330.0647110.2988180.145941...-0.0424740.254293-0.0585600.065822-0.089380-0.041392-0.220610-0.154711-0.1160720.174417
2COc1cc(O)cc(\\C=C\\c2ccccc2)c110.0024277-0.130346-0.0981850.0442120.164668-0.1309040.0018280.094736...0.0979920.2303310.0298910.0797770.020954-0.0896330.075818-0.021001-0.0286610.115051
3COc1c(O)cc2C(=O)O[C@H]3[C@@H](O)[C@H](O)[C@@H]...10.0024277-0.3165550.410722-0.236208-0.055084-0.0998760.5030350.154239...0.3890630.2083470.0154080.3391000.0311780.103611-0.070876-0.044751-0.0095910.322316
4CCOc1ccc2ccccc2c1C(=O)N[C@H]1[C@H]2SC(C)(C)[C@...4.3924277-0.0475870.248559-0.0200580.0857720.0963940.5455750.214587...0.6103440.4268260.1188730.4156230.3397940.238471-0.157253-0.002357-0.0573820.437593
\n", "

5 rows × 605 columns

\n", "
" ], "text/plain": [ " SMILES \\\n", "0 CCCOc1cc(N)ccc1C(=O)OCCN(CC)CC \n", "1 COc1cc(C)cc(OC)c1[C@@H]1C=C(C)CC[C@H]1C(C)=C \n", "2 COc1cc(O)cc(\\C=C\\c2ccccc2)c1 \n", "3 COc1c(O)cc2C(=O)O[C@H]3[C@@H](O)[C@H](O)[C@@H]... \n", "4 CCOc1ccc2ccccc2c1C(=O)N[C@H]1[C@H]2SC(C)(C)[C@... \n", "\n", " Metadata_mmoles_per_liter2 Metadata_Plate Cells_AreaShape_Center_X \\\n", "0 6.05 24277 -0.070346 \n", "1 10.00 24277 0.041380 \n", "2 10.00 24277 -0.130346 \n", "3 10.00 24277 -0.316555 \n", "4 4.39 24277 -0.047587 \n", "\n", " Cells_AreaShape_Compactness Cells_AreaShape_Extent \\\n", "0 0.256710 -0.114990 \n", "1 0.050962 0.051053 \n", "2 -0.098185 0.044212 \n", "3 0.410722 -0.236208 \n", "4 0.248559 -0.020058 \n", "\n", " Cells_AreaShape_FormFactor Cells_AreaShape_Orientation \\\n", "0 -0.237090 -0.037928 \n", "1 -0.033733 0.064711 \n", "2 0.164668 -0.130904 \n", "3 -0.055084 -0.099876 \n", "4 0.085772 0.096394 \n", "\n", " Cells_AreaShape_Perimeter Cells_AreaShape_Solidity ... \\\n", "0 0.525950 0.072795 ... \n", "1 0.298818 0.145941 ... \n", "2 0.001828 0.094736 ... \n", "3 0.503035 0.154239 ... \n", "4 0.545575 0.214587 ... \n", "\n", " Nuclei_Texture_SumEntropy_DNA_10_0 Nuclei_Texture_SumEntropy_ER_10_0 \\\n", "0 0.099029 0.271039 \n", "1 -0.042474 0.254293 \n", "2 0.097992 0.230331 \n", "3 0.389063 0.208347 \n", "4 0.610344 0.426826 \n", "\n", " Nuclei_Texture_SumEntropy_Mito_3_0 Nuclei_Texture_SumEntropy_RNA_5_0 \\\n", "0 -0.010427 0.118997 \n", "1 -0.058560 0.065822 \n", "2 0.029891 0.079777 \n", "3 0.015408 0.339100 \n", "4 0.118873 0.415623 \n", "\n", " Nuclei_Texture_SumVariance_ER_10_0 Nuclei_Texture_SumVariance_RNA_10_0 \\\n", "0 0.006318 -0.024573 \n", "1 -0.089380 -0.041392 \n", "2 0.020954 -0.089633 \n", "3 0.031178 0.103611 \n", "4 0.339794 0.238471 \n", "\n", " Nuclei_Texture_Variance_AGP_10_0 Nuclei_Texture_Variance_ER_10_0 \\\n", "0 -0.362861 -0.199743 \n", "1 -0.220610 -0.154711 \n", "2 0.075818 -0.021001 \n", "3 -0.070876 -0.044751 \n", "4 -0.157253 -0.002357 \n", "\n", " Nuclei_Texture_Variance_Mito_10_0 Nuclei_Texture_Variance_RNA_10_0 \n", "0 -0.329832 0.066800 \n", "1 -0.116072 0.174417 \n", "2 -0.028661 0.115051 \n", "3 -0.009591 0.322316 \n", "4 -0.057382 0.437593 \n", "\n", "[5 rows x 605 columns]" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# SMILES列移动到第一列\n", "\n", "if 'SMILES' in df_filled.columns:\n", " cols = df_filled.columns.tolist()\n", " cols.insert(0, cols.pop(cols.index('SMILES')))\n", " df_filled = df_filled[cols]\n", "\n", "df_filled.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# 规范化SMILES" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "最终 SMILES 唯一值数量: 1917\n" ] } ], "source": [ "final_smiles = df_filled['SMILES'].unique()\n", "print(f\"最终 SMILES 唯一值数量: {len(final_smiles)}\")" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "最终 SMILES 唯一值数量: 1917\n" ] } ], "source": [ "import pandas as pd\n", "from rdkit import Chem\n", "\n", "def canonicalize_smiles(smiles):\n", " \"\"\"尝试将一个 SMILES 转换为规范化形式,忽略 DMSO\"\"\"\n", " if pd.isna(smiles): \n", " return smiles\n", " if str(smiles).upper() == \"DMSO\": # 特殊情况,直接跳过\n", " return \"DMSO\"\n", " try:\n", " mol = Chem.MolFromSmiles(smiles)\n", " if mol is not None:\n", " return Chem.MolToSmiles(mol)\n", " else:\n", " return smiles\n", " except:\n", " return smiles\n", "\n", "# 应用到整列\n", "df_filled['SMILES'] = df_filled['SMILES'].apply(canonicalize_smiles)\n", "\n", "# 查看结果\n", "final_smiles = df_filled['SMILES'].unique()\n", "print(f\"最终 SMILES 唯一值数量: {len(final_smiles)}\")\n" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
SMILESMetadata_mmoles_per_liter2Metadata_PlateCells_AreaShape_Center_XCells_AreaShape_CompactnessCells_AreaShape_ExtentCells_AreaShape_FormFactorCells_AreaShape_OrientationCells_AreaShape_PerimeterCells_AreaShape_Solidity...Nuclei_Texture_SumEntropy_DNA_10_0Nuclei_Texture_SumEntropy_ER_10_0Nuclei_Texture_SumEntropy_Mito_3_0Nuclei_Texture_SumEntropy_RNA_5_0Nuclei_Texture_SumVariance_ER_10_0Nuclei_Texture_SumVariance_RNA_10_0Nuclei_Texture_Variance_AGP_10_0Nuclei_Texture_Variance_ER_10_0Nuclei_Texture_Variance_Mito_10_0Nuclei_Texture_Variance_RNA_10_0
0CCCOc1cc(N)ccc1C(=O)OCCN(CC)CC6.0524277-0.0703460.256710-0.114990-0.237090-0.0379280.5259500.072795...0.0990290.271039-0.0104270.1189970.006318-0.024573-0.362861-0.199743-0.3298320.066800
1C=C(C)[C@@H]1CCC(C)=C[C@H]1c1c(OC)cc(C)cc1OC10.00242770.0413800.0509620.051053-0.0337330.0647110.2988180.145941...-0.0424740.254293-0.0585600.065822-0.089380-0.041392-0.220610-0.154711-0.1160720.174417
2COc1cc(O)cc(/C=C/c2ccccc2)c110.0024277-0.130346-0.0981850.0442120.164668-0.1309040.0018280.094736...0.0979920.2303310.0298910.0797770.020954-0.0896330.075818-0.021001-0.0286610.115051
3COc1c(O)cc2c(c1O)[C@H]1O[C@H](CO)[C@@H](O)[C@H...10.0024277-0.3165550.410722-0.236208-0.055084-0.0998760.5030350.154239...0.3890630.2083470.0154080.3391000.0311780.103611-0.070876-0.044751-0.0095910.322316
4CCOc1ccc2ccccc2c1C(=O)N[C@@H]1C(=O)N2[C@@H]1SC...4.3924277-0.0475870.248559-0.0200580.0857720.0963940.5455750.214587...0.6103440.4268260.1188730.4156230.3397940.238471-0.157253-0.002357-0.0573820.437593
\n", "

5 rows × 605 columns

\n", "
" ], "text/plain": [ " SMILES \\\n", "0 CCCOc1cc(N)ccc1C(=O)OCCN(CC)CC \n", "1 C=C(C)[C@@H]1CCC(C)=C[C@H]1c1c(OC)cc(C)cc1OC \n", "2 COc1cc(O)cc(/C=C/c2ccccc2)c1 \n", "3 COc1c(O)cc2c(c1O)[C@H]1O[C@H](CO)[C@@H](O)[C@H... \n", "4 CCOc1ccc2ccccc2c1C(=O)N[C@@H]1C(=O)N2[C@@H]1SC... \n", "\n", " Metadata_mmoles_per_liter2 Metadata_Plate Cells_AreaShape_Center_X \\\n", "0 6.05 24277 -0.070346 \n", "1 10.00 24277 0.041380 \n", "2 10.00 24277 -0.130346 \n", "3 10.00 24277 -0.316555 \n", "4 4.39 24277 -0.047587 \n", "\n", " Cells_AreaShape_Compactness Cells_AreaShape_Extent \\\n", "0 0.256710 -0.114990 \n", "1 0.050962 0.051053 \n", "2 -0.098185 0.044212 \n", "3 0.410722 -0.236208 \n", "4 0.248559 -0.020058 \n", "\n", " Cells_AreaShape_FormFactor Cells_AreaShape_Orientation \\\n", "0 -0.237090 -0.037928 \n", "1 -0.033733 0.064711 \n", "2 0.164668 -0.130904 \n", "3 -0.055084 -0.099876 \n", "4 0.085772 0.096394 \n", "\n", " Cells_AreaShape_Perimeter Cells_AreaShape_Solidity ... \\\n", "0 0.525950 0.072795 ... \n", "1 0.298818 0.145941 ... \n", "2 0.001828 0.094736 ... \n", "3 0.503035 0.154239 ... \n", "4 0.545575 0.214587 ... \n", "\n", " Nuclei_Texture_SumEntropy_DNA_10_0 Nuclei_Texture_SumEntropy_ER_10_0 \\\n", "0 0.099029 0.271039 \n", "1 -0.042474 0.254293 \n", "2 0.097992 0.230331 \n", "3 0.389063 0.208347 \n", "4 0.610344 0.426826 \n", "\n", " Nuclei_Texture_SumEntropy_Mito_3_0 Nuclei_Texture_SumEntropy_RNA_5_0 \\\n", "0 -0.010427 0.118997 \n", "1 -0.058560 0.065822 \n", "2 0.029891 0.079777 \n", "3 0.015408 0.339100 \n", "4 0.118873 0.415623 \n", "\n", " Nuclei_Texture_SumVariance_ER_10_0 Nuclei_Texture_SumVariance_RNA_10_0 \\\n", "0 0.006318 -0.024573 \n", "1 -0.089380 -0.041392 \n", "2 0.020954 -0.089633 \n", "3 0.031178 0.103611 \n", "4 0.339794 0.238471 \n", "\n", " Nuclei_Texture_Variance_AGP_10_0 Nuclei_Texture_Variance_ER_10_0 \\\n", "0 -0.362861 -0.199743 \n", "1 -0.220610 -0.154711 \n", "2 0.075818 -0.021001 \n", "3 -0.070876 -0.044751 \n", "4 -0.157253 -0.002357 \n", "\n", " Nuclei_Texture_Variance_Mito_10_0 Nuclei_Texture_Variance_RNA_10_0 \n", "0 -0.329832 0.066800 \n", "1 -0.116072 0.174417 \n", "2 -0.028661 0.115051 \n", "3 -0.009591 0.322316 \n", "4 -0.057382 0.437593 \n", "\n", "[5 rows x 605 columns]" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_filled.head()" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [], "source": [ "# 假设你想把 'old_name1' 改成 'new_name1','old_name2' 改成 'new_name2'\n", "df_filled = df_filled.rename(columns={\n", " 'Metadata_mmoles_per_liter2': 'pert_dose',\n", " 'Metadata_Plate': 'Plate'\n", "})" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " mean variance\n", "pert_dose 7.887732 23.927793\n", "Plate 25124.655070 695496.697836\n", "Cells_AreaShape_Center_X 0.004264 0.015045\n", "Cells_AreaShape_Compactness 0.086884 0.093594\n", "Cells_AreaShape_Extent -0.017306 0.078201\n", "... ... ...\n", "Nuclei_Texture_SumVariance_RNA_10_0 -0.013250 0.079604\n", "Nuclei_Texture_Variance_AGP_10_0 -0.015986 0.074838\n", "Nuclei_Texture_Variance_ER_10_0 0.008951 0.038802\n", "Nuclei_Texture_Variance_Mito_10_0 -0.023557 0.078082\n", "Nuclei_Texture_Variance_RNA_10_0 0.029789 0.135745\n", "\n", "[604 rows x 2 columns]\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/tmp/ipykernel_980761/3438912780.py:3: FutureWarning: The default value of numeric_only in DataFrame.var is deprecated. In a future version, it will default to False. In addition, specifying 'numeric_only=None' is deprecated. Select only valid columns or specify the value of numeric_only to silence this warning.\n", " stats['variance'] = df_filled.var() # 添加方差列\n" ] } ], "source": [ "# 查看每列的基本统计信息\n", "stats = df_filled.describe().T # 转置方便查看\n", "stats['variance'] = df_filled.var() # 添加方差列\n", "print(stats[['mean', 'variance']])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# 数据清洗" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "最小值: -33.28080519838869, 最大值: inf\n", "(NumPy) 最小值: -33.28080519838869, 最大值: inf\n" ] } ], "source": [ "import numpy as np\n", "\n", "# 假设 df_filled 的前 3 列是 index 0,1,2\n", "data_subset = df_filled.iloc[:, 3:] # 取第4列开始到最后\n", "\n", "# 计算极值\n", "min_val = data_subset.min().min()\n", "max_val = data_subset.max().max()\n", "print(f\"最小值: {min_val}, 最大值: {max_val}\")\n", "\n", "# 或用 NumPy\n", "min_val_np = np.min(data_subset.values)\n", "max_val_np = np.max(data_subset.values)\n", "print(f\"(NumPy) 最小值: {min_val_np}, 最大值: {max_val_np}\")\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "含有无穷大的列: ['Cells_Granularity_8_AGP', 'Cells_Granularity_9_Mito', 'Cells_Neighbors_NumberOfNeighbors_5', 'Cells_Neighbors_NumberOfNeighbors_Adjacent', 'Cells_Neighbors_PercentTouching_Adjacent', 'Cytoplasm_RadialDistribution_RadialCV_AGP_1of4', 'Cytoplasm_RadialDistribution_RadialCV_DNA_1of4', 'Cytoplasm_RadialDistribution_RadialCV_ER_1of4', 'Cytoplasm_RadialDistribution_RadialCV_Mito_1of4', 'Cytoplasm_RadialDistribution_RadialCV_RNA_1of4', 'Nuclei_Granularity_7_Mito']\n" ] }, { "data": { "text/plain": [ "11" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# 查看哪些列含有 inf/-inf\n", "cols_with_inf = data_subset.columns.to_list()\n", "inf_cols = data_subset.loc[:, np.isinf(data_subset).any()].columns.tolist()\n", "print(\"含有无穷大的列:\", inf_cols)\n", "len(inf_cols)\n", "# 查看具体行数\n", "# rows_with_inf = data_subset[np.isinf(data_subset).any(axis=1)]\n", "# print(\"含有无穷大的行数:\", len(rows_with_inf))" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "处理后最小值: -33.28080519838869, 最大值: 14306335.342782514\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/tmp/ipykernel_980761/3153003127.py:3: FutureWarning: The default value of numeric_only in DataFrame.median is deprecated. In a future version, it will default to False. In addition, specifying 'numeric_only=None' is deprecated. Select only valid columns or specify the value of numeric_only to silence this warning.\n", " data_subset.fillna(df_filled.median(), inplace=True)\n" ] } ], "source": [ "# 将无穷大值替换为 NaN\n", "data_subset.replace([np.inf, -np.inf], np.nan, inplace=True)\n", "data_subset.fillna(df_filled.median(), inplace=True)\n", "\n", "# data_subset = df_filled.iloc[:, 3:] # 忽略前3列\n", "min_val = data_subset.min().min()\n", "max_val = data_subset.max().max()\n", "print(f\"处理后最小值: {min_val}, 最大值: {max_val}\")\n" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "处理后的统计信息: {'min': -20.893137652648804, 'max': 26.271766409991006, 'mean': 0.03453020981290565, 'std': 1.0699224422935123}\n" ] } ], "source": [ "import pandas as pd\n", "import numpy as np\n", "from sklearn.preprocessing import RobustScaler\n", "\n", "def preprocess_dl_auto_log(df: pd.DataFrame, skip_cols: int = 3,\n", " log_keywords: list = None, lower_percentile=0.01, upper_percentile=0.99):\n", " \"\"\"\n", " 深度学习训练前数据预处理(自动识别 log 列):\n", " - skip_cols: 保留前几列不处理(如 ID、SMILES、剂量等)\n", " - log_keywords: 用于识别需要 log1p 的列的关键字(如 'Granularity', 'Neighbors', 'RadialDistribution')\n", " - lower_percentile, upper_percentile: 百分位剪切极值\n", " \n", " 返回:\n", " df_clean: 处理后的 DataFrame\n", " stats: 最终统计信息(min, max, mean, std)\n", " \"\"\"\n", " df_clean = df.copy()\n", " \n", " # --- 1. 分离元数据和特征 ---\n", " meta_cols = df_clean.iloc[:, :skip_cols]\n", " data_cols = df_clean.iloc[:, skip_cols:]\n", " \n", " # --- 2. 替换 inf/-inf 为 NaN ---\n", " data_cols.replace([np.inf, -np.inf], np.nan, inplace=True)\n", " \n", " # --- 3. 填充 NaN(用中位数) ---\n", " data_cols.fillna(data_cols.median(), inplace=True)\n", " \n", " # --- 4. 百分位剪切极值 ---\n", " lower = data_cols.quantile(lower_percentile)\n", " upper = data_cols.quantile(upper_percentile)\n", " data_cols = data_cols.clip(lower=lower, upper=upper, axis=1)\n", " \n", " # --- 5. 自动识别 log1p 列 ---\n", " log_cols = []\n", " if log_keywords:\n", " log_cols = [col for col in data_cols.columns if any(k in col for k in log_keywords)]\n", " \n", " # --- 6. 对计数/强度型特征做 log1p ---\n", " for col in log_cols:\n", " # 保证非负\n", " data_cols[col] = np.log1p(data_cols[col] - data_cols[col].min())\n", " \n", " # --- 7. RobustScaler 缩放 ---\n", " scaler = RobustScaler()\n", " data_scaled = scaler.fit_transform(data_cols.values)\n", " data_cols.iloc[:, :] = data_scaled\n", " \n", " # --- 8. 合并回原 DataFrame ---\n", " df_clean = pd.concat([meta_cols.reset_index(drop=True), pd.DataFrame(data_cols, columns=data_cols.columns)], axis=1)\n", " \n", " # --- 9. 统计信息 ---\n", " stats = {\n", " 'min': data_cols.min().min(),\n", " 'max': data_cols.max().max(),\n", " 'mean': data_cols.mean().mean(),\n", " 'std': data_cols.std().mean()\n", " }\n", " \n", " return df_clean, stats\n", "\n", "# ------------------------\n", "# 使用示例\n", "# ------------------------\n", "keywords = ['Granularity', 'Neighbors', 'RadialDistribution'] # 自动识别 log1p 特征\n", "df_processed, stats = preprocess_dl_auto_log(df_filled, skip_cols=3, log_keywords=keywords)\n", "print(\"处理后的统计信息:\", stats)" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
SMILESpert_dosePlateCells_AreaShape_Center_XCells_AreaShape_CompactnessCells_AreaShape_ExtentCells_AreaShape_FormFactorCells_AreaShape_OrientationCells_AreaShape_PerimeterCells_AreaShape_Solidity...Nuclei_Texture_SumEntropy_DNA_10_0Nuclei_Texture_SumEntropy_ER_10_0Nuclei_Texture_SumEntropy_Mito_3_0Nuclei_Texture_SumEntropy_RNA_5_0Nuclei_Texture_SumVariance_ER_10_0Nuclei_Texture_SumVariance_RNA_10_0Nuclei_Texture_Variance_AGP_10_0Nuclei_Texture_Variance_ER_10_0Nuclei_Texture_Variance_Mito_10_0Nuclei_Texture_Variance_RNA_10_0
0CCCOc1cc(N)ccc1C(=O)OCCN(CC)CC6.0524277-0.6048470.809281-0.491738-0.985194-0.2719791.5616990.307036...0.4758661.1314760.1802880.4686020.2949920.092436-1.491192-1.124909-1.6145650.351811
1C=C(C)[C@@H]1CCC(C)=C[C@H]1c1c(OC)cc(C)cc1OC10.00242770.303335-0.0562090.536350-0.1868910.4695970.8162240.657581...0.1144811.0734910.0553590.333429-0.0476540.017835-0.817194-0.846448-0.4114270.776666
2COc1cc(O)cc(/C=C/c2ccccc2)c110.0024277-1.092574-0.6836050.4939900.591957-0.943733-0.1585300.412186...0.4732190.9905140.2849360.3689030.347398-0.1961400.587304-0.0196310.0805580.542300
3COc1c(O)cc2c(c1O)[C@H]1O[C@H](CO)[C@@H](O)[C@H...10.0024277-2.4757221.457141-1.242283-0.270706-0.7195561.4864880.697351...1.2165890.9143850.2473441.0281060.3840050.661007-0.107747-0.1664960.1878931.360546
4CCOc1ccc2ccccc2c1C(=O)N[C@@H]1C(=O)N2[C@@H]1SC...4.3924277-0.4198470.7749930.0960510.2822400.6985041.6261120.986562...1.7817201.6709380.5158891.2226281.4890001.259185-0.5170040.095658-0.0810941.815642
\n", "

5 rows × 605 columns

\n", "
" ], "text/plain": [ " SMILES pert_dose Plate \\\n", "0 CCCOc1cc(N)ccc1C(=O)OCCN(CC)CC 6.05 24277 \n", "1 C=C(C)[C@@H]1CCC(C)=C[C@H]1c1c(OC)cc(C)cc1OC 10.00 24277 \n", "2 COc1cc(O)cc(/C=C/c2ccccc2)c1 10.00 24277 \n", "3 COc1c(O)cc2c(c1O)[C@H]1O[C@H](CO)[C@@H](O)[C@H... 10.00 24277 \n", "4 CCOc1ccc2ccccc2c1C(=O)N[C@@H]1C(=O)N2[C@@H]1SC... 4.39 24277 \n", "\n", " Cells_AreaShape_Center_X Cells_AreaShape_Compactness \\\n", "0 -0.604847 0.809281 \n", "1 0.303335 -0.056209 \n", "2 -1.092574 -0.683605 \n", "3 -2.475722 1.457141 \n", "4 -0.419847 0.774993 \n", "\n", " Cells_AreaShape_Extent Cells_AreaShape_FormFactor \\\n", "0 -0.491738 -0.985194 \n", "1 0.536350 -0.186891 \n", "2 0.493990 0.591957 \n", "3 -1.242283 -0.270706 \n", "4 0.096051 0.282240 \n", "\n", " Cells_AreaShape_Orientation Cells_AreaShape_Perimeter \\\n", "0 -0.271979 1.561699 \n", "1 0.469597 0.816224 \n", "2 -0.943733 -0.158530 \n", "3 -0.719556 1.486488 \n", "4 0.698504 1.626112 \n", "\n", " Cells_AreaShape_Solidity ... Nuclei_Texture_SumEntropy_DNA_10_0 \\\n", "0 0.307036 ... 0.475866 \n", "1 0.657581 ... 0.114481 \n", "2 0.412186 ... 0.473219 \n", "3 0.697351 ... 1.216589 \n", "4 0.986562 ... 1.781720 \n", "\n", " Nuclei_Texture_SumEntropy_ER_10_0 Nuclei_Texture_SumEntropy_Mito_3_0 \\\n", "0 1.131476 0.180288 \n", "1 1.073491 0.055359 \n", "2 0.990514 0.284936 \n", "3 0.914385 0.247344 \n", "4 1.670938 0.515889 \n", "\n", " Nuclei_Texture_SumEntropy_RNA_5_0 Nuclei_Texture_SumVariance_ER_10_0 \\\n", "0 0.468602 0.294992 \n", "1 0.333429 -0.047654 \n", "2 0.368903 0.347398 \n", "3 1.028106 0.384005 \n", "4 1.222628 1.489000 \n", "\n", " Nuclei_Texture_SumVariance_RNA_10_0 Nuclei_Texture_Variance_AGP_10_0 \\\n", "0 0.092436 -1.491192 \n", "1 0.017835 -0.817194 \n", "2 -0.196140 0.587304 \n", "3 0.661007 -0.107747 \n", "4 1.259185 -0.517004 \n", "\n", " Nuclei_Texture_Variance_ER_10_0 Nuclei_Texture_Variance_Mito_10_0 \\\n", "0 -1.124909 -1.614565 \n", "1 -0.846448 -0.411427 \n", "2 -0.019631 0.080558 \n", "3 -0.166496 0.187893 \n", "4 0.095658 -0.081094 \n", "\n", " Nuclei_Texture_Variance_RNA_10_0 \n", "0 0.351811 \n", "1 0.776666 \n", "2 0.542300 \n", "3 1.360546 \n", "4 1.815642 \n", "\n", "[5 rows x 605 columns]" ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_processed.head()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [], "source": [ "# save to parquet\n", "output_path = 'Step2_CP_cleaned.parquet'\n", "df_processed.to_parquet(output_path, index=False)" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "output_path = 'Step2_CP_cleaned.parquet'\n", "df_processed = pd.read_parquet(output_path)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# 数据处理到这就可以了,对齐数据先不做,想好怎么处理直接对 df 做反而方便。" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(18540, 605)" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_processed.shape" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
SMILESpert_dosePlateCells_AreaShape_Center_XCells_AreaShape_CompactnessCells_AreaShape_ExtentCells_AreaShape_FormFactorCells_AreaShape_OrientationCells_AreaShape_PerimeterCells_AreaShape_Solidity...Nuclei_Texture_SumEntropy_DNA_10_0Nuclei_Texture_SumEntropy_ER_10_0Nuclei_Texture_SumEntropy_Mito_3_0Nuclei_Texture_SumEntropy_RNA_5_0Nuclei_Texture_SumVariance_ER_10_0Nuclei_Texture_SumVariance_RNA_10_0Nuclei_Texture_Variance_AGP_10_0Nuclei_Texture_Variance_ER_10_0Nuclei_Texture_Variance_Mito_10_0Nuclei_Texture_Variance_RNA_10_0
0CCCOc1cc(N)ccc1C(=O)OCCN(CC)CC6.0524277-0.6048470.809281-0.491738-0.985194-0.2719791.5616990.307036...0.4758661.1314760.1802880.4686020.2949920.092436-1.491192-1.124909-1.6145650.351811
1C=C(C)[C@@H]1CCC(C)=C[C@H]1c1c(OC)cc(C)cc1OC10.00242770.303335-0.0562090.536350-0.1868910.4695970.8162240.657581...0.1144811.0734910.0553590.333429-0.0476540.017835-0.817194-0.846448-0.4114270.776666
2COc1cc(O)cc(/C=C/c2ccccc2)c110.0024277-1.092574-0.6836050.4939900.591957-0.943733-0.1585300.412186...0.4732190.9905140.2849360.3689030.347398-0.1961400.587304-0.0196310.0805580.542300
3COc1c(O)cc2c(c1O)[C@H]1O[C@H](CO)[C@@H](O)[C@H...10.0024277-2.4757221.457141-1.242283-0.270706-0.7195561.4864880.697351...1.2165890.9143850.2473441.0281060.3840050.661007-0.107747-0.1664960.1878931.360546
4CCOc1ccc2ccccc2c1C(=O)N[C@@H]1C(=O)N2[C@@H]1SC...4.3924277-0.4198470.7749930.0960510.2822400.6985041.6261120.986562...1.7817201.6709380.5158891.2226281.4890001.259185-0.5170040.095658-0.0810941.815642
\n", "

5 rows × 605 columns

\n", "
" ], "text/plain": [ " SMILES pert_dose Plate \\\n", "0 CCCOc1cc(N)ccc1C(=O)OCCN(CC)CC 6.05 24277 \n", "1 C=C(C)[C@@H]1CCC(C)=C[C@H]1c1c(OC)cc(C)cc1OC 10.00 24277 \n", "2 COc1cc(O)cc(/C=C/c2ccccc2)c1 10.00 24277 \n", "3 COc1c(O)cc2c(c1O)[C@H]1O[C@H](CO)[C@@H](O)[C@H... 10.00 24277 \n", "4 CCOc1ccc2ccccc2c1C(=O)N[C@@H]1C(=O)N2[C@@H]1SC... 4.39 24277 \n", "\n", " Cells_AreaShape_Center_X Cells_AreaShape_Compactness \\\n", "0 -0.604847 0.809281 \n", "1 0.303335 -0.056209 \n", "2 -1.092574 -0.683605 \n", "3 -2.475722 1.457141 \n", "4 -0.419847 0.774993 \n", "\n", " Cells_AreaShape_Extent Cells_AreaShape_FormFactor \\\n", "0 -0.491738 -0.985194 \n", "1 0.536350 -0.186891 \n", "2 0.493990 0.591957 \n", "3 -1.242283 -0.270706 \n", "4 0.096051 0.282240 \n", "\n", " Cells_AreaShape_Orientation Cells_AreaShape_Perimeter \\\n", "0 -0.271979 1.561699 \n", "1 0.469597 0.816224 \n", "2 -0.943733 -0.158530 \n", "3 -0.719556 1.486488 \n", "4 0.698504 1.626112 \n", "\n", " Cells_AreaShape_Solidity ... Nuclei_Texture_SumEntropy_DNA_10_0 \\\n", "0 0.307036 ... 0.475866 \n", "1 0.657581 ... 0.114481 \n", "2 0.412186 ... 0.473219 \n", "3 0.697351 ... 1.216589 \n", "4 0.986562 ... 1.781720 \n", "\n", " Nuclei_Texture_SumEntropy_ER_10_0 Nuclei_Texture_SumEntropy_Mito_3_0 \\\n", "0 1.131476 0.180288 \n", "1 1.073491 0.055359 \n", "2 0.990514 0.284936 \n", "3 0.914385 0.247344 \n", "4 1.670938 0.515889 \n", "\n", " Nuclei_Texture_SumEntropy_RNA_5_0 Nuclei_Texture_SumVariance_ER_10_0 \\\n", "0 0.468602 0.294992 \n", "1 0.333429 -0.047654 \n", "2 0.368903 0.347398 \n", "3 1.028106 0.384005 \n", "4 1.222628 1.489000 \n", "\n", " Nuclei_Texture_SumVariance_RNA_10_0 Nuclei_Texture_Variance_AGP_10_0 \\\n", "0 0.092436 -1.491192 \n", "1 0.017835 -0.817194 \n", "2 -0.196140 0.587304 \n", "3 0.661007 -0.107747 \n", "4 1.259185 -0.517004 \n", "\n", " Nuclei_Texture_Variance_ER_10_0 Nuclei_Texture_Variance_Mito_10_0 \\\n", "0 -1.124909 -1.614565 \n", "1 -0.846448 -0.411427 \n", "2 -0.019631 0.080558 \n", "3 -0.166496 0.187893 \n", "4 0.095658 -0.081094 \n", "\n", " Nuclei_Texture_Variance_RNA_10_0 \n", "0 0.351811 \n", "1 0.776666 \n", "2 0.542300 \n", "3 1.360546 \n", "4 1.815642 \n", "\n", "[5 rows x 605 columns]" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_processed.head()" ] }, { "cell_type": "code", "execution_count": 29, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "DMSO 3528\n", "CC(C)NCC(O)COc1cccc2[nH]ccc12 16\n", "CC(C)(C)NC[C@@H](O)COc1cccc2c1CCCC2=O 16\n", "COc1ccc(CCN(C)CCc2ccc(OC)c(OC)c2)cc1OC 8\n", "C/C=C(/C)C(=O)O[C@@H]1Cc2c(ccc3ccc(=O)oc23)OC1(C)C 8\n", " ... \n", "CCCC1CC2=CC(=O)CCC2(C)C2CCC3(C)C(CCC3(O)CCC(=O)O)C12 7\n", "COC(=O)C1=C(C)NC(C)=C(C(=O)OCCCN2CCC(c3ccccc3)(c3ccccc3)CC2)[C@@H]1c1cccc([N+](=O)[O-])c1 6\n", "CC(C)(Cc1c[nH]c2ccc(Cl)cc12)NCCOc1ccccc1OCC1CC1 6\n", "O=C1C(SCCO)=C(SCCO)C(=O)c2ccccc21 6\n", "CCc1ccc(OCc2ccccc2C(=O)Nc2ccc3nc(C)cc(N)c3c2)cc1 4\n", "Name: SMILES, Length: 1917, dtype: int64" ] }, "execution_count": 29, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_processed['SMILES'].value_counts()" ] }, { "cell_type": "code", "execution_count": 30, "metadata": {}, "outputs": [], "source": [ "df_processed = df_processed.drop(columns=\"pert_dose\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# 做对齐数据" ] }, { "cell_type": "code", "execution_count": 38, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "数据已成功处理并保存到 ./Processed_Paired_CP.h5 文件中。\n", "共有 14996 个样本。\n" ] } ], "source": [ "import pandas as pd\n", "import numpy as np\n", "import h5py\n", "\n", "# 1. 确保数值列为 float32 类型,这能减少内存使用并提高计算效率\n", "data_cols = [col for col in df_processed.columns if col not in ['Plate', 'SMILES']]\n", "df_processed[data_cols] = df_processed[data_cols].astype(np.float32)\n", "\n", "# 2. 对每个 Plate 中的相同 SMILES 进行求均值,一步到位\n", "# 这是一个高效的 Pandas 操作,能将数据处理流程大大简化\n", "processed_df = df_processed.groupby(['Plate', 'SMILES']).mean().reset_index()\n", "\n", "# 3. 初始化列表来存储数据。这种方式比在循环中频繁创建和合并 NumPy 数组更高效\n", "all_smiles = []\n", "all_control = []\n", "all_target = []\n", "\n", "# 4. 按 Plate 分组,遍历每个 Plate\n", "# `grouped` 是一个迭代器,可以逐个处理每个 Plate\n", "grouped = processed_df.groupby('Plate')\n", "for plate_name, plate_data in grouped:\n", " # 5. 分离 DMSO 和 Target 数据\n", " dmso_data = plate_data[plate_data['SMILES'] == 'DMSO']\n", " target_data = plate_data[plate_data['SMILES'] != 'DMSO']\n", "\n", " # 6. 处理 DMSO 行(Control)\n", " if not dmso_data.empty:\n", " # 提取数值列并转换为 NumPy 数组\n", " control = dmso_data[data_cols].values.flatten().astype(np.float32)\n", " else:\n", " print(f\"警告:Plate '{plate_name}' 没有 DMSO 数据。将用全零填充。\")\n", " control = np.zeros(len(data_cols), dtype=np.float32)\n", "\n", " # 7. 处理非 DMSO 行(Target)\n", " if not target_data.empty:\n", " # 提取 SMILES 和数值数据\n", " smiles = target_data['SMILES'].tolist()\n", " target = target_data[data_cols].values.astype(np.float32)\n", "\n", " # 重复 control,使其与 target 的行数匹配\n", " control_aligned = np.tile(control, (target.shape[0], 1))\n", "\n", " # 将处理后的数据追加到列表中\n", " all_smiles.extend(smiles)\n", " all_control.append(control_aligned)\n", " all_target.append(target)\n", "\n", "# 8. 一次性将列表合并为 NumPy 数组\n", "# 使用 astype('S') 转换为字节串,这是 HDF5 存储字符串的最佳方式\n", "final_smiles = np.array(all_smiles, dtype='S')\n", "# 使用三元表达式防止列表为空时报错\n", "final_control = np.vstack(all_control) if all_control else np.array([], dtype=np.float32).reshape(0, len(data_cols))\n", "final_target = np.vstack(all_target) if all_target else np.array([], dtype=np.float32).reshape(0, len(data_cols))\n", "\n", "# 9. 保存到 HDF5 文件\n", "output_path = './Processed_Paired_CP.h5'\n", "with h5py.File(output_path, 'w') as f:\n", " f.create_dataset('canonical_smiles', data=final_smiles)\n", " f.create_dataset('control', data=final_control, dtype=np.float32)\n", " f.create_dataset('target', data=final_target, dtype=np.float32)\n", "\n", "print(f\"数据已成功处理并保存到 {output_path} 文件中。\")\n", "print(f\"共有 {len(final_smiles)} 个样本。\")\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "数据已保存到 Processed_Paired_CP.h5 文件中。\n" ] } ], "source": [ "# # 保存到 HDF5 文件\n", "# with h5py.File('./Processed_Paired_CP.h5', 'w') as f:\n", "# f.create_dataset('canonical_smiles', data=final_smiles)\n", "# f.create_dataset('control', data=final_control, dtype=np.float32)\n", "# f.create_dataset('target', data=final_target, dtype=np.float32)\n", "\n", "# print(\"数据已保存到 Processed_Paired_CP.h5 文件中。\")" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array(['C#CCOC(=O)C1=CCCN(C)C1',\n", " 'C#C[C@]1(O)CC[C@H]2[C@@H]3CCC4=CC(=O)CC[C@@H]4[C@H]3CC[C@@]21CC',\n", " 'C#C[C@]1(O)CC[C@H]2[C@@H]3CCc4cc(OC)ccc4[C@H]3CC[C@@]21C', ...,\n", " 'Cc1noc(C)c1NC(=O)N(C)C[C@@H]1OCc2cnnn2CCCC(=O)N([C@@H](C)CO)C[C@H]1C',\n", " 'Cc1noc(C)c1NC(=O)N(C)C[C@H]1OCc2cn(nn2)CCCC(=O)N([C@@H](C)CO)C[C@@H]1C',\n", " 'Cc1noc(C)c1NC(=O)N(C)C[C@H]1OCc2cnnn2CCCC(=O)N([C@H](C)CO)C[C@@H]1C'],\n", " dtype='\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
pert_dosePlateSMILES221227_x_at212345_s_at218597_s_at217140_s_at209253_at214404_x_at219888_at...218397_at202996_at204608_at211071_s_at203341_at202801_at206414_s_at204978_at205379_at203897_at
050.0PAC001_U2OS_6H_X1_B1_UNI4445LCC(C)[C@H](CO)Nc1nc(Nc2cc(N)cc(Cl)c2)c2ncn(C(C...-0.118505-0.293445-0.2940880.292745-0.1458960.973580.247915...-0.5299050.8049920.430269-0.97559-1.7406050.3403820.4987780.3521520.535910.52484
112.7PAC001_U2OS_6H_X1_B1_UNI4445LIc1cccc(CSc2nnc(-c3ccncc3)o2)c10.043264-0.264945-0.0006330.0009350.177604-0.504720.214315...0.228895-0.3813080.5569690.25051-0.025625-0.024428-0.2251220.533052-0.19329-0.25436
250.0PAC001_U2OS_6H_X1_B1_UNI4445LO=C(Nc1ccncc1)Nc1c(Cl)cc(Cl)cc1Cl-0.0708050.1957550.004606-0.040855-0.067346-0.19872-0.053195...-0.031795-0.051728-0.0177410.056810.1306950.005919-0.408722-0.057177-0.256990.31004
316.2PAC001_U2OS_6H_X1_B1_UNI4445LCOc1ccc(CNC(=O)Nc2ncc([N+](=O)[O-])s2)cc10.027165-0.1495450.173113-0.100695-0.309296-0.20782-0.323985...-0.013787-0.1776080.219869-0.161290.365195-0.040848-0.2511220.0407320.17091-0.05144
412.5PAC001_U2OS_6H_X1_B1_UNI4445LO=C(O)c1ccc2c3c1cccc3c(=O)n1c3ccccc3nc210.3032940.254455-0.055418-0.0536350.000455-0.109080.031425...-0.052585-0.1961080.2454690.007840.093595-0.3034180.474878-0.022947-0.285890.06423
\n", "

5 rows × 980 columns

\n", "" ], "text/plain": [ " pert_dose Plate \\\n", "0 50.0 PAC001_U2OS_6H_X1_B1_UNI4445L \n", "1 12.7 PAC001_U2OS_6H_X1_B1_UNI4445L \n", "2 50.0 PAC001_U2OS_6H_X1_B1_UNI4445L \n", "3 16.2 PAC001_U2OS_6H_X1_B1_UNI4445L \n", "4 12.5 PAC001_U2OS_6H_X1_B1_UNI4445L \n", "\n", " SMILES 221227_x_at \\\n", "0 CC(C)[C@H](CO)Nc1nc(Nc2cc(N)cc(Cl)c2)c2ncn(C(C... -0.118505 \n", "1 Ic1cccc(CSc2nnc(-c3ccncc3)o2)c1 0.043264 \n", "2 O=C(Nc1ccncc1)Nc1c(Cl)cc(Cl)cc1Cl -0.070805 \n", "3 COc1ccc(CNC(=O)Nc2ncc([N+](=O)[O-])s2)cc1 0.027165 \n", "4 O=C(O)c1ccc2c3c1cccc3c(=O)n1c3ccccc3nc21 0.303294 \n", "\n", " 212345_s_at 218597_s_at 217140_s_at 209253_at 214404_x_at 219888_at \\\n", "0 -0.293445 -0.294088 0.292745 -0.145896 0.97358 0.247915 \n", "1 -0.264945 -0.000633 0.000935 0.177604 -0.50472 0.214315 \n", "2 0.195755 0.004606 -0.040855 -0.067346 -0.19872 -0.053195 \n", "3 -0.149545 0.173113 -0.100695 -0.309296 -0.20782 -0.323985 \n", "4 0.254455 -0.055418 -0.053635 0.000455 -0.10908 0.031425 \n", "\n", " ... 218397_at 202996_at 204608_at 211071_s_at 203341_at 202801_at \\\n", "0 ... -0.529905 0.804992 0.430269 -0.97559 -1.740605 0.340382 \n", "1 ... 0.228895 -0.381308 0.556969 0.25051 -0.025625 -0.024428 \n", "2 ... -0.031795 -0.051728 -0.017741 0.05681 0.130695 0.005919 \n", "3 ... -0.013787 -0.177608 0.219869 -0.16129 0.365195 -0.040848 \n", "4 ... -0.052585 -0.196108 0.245469 0.00784 0.093595 -0.303418 \n", "\n", " 206414_s_at 204978_at 205379_at 203897_at \n", "0 0.498778 0.352152 0.53591 0.52484 \n", "1 -0.225122 0.533052 -0.19329 -0.25436 \n", "2 -0.408722 -0.057177 -0.25699 0.31004 \n", "3 -0.251122 0.040732 0.17091 -0.05144 \n", "4 0.474878 -0.022947 -0.28589 0.06423 \n", "\n", "[5 rows x 980 columns]" ] }, "execution_count": 39, "metadata": {}, "output_type": "execute_result" } ], "source": [ "GE_CSV_matched.head()" ] }, { "cell_type": "code", "execution_count": 41, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "PAC005_U2OS_6H_X3_B1_UNI4445L 172\n", "PAC004_U2OS_6H_X1_B1_UNI4445R 169\n", "PAC006_U2OS_6H_X2_B1_UNI4445L 169\n", "PAC005_U2OS_6H_X3_B1_UNI4445R 169\n", "PAC003_U2OS_6H_X3_B1_UNI4445R 168\n", " ... \n", "PAC056_U2OS_6H_X3_B1_UNI4445L 7\n", "PAC062_U2OS_6H_X2_B1_UNI4445R 6\n", "PAC062_U2OS_6H_X1_B1_UNI4445R 6\n", "PAC062_U2OS_6H_X3_B1_UNI4445R 6\n", "PAC056_U2OS_6H_X3_B1_UNI4445R 5\n", "Name: Plate, Length: 386, dtype: int64" ] }, "execution_count": 41, "metadata": {}, "output_type": "execute_result" } ], "source": [ "GE_CSV_matched['Plate'].value_counts()" ] }, { "cell_type": "code", "execution_count": 32, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "太棒了!整个 DataFrame 都不存在 NaN 值。\n" ] } ], "source": [ "# 检查整个 DataFrame 那存在NaN的列\n", "nan_columns = GE_CSV_matched.columns[GE_CSV_matched.isnull().any()].tolist()\n", "\n", "if nan_columns:\n", " print(\"以下列仍包含 NaN 值:\")\n", " for col in nan_columns:\n", " # 打印出具体列及其 NaN 值的数量\n", " print(f\"- {col}: {GE_CSV_matched[col].isnull().sum()} 个 NaN\")\n", "else:\n", " print(\"太棒了!整个 DataFrame 都不存在 NaN 值。\")" ] }, { "cell_type": "code", "execution_count": 42, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
pert_dosePlateSMILES221227_x_at212345_s_at218597_s_at217140_s_at209253_at214404_x_at219888_at...218397_at202996_at204608_at211071_s_at203341_at202801_at206414_s_at204978_at205379_at203897_at
050.0PAC001_U2OS_6H_X1_B1_UNI4445LCC(C)[C@H](CO)Nc1nc(Nc2cc(N)cc(Cl)c2)c2ncn(C(C...-0.118505-0.293445-0.2940880.292745-0.1458960.973580.247915...-0.5299050.8049920.430269-0.97559-1.7406050.3403820.4987780.3521520.535910.52484
112.7PAC001_U2OS_6H_X1_B1_UNI4445LIc1cccc(CSc2nnc(-c3ccncc3)o2)c10.043264-0.264945-0.0006330.0009350.177604-0.504720.214315...0.228895-0.3813080.5569690.25051-0.025625-0.024428-0.2251220.533052-0.19329-0.25436
250.0PAC001_U2OS_6H_X1_B1_UNI4445LO=C(Nc1ccncc1)Nc1c(Cl)cc(Cl)cc1Cl-0.0708050.1957550.004606-0.040855-0.067346-0.19872-0.053195...-0.031795-0.051728-0.0177410.056810.1306950.005919-0.408722-0.057177-0.256990.31004
316.2PAC001_U2OS_6H_X1_B1_UNI4445LCOc1ccc(CNC(=O)Nc2ncc([N+](=O)[O-])s2)cc10.027165-0.1495450.173113-0.100695-0.309296-0.20782-0.323985...-0.013787-0.1776080.219869-0.161290.365195-0.040848-0.2511220.0407320.17091-0.05144
412.5PAC001_U2OS_6H_X1_B1_UNI4445LO=C(O)c1ccc2c3c1cccc3c(=O)n1c3ccccc3nc210.3032940.254455-0.055418-0.0536350.000455-0.109080.031425...-0.052585-0.1961080.2454690.007840.093595-0.3034180.474878-0.022947-0.285890.06423
\n", "

5 rows × 980 columns

\n", "
" ], "text/plain": [ " pert_dose Plate \\\n", "0 50.0 PAC001_U2OS_6H_X1_B1_UNI4445L \n", "1 12.7 PAC001_U2OS_6H_X1_B1_UNI4445L \n", "2 50.0 PAC001_U2OS_6H_X1_B1_UNI4445L \n", "3 16.2 PAC001_U2OS_6H_X1_B1_UNI4445L \n", "4 12.5 PAC001_U2OS_6H_X1_B1_UNI4445L \n", "\n", " SMILES 221227_x_at \\\n", "0 CC(C)[C@H](CO)Nc1nc(Nc2cc(N)cc(Cl)c2)c2ncn(C(C... -0.118505 \n", "1 Ic1cccc(CSc2nnc(-c3ccncc3)o2)c1 0.043264 \n", "2 O=C(Nc1ccncc1)Nc1c(Cl)cc(Cl)cc1Cl -0.070805 \n", "3 COc1ccc(CNC(=O)Nc2ncc([N+](=O)[O-])s2)cc1 0.027165 \n", "4 O=C(O)c1ccc2c3c1cccc3c(=O)n1c3ccccc3nc21 0.303294 \n", "\n", " 212345_s_at 218597_s_at 217140_s_at 209253_at 214404_x_at 219888_at \\\n", "0 -0.293445 -0.294088 0.292745 -0.145896 0.97358 0.247915 \n", "1 -0.264945 -0.000633 0.000935 0.177604 -0.50472 0.214315 \n", "2 0.195755 0.004606 -0.040855 -0.067346 -0.19872 -0.053195 \n", "3 -0.149545 0.173113 -0.100695 -0.309296 -0.20782 -0.323985 \n", "4 0.254455 -0.055418 -0.053635 0.000455 -0.10908 0.031425 \n", "\n", " ... 218397_at 202996_at 204608_at 211071_s_at 203341_at 202801_at \\\n", "0 ... -0.529905 0.804992 0.430269 -0.97559 -1.740605 0.340382 \n", "1 ... 0.228895 -0.381308 0.556969 0.25051 -0.025625 -0.024428 \n", "2 ... -0.031795 -0.051728 -0.017741 0.05681 0.130695 0.005919 \n", "3 ... -0.013787 -0.177608 0.219869 -0.16129 0.365195 -0.040848 \n", "4 ... -0.052585 -0.196108 0.245469 0.00784 0.093595 -0.303418 \n", "\n", " 206414_s_at 204978_at 205379_at 203897_at \n", "0 0.498778 0.352152 0.53591 0.52484 \n", "1 -0.225122 0.533052 -0.19329 -0.25436 \n", "2 -0.408722 -0.057177 -0.25699 0.31004 \n", "3 -0.251122 0.040732 0.17091 -0.05144 \n", "4 0.474878 -0.022947 -0.28589 0.06423 \n", "\n", "[5 rows x 980 columns]" ] }, "execution_count": 42, "metadata": {}, "output_type": "execute_result" } ], "source": [ "GE_CSV_matched = GE_CSV_matched.rename(columns={\n", " 'det_plate': 'Plate',\n", " 'CPD_SMILES': 'SMILES'\n", "})\n", "GE_CSV_matched.head()" ] }, { "cell_type": "code", "execution_count": 43, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "最终 SMILES 唯一值数量: 1917\n" ] } ], "source": [ "import pandas as pd\n", "from rdkit import Chem\n", "\n", "def canonicalize_smiles(smiles):\n", " \"\"\"尝试将一个 SMILES 转换为规范化形式,忽略 DMSO\"\"\"\n", " if pd.isna(smiles): \n", " return smiles\n", " if str(smiles).upper() == \"DMSO\": # 特殊情况,直接跳过\n", " return \"DMSO\"\n", " try:\n", " mol = Chem.MolFromSmiles(smiles)\n", " if mol is not None:\n", " return Chem.MolToSmiles(mol)\n", " else:\n", " return smiles\n", " except:\n", " return smiles\n", "\n", "# 应用到整列\n", "GE_CSV_matched['SMILES'] = GE_CSV_matched['SMILES'].apply(canonicalize_smiles)\n", "\n", "# 查看结果\n", "final_smiles = GE_CSV_matched['SMILES'].unique()\n", "print(f\"最终 SMILES 唯一值数量: {len(final_smiles)}\")\n" ] }, { "cell_type": "code", "execution_count": 44, "metadata": {}, "outputs": [], "source": [ "# save to parquet\n", "output_path = './Step2_GE_cleaned.parquet'\n", "GE_CSV_matched.to_parquet(output_path, index=False)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 45, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "GE_CSV_matched = pd.read_parquet('./Step2_GE_cleaned.parquet')" ] }, { "cell_type": "code", "execution_count": 46, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(6929, 980)\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
pert_dosePlateSMILES221227_x_at212345_s_at218597_s_at217140_s_at209253_at214404_x_at219888_at...218397_at202996_at204608_at211071_s_at203341_at202801_at206414_s_at204978_at205379_at203897_at
050.0PAC001_U2OS_6H_X1_B1_UNI4445LCC(C)[C@H](CO)Nc1nc(Nc2cc(N)cc(Cl)c2)c2ncn(C(C...-0.118505-0.293445-0.2940880.292745-0.1458960.973580.247915...-0.5299050.8049920.430269-0.97559-1.7406050.3403820.4987780.3521520.535910.52484
112.7PAC001_U2OS_6H_X1_B1_UNI4445LIc1cccc(CSc2nnc(-c3ccncc3)o2)c10.043264-0.264945-0.0006330.0009350.177604-0.504720.214315...0.228895-0.3813080.5569690.25051-0.025625-0.024428-0.2251220.533052-0.19329-0.25436
250.0PAC001_U2OS_6H_X1_B1_UNI4445LO=C(Nc1ccncc1)Nc1c(Cl)cc(Cl)cc1Cl-0.0708050.1957550.004606-0.040855-0.067346-0.19872-0.053195...-0.031795-0.051728-0.0177410.056810.1306950.005919-0.408722-0.057177-0.256990.31004
316.2PAC001_U2OS_6H_X1_B1_UNI4445LCOc1ccc(CNC(=O)Nc2ncc([N+](=O)[O-])s2)cc10.027165-0.1495450.173113-0.100695-0.309296-0.20782-0.323985...-0.013787-0.1776080.219869-0.161290.365195-0.040848-0.2511220.0407320.17091-0.05144
412.5PAC001_U2OS_6H_X1_B1_UNI4445LO=C(O)c1ccc2c3c1cccc3c(=O)n1c3ccccc3nc210.3032940.254455-0.055418-0.0536350.000455-0.109080.031425...-0.052585-0.1961080.2454690.007840.093595-0.3034180.474878-0.022947-0.285890.06423
\n", "

5 rows × 980 columns

\n", "
" ], "text/plain": [ " pert_dose Plate \\\n", "0 50.0 PAC001_U2OS_6H_X1_B1_UNI4445L \n", "1 12.7 PAC001_U2OS_6H_X1_B1_UNI4445L \n", "2 50.0 PAC001_U2OS_6H_X1_B1_UNI4445L \n", "3 16.2 PAC001_U2OS_6H_X1_B1_UNI4445L \n", "4 12.5 PAC001_U2OS_6H_X1_B1_UNI4445L \n", "\n", " SMILES 221227_x_at \\\n", "0 CC(C)[C@H](CO)Nc1nc(Nc2cc(N)cc(Cl)c2)c2ncn(C(C... -0.118505 \n", "1 Ic1cccc(CSc2nnc(-c3ccncc3)o2)c1 0.043264 \n", "2 O=C(Nc1ccncc1)Nc1c(Cl)cc(Cl)cc1Cl -0.070805 \n", "3 COc1ccc(CNC(=O)Nc2ncc([N+](=O)[O-])s2)cc1 0.027165 \n", "4 O=C(O)c1ccc2c3c1cccc3c(=O)n1c3ccccc3nc21 0.303294 \n", "\n", " 212345_s_at 218597_s_at 217140_s_at 209253_at 214404_x_at 219888_at \\\n", "0 -0.293445 -0.294088 0.292745 -0.145896 0.97358 0.247915 \n", "1 -0.264945 -0.000633 0.000935 0.177604 -0.50472 0.214315 \n", "2 0.195755 0.004606 -0.040855 -0.067346 -0.19872 -0.053195 \n", "3 -0.149545 0.173113 -0.100695 -0.309296 -0.20782 -0.323985 \n", "4 0.254455 -0.055418 -0.053635 0.000455 -0.10908 0.031425 \n", "\n", " ... 218397_at 202996_at 204608_at 211071_s_at 203341_at 202801_at \\\n", "0 ... -0.529905 0.804992 0.430269 -0.97559 -1.740605 0.340382 \n", "1 ... 0.228895 -0.381308 0.556969 0.25051 -0.025625 -0.024428 \n", "2 ... -0.031795 -0.051728 -0.017741 0.05681 0.130695 0.005919 \n", "3 ... -0.013787 -0.177608 0.219869 -0.16129 0.365195 -0.040848 \n", "4 ... -0.052585 -0.196108 0.245469 0.00784 0.093595 -0.303418 \n", "\n", " 206414_s_at 204978_at 205379_at 203897_at \n", "0 0.498778 0.352152 0.53591 0.52484 \n", "1 -0.225122 0.533052 -0.19329 -0.25436 \n", "2 -0.408722 -0.057177 -0.25699 0.31004 \n", "3 -0.251122 0.040732 0.17091 -0.05144 \n", "4 0.474878 -0.022947 -0.28589 0.06423 \n", "\n", "[5 rows x 980 columns]" ] }, "execution_count": 46, "metadata": {}, "output_type": "execute_result" } ], "source": [ "print(GE_CSV_matched.shape)\n", "\n", "GE_CSV_matched.head()" ] }, { "cell_type": "code", "execution_count": 49, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
pert_dosePlateSMILES221227_x_at212345_s_at218597_s_at217140_s_at209253_at214404_x_at219888_at...218397_at202996_at204608_at211071_s_at203341_at202801_at206414_s_at204978_at205379_at203897_at
3644-666.0PAC008_U2OS_6H_X2_B1_UNI4445RDMSO-0.1144640.136821-0.319177-0.021415-0.0236670.577430.221430...-0.342200.08380-0.58216-0.392490-0.003960.040210.41688-0.6477490.393390-0.44556
3645-666.0PAC008_U2OS_6H_X2_B1_UNI4445RDMSO0.0620260.1164210.0658030.0326500.0355400.137140.344430...0.08018-0.08969-0.11377-0.2257900.266250.312140.000460.452851-0.0160210.48514
3646-666.0PAC008_U2OS_6H_X2_B1_UNI4445RDMSO-0.4651640.817321-0.045657-0.255690-0.0413000.52993-0.007092...-0.30240-0.20209-0.42716-0.2055900.080150.121540.17858-0.4829490.157490-0.27226
3647-666.0PAC008_U2OS_6H_X2_B1_UNI4445RDMSO-0.0478840.255221-0.225577-0.253590-0.1239500.156130.122330...-0.282900.14221-0.61346-0.1679400.023600.64294-0.31512-0.343749-0.107310-0.72266
3648-666.0PAC008_U2OS_6H_X2_B1_UNI4445RDMSO0.1669360.508521-0.0128770.141710-0.151150-0.13957-0.093540...-0.533600.065190.04714-0.0722890.09286-0.064170.07877-0.2311490.2449900.05233
3649-666.0PAC008_U2OS_6H_X2_B1_UNI4445RDMSO-0.0204540.160721-0.054257-0.288790-0.136850-0.180270.204830...0.07444-0.47469-0.09135-0.313590-0.020370.39284-0.13512-0.3566490.011830-0.13159
3650-666.0PAC008_U2OS_6H_X2_B1_UNI4445RDMSO-0.1099640.099361-0.028357-0.268090-0.3709500.973530.277630...-0.816300.34741-0.88646-0.568590-0.006840.210140.63028-0.6206490.354890-0.53586
3651-666.0PAC008_U2OS_6H_X2_B1_UNI4445RDMSO-0.2560640.193521-0.1280770.0153500.1466500.25633-0.315070...-0.01698-0.08150-0.26236-0.1805900.041760.48154-0.129720.1212510.007910-0.43996
\n", "

8 rows × 980 columns

\n", "
" ], "text/plain": [ " pert_dose Plate SMILES 221227_x_at \\\n", "3644 -666.0 PAC008_U2OS_6H_X2_B1_UNI4445R DMSO -0.114464 \n", "3645 -666.0 PAC008_U2OS_6H_X2_B1_UNI4445R DMSO 0.062026 \n", "3646 -666.0 PAC008_U2OS_6H_X2_B1_UNI4445R DMSO -0.465164 \n", "3647 -666.0 PAC008_U2OS_6H_X2_B1_UNI4445R DMSO -0.047884 \n", "3648 -666.0 PAC008_U2OS_6H_X2_B1_UNI4445R DMSO 0.166936 \n", "3649 -666.0 PAC008_U2OS_6H_X2_B1_UNI4445R DMSO -0.020454 \n", "3650 -666.0 PAC008_U2OS_6H_X2_B1_UNI4445R DMSO -0.109964 \n", "3651 -666.0 PAC008_U2OS_6H_X2_B1_UNI4445R DMSO -0.256064 \n", "\n", " 212345_s_at 218597_s_at 217140_s_at 209253_at 214404_x_at \\\n", "3644 0.136821 -0.319177 -0.021415 -0.023667 0.57743 \n", "3645 0.116421 0.065803 0.032650 0.035540 0.13714 \n", "3646 0.817321 -0.045657 -0.255690 -0.041300 0.52993 \n", "3647 0.255221 -0.225577 -0.253590 -0.123950 0.15613 \n", "3648 0.508521 -0.012877 0.141710 -0.151150 -0.13957 \n", "3649 0.160721 -0.054257 -0.288790 -0.136850 -0.18027 \n", "3650 0.099361 -0.028357 -0.268090 -0.370950 0.97353 \n", "3651 0.193521 -0.128077 0.015350 0.146650 0.25633 \n", "\n", " 219888_at ... 218397_at 202996_at 204608_at 211071_s_at 203341_at \\\n", "3644 0.221430 ... -0.34220 0.08380 -0.58216 -0.392490 -0.00396 \n", "3645 0.344430 ... 0.08018 -0.08969 -0.11377 -0.225790 0.26625 \n", "3646 -0.007092 ... -0.30240 -0.20209 -0.42716 -0.205590 0.08015 \n", "3647 0.122330 ... -0.28290 0.14221 -0.61346 -0.167940 0.02360 \n", "3648 -0.093540 ... -0.53360 0.06519 0.04714 -0.072289 0.09286 \n", "3649 0.204830 ... 0.07444 -0.47469 -0.09135 -0.313590 -0.02037 \n", "3650 0.277630 ... -0.81630 0.34741 -0.88646 -0.568590 -0.00684 \n", "3651 -0.315070 ... -0.01698 -0.08150 -0.26236 -0.180590 0.04176 \n", "\n", " 202801_at 206414_s_at 204978_at 205379_at 203897_at \n", "3644 0.04021 0.41688 -0.647749 0.393390 -0.44556 \n", "3645 0.31214 0.00046 0.452851 -0.016021 0.48514 \n", "3646 0.12154 0.17858 -0.482949 0.157490 -0.27226 \n", "3647 0.64294 -0.31512 -0.343749 -0.107310 -0.72266 \n", "3648 -0.06417 0.07877 -0.231149 0.244990 0.05233 \n", "3649 0.39284 -0.13512 -0.356649 0.011830 -0.13159 \n", "3650 0.21014 0.63028 -0.620649 0.354890 -0.53586 \n", "3651 0.48154 -0.12972 0.121251 0.007910 -0.43996 \n", "\n", "[8 rows x 980 columns]" ] }, "execution_count": 49, "metadata": {}, "output_type": "execute_result" } ], "source": [ "GE_CSV_matched.loc[GE_CSV_matched['Plate'] == 'PAC008_U2OS_6H_X2_B1_UNI4445R']" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 37, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "警告: Plate PAC007_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC007_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC008_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC008_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC008_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC008_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC008_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC008_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC009_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC009_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC009_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC009_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC009_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC009_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC010_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC010_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC010_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC010_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC011_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC011_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC011_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC011_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC011_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC011_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC012_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC012_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC012_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC012_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC012_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC012_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC013_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC013_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC013_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC013_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC013_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC013_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC014_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC014_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC014_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC014_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC014_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC014_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC015_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC015_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC015_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC015_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC015_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC015_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC016_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC016_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC016_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC016_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC016_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC016_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC017_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC017_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC017_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC017_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC017_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC017_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC018_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC018_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC018_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC018_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC018_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC018_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC019_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC019_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC019_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC019_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC019_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC019_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC020_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC020_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC020_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC020_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC020_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC020_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC021_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC021_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC021_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC021_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC021_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC021_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC022_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC022_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC022_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC022_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC023_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC023_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC023_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC023_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC023_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC023_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC024_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC024_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC024_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC024_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC024_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC024_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC025_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC025_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC025_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC025_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC025_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC025_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC026_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC026_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC026_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC026_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC026_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC026_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC027_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC027_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC027_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC027_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC027_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC027_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC028_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC028_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC028_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC028_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC028_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC028_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC029_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC029_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC029_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC029_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC029_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC029_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC030_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC030_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC030_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC030_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC030_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC030_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC031_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC031_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC031_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC031_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC031_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC031_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC032_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC032_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC032_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC032_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC032_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC032_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC033_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC033_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC033_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC033_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC033_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC033_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC034_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC034_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC034_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC034_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC034_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC034_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC035_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC035_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC035_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC035_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC035_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC035_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC036_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC036_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC036_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC036_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC036_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC036_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC037_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC037_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC037_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC037_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC037_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC037_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC038_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC038_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC038_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC038_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC038_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC038_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC039_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC039_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC039_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC039_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC039_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC039_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC040_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC040_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC040_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC040_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC040_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC040_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC041_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC041_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC041_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC041_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC041_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC041_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC042_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC042_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC042_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC042_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC042_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC042_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC043_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC043_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC043_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC043_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC043_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC043_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC044_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC044_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC044_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC044_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC044_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC044_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC045_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC045_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC045_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC045_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC045_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC045_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC046_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC046_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC046_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC046_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC046_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC046_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC047_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC047_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC047_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC047_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC047_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC047_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC048_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC048_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC048_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC048_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC048_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC048_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC049_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC049_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC049_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC049_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC049_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC049_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC050_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC050_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC050_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC050_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC050_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC050_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC051_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC051_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC051_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC051_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC051_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC051_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC052_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC052_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC052_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC052_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC052_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC052_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC053_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC053_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC053_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC053_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC053_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC053_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC054_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC054_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC054_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC054_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC054_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC054_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC055_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC055_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC055_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC055_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC055_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC055_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC056_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC056_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC056_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC056_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC056_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC056_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC057_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC057_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC057_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC057_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC057_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC057_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC058_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC058_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC058_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC058_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC058_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC058_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC059_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC059_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC059_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC059_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC059_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC059_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC060_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC060_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC060_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC060_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC060_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC060_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC061_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC061_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC061_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC061_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC061_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC061_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC062_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC062_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC062_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC063_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC063_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC063_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC063_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC063_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC063_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC064_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC064_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC064_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC064_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC064_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC064_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC065_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC065_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC065_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC065_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC065_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC066_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC066_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC066_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC066_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC066_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC066_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC067_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC067_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC067_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC067_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC068_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC068_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC068_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC068_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC068_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC068_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC069_U2OS_6H_X1_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC069_U2OS_6H_X1_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC069_U2OS_6H_X2_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC069_U2OS_6H_X2_B1_UNI4445R 中没有其他化合物数据。跳过。\n", "警告: Plate PAC069_U2OS_6H_X3_B1_UNI4445L 中没有其他化合物数据。跳过。\n", "警告: Plate PAC069_U2OS_6H_X3_B1_UNI4445R 中没有其他化合物数据。跳过。\n" ] } ], "source": [ "import pandas as pd\n", "import numpy as np\n", "import h5py\n", "\n", "# 初始化存储结果的字典\n", "results_CP = {\n", " 'smiles': [], # 存储非 DMSO 的 smiles\n", " 'control': [], # 存储 DMSO 行对应的 672 维数据\n", " 'target': [] # 存储非 DMSO 行对应的 672 维数据\n", "}\n", "\n", "def process_plate(df):\n", " # 对当前 Plate 中的相同 SMILES 进行求均值\n", " # 显式添加 numeric_only=True 来消除警告\n", " return df.groupby('SMILES', as_index=False).mean(numeric_only=True)\n", "\n", "df = GE_CSV_matched\n", "# 按 det_plate 分组,对每个组应用 process_plate 函数\n", "processed_data_list = []\n", "for plate_name, plate_df in df.groupby('Plate'):\n", " processed_plate_df = process_plate(plate_df)\n", " # 为处理后的数据添加分组ID,以便后续使用\n", " processed_plate_df['Plate'] = plate_name\n", " processed_data_list.append(processed_plate_df)\n", "\n", "if processed_data_list:\n", " processed_data = pd.concat(processed_data_list, ignore_index=True)\n", "else:\n", " print(\"没有数据可供处理。\")\n", " exit()\n", "\n", "# 获取数值列的列名列表\n", "# 这将排除 det_plate 和 CPD_SMILES\n", "numeric_cols = [col for col in processed_data.columns if col not in ['Plate', 'SMILES', 'pert_dose']]\n", "\n", "# 按 Plate 分组\n", "grouped = processed_data.groupby('Plate')\n", "\n", "# 遍历每个 Plate\n", "for plate_name, plate_data in grouped:\n", " # 分离 DMSO 和非 DMSO 行\n", " na_mask = plate_data['SMILES'] == 'DMSO'\n", " na_data = plate_data[na_mask]\n", " non_na_data = plate_data[~na_mask]\n", "\n", " # 处理 DMSO 行(control)\n", " if not na_data.empty:\n", " # 使用显式列名列表来提取数据\n", " control = na_data[numeric_cols].values\n", " control = control.flatten()\n", " else:\n", " # 这里的警告提示了你数据中可能存在的问题\n", " print(f\"警告: Plate {plate_name} 中没有 DMSO 行,使用其他 Plate 的 DMSO 均值填充。\")\n", " # 可以用所有 DMSO 的平均值作为代替\n", " all_dmso_data = processed_data[processed_data['SMILES'] == 'DMSO']\n", " if not all_dmso_data.empty:\n", " control = all_dmso_data[numeric_cols].mean().values.flatten()\n", " else:\n", " # 如果整个数据集都没有 DMSO,用全零填充\n", " print(f\"警告: 整个数据集中都没有 DMSO,用全零填充 control。\")\n", " control = np.zeros(len(numeric_cols))\n", "\n", " # 处理非 DMSO 行(smiles 和 target)\n", " if not non_na_data.empty:\n", " smiles = non_na_data['SMILES'].tolist()\n", " # 使用显式列名列表来提取数据\n", " target = non_na_data[numeric_cols].values\n", "\n", " # 对齐 control 和 target:通过重复 control 使其长度与 target 一致\n", " control_aligned = np.tile(control, (target.shape[0], 1))\n", "\n", " # 存储结果\n", " results_CP['smiles'].extend(smiles)\n", " results_CP['control'].append(control_aligned)\n", " results_CP['target'].append(target)\n", " else:\n", " print(f\"警告: Plate {plate_name} 中没有其他化合物数据。跳过。\")\n", "\n", "# 将结果转换为 NumPy 数组并保存\n", "if results_CP['smiles']:\n", " results_CP['smiles'] = np.array(results_CP['smiles'], dtype='S256') # 使用 S256 来存储字符串\n", " results_CP['control'] = np.vstack(results_CP['control'])\n", " results_CP['target'] = np.vstack(results_CP['target'])\n", "\n", " # 输出结果,用逗号分隔元素\n", " # print(\"smiles:\", np.array2string(results_CP['smiles'], separator=', '))\n", " # print(\"control:\", np.array2string(results_CP['control'], separator=', '))\n", " # print(\"target:\", np.array2string(results_CP['target'], separator=', '))\n", "\n", " # 保存到 HDF5 文件\n", " # with h5py.File('./Processed_Paired_GE.h5', 'w') as f:\n", " # f.create_dataset('smiles', data=results_CP['smiles'])\n", " # f.create_dataset('control', data=results_CP['control'])\n", " # f.create_dataset('target', data=results_CP['target'])\n", "\n", " # print(\"数据已保存到 Processed_Paired_GE.h5 文件中。\")\n", "else:\n", " print(\"没有找到任何可用的数据来保存。\")" ] }, { "cell_type": "code", "execution_count": 50, "metadata": {}, "outputs": [], "source": [ "# 使用 astype('S') 转换为字节串,这是 HDF5 存储字符串的最佳方式\n", "final_smiles = np.array(results_CP['smiles'], dtype='S')\n", "\n", "# 9. 保存到 HDF5 文件\n", "output_path = './Processed_Paired_GE.h5'\n", "with h5py.File(output_path, 'w') as f:\n", " f.create_dataset('canonical_smiles', data=final_smiles)\n", " f.create_dataset('control', data=results_CP['control'], dtype=np.float32)\n", " f.create_dataset('target', data=results_CP['target'], dtype=np.float32)\n" ] }, { "cell_type": "code", "execution_count": 51, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(3451, 977)" ] }, "execution_count": 51, "metadata": {}, "output_type": "execute_result" } ], "source": [ "results_CP['control'].shape" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array(['Brc1c(NC2=NCCN2)ccc2nccnc12',\n", " 'C/C=C1\\\\[C@H]2C=C(C)C[C@]1(N)c1ccc(=O)[nH]c1C2',\n", " 'C=C(C)[C@@H]1CC[C@]2(CO)CC[C@]3(C)[C@H](CC[C@@H]4[C@@]5(C)CC[C@H](O)C(C)(C)[C@@H]5CC[C@]43C)[C@@H]12',\n", " ..., 'c1ccc(-c2cnc(-c3ccccn3)nn2)cc1',\n", " 'c1ccc(Cn2ncc3c(N4CCN(c5ccccc5)CC4)ncnc32)cc1',\n", " 'c1ccc2c(Nc3nnc(-c4ccncc4)s3)cccc2c1'], dtype='