{ "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\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "看文件名就能大致推断这些是 L1000(基因表达)实验数据的不同处理版本。拆一下:\n", "\n", "# replicate_level_l1k.csv.gz\n", "\n", "replicate level 表示这是原始的重复水平(每个实验重复、每个孔的独立测量)。\n", "\n", "没有额外后缀,通常代表的是比较“基础”的数值(可能是直接从测序/芯片信号经过标准化后的结果)。\n", "\n", "# replicate_level_l1k_pclfc.csv.gz\n", "\n", "pclfc 应该是 plate-centered log fold change 的缩写。\n", "\n", "意味着:对同一板(plate)的数据做了中心化(plate centering),再计算 log fold change,相当于消除板间差异的影响。\n", "\n", "# replicate_level_l1k_pczscore.csv.gz\n", "\n", "pczscore = plate-centered z-score。\n", "\n", "在每个板内,先做中心化,再按标准差缩放,得到标准正态分布的 z-score 值。常用于跨板比较,因为板效应(batch effect)被部分去掉。\n", "\n", "# replicate_level_l1k_vczscore.csv.gz\n", "\n", "vczscore = vehicle-centered z-score。\n", "\n", "是以 对照组(vehicle control) 为基准,做 z-score 标准化。这样更直接衡量药物相对对照的扰动幅度。\n", "\n", "# treatment_level_l1k.csv.gz\n", "\n", "treatment level 表示已经把 replicate-level 聚合到 处理水平(treatment level)。\n", "\n", "一个药物 × 剂量 × 时间点的所有重复实验已经合并成一个代表性 profile(比如均值或中位数)。\n", "\n", "通常用于下游分析(聚类、表型比较),因为它去掉了重复的噪声。" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "如果你要做 模型训练,通常会优先用 replicate_level,因为保留了最大的信息量;如果要做 统计比较或可视化聚类,则 treatment_level 更合适。" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/tmp/ipykernel_2269741/4254072982.py:7: DtypeWarning: Columns (985) have mixed types. Specify dtype option on import or set low_memory=False.\n", " GE_CSV = pd.read_csv(GE_path)\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", "
221227_x_at212345_s_at218597_s_at217140_s_at209253_at214404_x_at219888_at201225_s_at202535_at219499_at...203897_atpert_idpert_doseBROAD_CPD_IDCPD_NAMECPD_TYPECPD_SMILESpert_sample_dosepert_typecontrol_type
0-0.547527-0.607310-1.2606221.837584-1.1767525.6846040.756884-0.920996-7.3275442.412345...2.971061BRD-K07762753-001-03-650.0BRD-K07762753aminopurvalanol ABIOCC(C)[C@H](CO)Nc1nc(Nc2cc(N)cc(Cl)c2)c2ncn(C(C...BRD-K07762753-001-03-6_50.0trtNaN
1-0.028035-0.5026020.146508-0.3841910.495755-2.7054280.6543550.256602-0.157098-0.115186...-1.714138BRD-K09991945-001-02-012.7BRD-K09991945GSK-3 inhibitor IIBIOIc1cccc(CSc2nnc(o2)-c2ccncc2)c1BRD-K09991945-001-02-0_12.7trtNaN
2-0.3943481.1900050.171630-0.702371-0.770646-0.968737-0.1619410.348620-1.860317-1.486289...1.679504BRD-K46678324-001-03-750.0BRD-K46678324RHO-kinase inhibitor IIBIOClc1cc(Cl)c(NC(=O)Nc2ccncc2)c(Cl)c1BRD-K46678324-001-03-7_50.0trtNaN
3-0.079737-0.0786230.979632-1.157979-2.021536-1.020384-0.9882450.841324-2.685479-0.412295...-0.494014BRD-K67860401-001-02-316.2BRD-K67860401GSK-3beta inhibitor VIIIBIOCOc1ccc(CNC(=O)Nc2ncc(s2)[N+]([O-])=O)cc1BRD-K67860401-001-02-3_16.2trtNaN
40.8070011.405668-0.116184-0.799675-0.420112-0.4599890.096274-0.1308440.4607151.213526...0.201490BRD-K52620403-001-01-812.5BRD-K52620403STO 609BIOOC(=O)c1ccc2c3nc4ccccc4n3c(=O)c3cccc1c23BRD-K52620403-001-01-8_12.5trtNaN
\n", "

5 rows × 986 columns

\n", "
" ], "text/plain": [ " 221227_x_at 212345_s_at 218597_s_at 217140_s_at 209253_at 214404_x_at \\\n", "0 -0.547527 -0.607310 -1.260622 1.837584 -1.176752 5.684604 \n", "1 -0.028035 -0.502602 0.146508 -0.384191 0.495755 -2.705428 \n", "2 -0.394348 1.190005 0.171630 -0.702371 -0.770646 -0.968737 \n", "3 -0.079737 -0.078623 0.979632 -1.157979 -2.021536 -1.020384 \n", "4 0.807001 1.405668 -0.116184 -0.799675 -0.420112 -0.459989 \n", "\n", " 219888_at 201225_s_at 202535_at 219499_at ... 203897_at \\\n", "0 0.756884 -0.920996 -7.327544 2.412345 ... 2.971061 \n", "1 0.654355 0.256602 -0.157098 -0.115186 ... -1.714138 \n", "2 -0.161941 0.348620 -1.860317 -1.486289 ... 1.679504 \n", "3 -0.988245 0.841324 -2.685479 -0.412295 ... -0.494014 \n", "4 0.096274 -0.130844 0.460715 1.213526 ... 0.201490 \n", "\n", " pert_id pert_dose BROAD_CPD_ID CPD_NAME \\\n", "0 BRD-K07762753-001-03-6 50.0 BRD-K07762753 aminopurvalanol A \n", "1 BRD-K09991945-001-02-0 12.7 BRD-K09991945 GSK-3 inhibitor II \n", "2 BRD-K46678324-001-03-7 50.0 BRD-K46678324 RHO-kinase inhibitor II \n", "3 BRD-K67860401-001-02-3 16.2 BRD-K67860401 GSK-3beta inhibitor VIII \n", "4 BRD-K52620403-001-01-8 12.5 BRD-K52620403 STO 609 \n", "\n", " CPD_TYPE CPD_SMILES \\\n", "0 BIO CC(C)[C@H](CO)Nc1nc(Nc2cc(N)cc(Cl)c2)c2ncn(C(C... \n", "1 BIO Ic1cccc(CSc2nnc(o2)-c2ccncc2)c1 \n", "2 BIO Clc1cc(Cl)c(NC(=O)Nc2ccncc2)c(Cl)c1 \n", "3 BIO COc1ccc(CNC(=O)Nc2ncc(s2)[N+]([O-])=O)cc1 \n", "4 BIO OC(=O)c1ccc2c3nc4ccccc4n3c(=O)c3cccc1c23 \n", "\n", " pert_sample_dose pert_type control_type \n", "0 BRD-K07762753-001-03-6_50.0 trt NaN \n", "1 BRD-K09991945-001-02-0_12.7 trt NaN \n", "2 BRD-K46678324-001-03-7_50.0 trt NaN \n", "3 BRD-K67860401-001-02-3_16.2 trt NaN \n", "4 BRD-K52620403-001-01-8_12.5 trt NaN \n", "\n", "[5 rows x 986 columns]" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "root = '/home/bob/boom/VCBench/data/MVC/CDRP-BBBC047-Bray/'\n", "\n", "CP_path = root + 'CellPainting/replicate_level_cp_normalized_variable_selected.csv.gz'\n", "GE_path = root + 'L1000/replicate_level_l1k.csv.gz'\n", "\n", "# CP_CSV = pd.read_csv(CP_path)\n", "GE_CSV = pd.read_csv(GE_path)\n", "# print(GE_CSV.shape, CP_CSV.shape)\n", "GE_CSV.head()" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(68120, 986)" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "GE_CSV.shape" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "CCCCC\\C=C\\C=C1/[C@@H](C\\C=C/CCCC(O)=O)C=CC1=O 715\n", "Oc1ccc(cc1)-c1coc2cc(O)cc(O)c2c1=O 193\n", "C[C@]12CC[C@H]3[C@@H](CCc4cc(O)ccc34)[C@@H]1CC[C@@H]2O 193\n", "CC(/C=C/C1=C(C)CCCC1(C)C)=C\\C=C\\C(C)=C\\C(O)=O 190\n", "COC1CC(CC(C)C2CC(=O)C(C)\\C=C(C)\\C(O)C(OC)C(=O)C(C)CC(C)\\C=C\\C=C\\C=C(C)\\C(CC3CCC(C)C(O)(O3)C(=O)C(=O)N3CCCCC3C(=O)O2)OC)CCC1O 189\n", " ... \n", "COC(=O)C=CC(=O)NC1CCC2(O)C3Cc4ccc(O)c5OC1C2(CCN3CC1CC1)c45 1\n", "CN(C1CCCCC1N1CCCC1)C(=O)c1ccc(Cl)c(Cl)c1 1\n", "Cc1nn(c(OC(=O)C2CCCC2)c1S(=O)(=O)c1ccccc1)C(C)(C)C 1\n", "CC1(C)[C@H](O)CC(=O)[C@@]2(C)C1CC(=O)[C@]1(C)C2CC[C@@]2(C)[C@@H](OC(=O)[C@H]3O[C@@]123)c1ccoc1 1\n", "OC(=O)C1CCCN(CCC=C(c2ccccc2)c2ccccc2)C1 1\n", "Name: CPD_SMILES, Length: 21781, dtype: int64" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "GE_CSV['CPD_SMILES'].value_counts()" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "NaN数量: 0\n" ] } ], "source": [ "nan_count = GE_CSV['CPD_SMILES'].isna().sum()\n", "print(f\"NaN数量: {nan_count}\") # 3478" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "===== Checking GeneExpression =====\n", "Shape: (68120, 986)\n", "Total NaNs: 75076 (0.11% of all values)\n", "\n", "Summary statistics:\n", " mean std min max nan_count\n", "221227_x_at -0.050873 0.890101 -14.905430 10.504144 0\n", "212345_s_at 0.059451 0.909314 -9.599837 10.908337 0\n", "218597_s_at -0.070412 0.914794 -12.414081 6.307222 0\n", "217140_s_at -0.029349 0.932918 -37.611337 11.847358 0\n", "209253_at -0.050370 0.883516 -13.595227 7.430222 0\n", "214404_x_at 0.065518 0.895404 -7.354430 12.951966 0\n", "219888_at 0.062615 0.922233 -6.044906 17.532259 0\n", "201225_s_at -0.039507 0.893109 -15.351103 9.122618 0\n", "202535_at -0.092677 0.942675 -11.542489 8.357049 0\n", "219499_at 0.037418 0.913377 -13.644873 16.996099 0\n", "... (968 more columns)\n" ] } ], "source": [ "import pandas as pd\n", "import numpy as np\n", "\n", "def check_dataframe_stats(df, name=\"DataFrame\", max_cols=10):\n", " print(f\"\\n===== Checking {name} =====\")\n", " print(f\"Shape: {df.shape}\")\n", " \n", " # NaN 检查\n", " nan_counts = df.isna().sum()\n", " total_nan = nan_counts.sum()\n", " print(f\"Total NaNs: {total_nan} \"\n", " f\"({total_nan/df.size:.2%} of all values)\")\n", " \n", " # 数值列统计\n", " numeric_df = df.select_dtypes(include=[np.number])\n", " if numeric_df.shape[1] == 0:\n", " print(\"No numeric columns found.\")\n", " return\n", " \n", " stats = pd.DataFrame({\n", " \"mean\": numeric_df.mean(),\n", " \"std\": numeric_df.std(),\n", " \"min\": numeric_df.min(),\n", " \"max\": numeric_df.max(),\n", " \"nan_count\": nan_counts.loc[numeric_df.columns]\n", " })\n", " \n", " print(\"\\nSummary statistics:\")\n", " if numeric_df.shape[1] > max_cols:\n", " # 只展示前 max_cols 列\n", " print(stats.head(max_cols))\n", " print(f\"... ({numeric_df.shape[1]-max_cols} more columns)\")\n", " else:\n", " print(stats)\n", "\n", " # 检查是否有异常(例如 std=0 或 min=max)\n", " bad_cols = stats[(stats[\"std\"] == 0) | (stats[\"min\"] == stats[\"max\"])]\n", " if not bad_cols.empty:\n", " print(\"\\nPotentially problematic columns (constant values):\")\n", " print(bad_cols)\n", "\n", "# 使用\n", "check_dataframe_stats(GE_CSV, \"GeneExpression\")\n" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "===== Checking CellPainting =====\n", "Shape: (153386, 919)\n", "Total NaNs: 15092945 (10.71% of all values)\n", "\n", "Summary statistics:\n", " mean std min \\\n", "Metadata_Plate 25549.173738 778.815664 24277.000000 \n", "Metadata_Assay_Plate_Barcode 25549.173738 778.815664 24277.000000 \n", "Metadata_mmoles_per_liter 4.139222 2.001665 0.000000 \n", "Metadata_pert_id_vendor NaN NaN NaN \n", "Cells_AreaShape_Compactness 0.090607 0.225140 -1.313544 \n", "Cells_AreaShape_EulerNumber NaN NaN NaN \n", "Cells_AreaShape_Extent -0.033060 0.176837 -3.000090 \n", "Cells_AreaShape_FormFactor 0.021036 0.300102 -3.415679 \n", "Cells_AreaShape_MaxFeretDiameter 0.108925 0.482565 -3.018066 \n", "Cells_AreaShape_MaximumRadius 0.053408 0.796516 -3.267396 \n", "\n", " max nan_count \n", "Metadata_Plate 26795.000000 0 \n", "Metadata_Assay_Plate_Barcode 26795.000000 0 \n", "Metadata_mmoles_per_liter 25.000000 0 \n", "Metadata_pert_id_vendor NaN 153386 \n", "Cells_AreaShape_Compactness 20.910727 0 \n", "Cells_AreaShape_EulerNumber NaN 153386 \n", "Cells_AreaShape_Extent 5.296431 0 \n", "Cells_AreaShape_FormFactor 5.439152 0 \n", "Cells_AreaShape_MaxFeretDiameter 40.497419 0 \n", "Cells_AreaShape_MaximumRadius 134.437945 0 \n", "... (889 more columns)\n", "\n", "Potentially problematic columns (constant values):\n", " mean std min max nan_count\n", "Cells_Correlation_Manders_AGP_Mito -inf NaN -inf -inf 152590\n", "Cells_Correlation_Manders_AGP_RNA -inf NaN -inf -inf 152978\n", "Cells_Correlation_Manders_DNA_AGP -inf NaN -inf -inf 153269\n", "Cells_Correlation_Manders_DNA_ER -inf NaN -inf -inf 151860\n", "Cells_Correlation_Manders_DNA_Mito -inf NaN -inf -inf 153214\n", "Cells_Correlation_Manders_DNA_RNA -inf NaN -inf -inf 153365\n", "Cells_Correlation_Manders_ER_AGP -inf NaN -inf -inf 153254\n", "Cells_Correlation_Manders_ER_Mito -inf NaN -inf -inf 152963\n", "Cells_Correlation_Manders_ER_RNA -inf NaN -inf -inf 153190\n", "Cells_Correlation_Manders_Mito_AGP -inf NaN -inf -inf 153066\n", "Cells_Correlation_Manders_Mito_RNA -inf NaN -inf -inf 152995\n", "Cells_Correlation_Manders_RNA_AGP -inf NaN -inf -inf 153059\n", "Cells_Correlation_Manders_RNA_Mito -inf NaN -inf -inf 152566\n", "Cytoplasm_Correlation_Manders_AGP_DNA -inf NaN -inf -inf 152609\n", "Cytoplasm_Correlation_Manders_AGP_Mito -inf NaN -inf -inf 152783\n", "Cytoplasm_Correlation_Manders_AGP_RNA -inf NaN -inf -inf 153350\n", "Cytoplasm_Correlation_Manders_DNA_AGP -inf NaN -inf -inf 153123\n", "Cytoplasm_Correlation_Manders_DNA_Mito -inf NaN -inf -inf 152658\n", "Cytoplasm_Correlation_Manders_DNA_RNA -inf NaN -inf -inf 153341\n", "Cytoplasm_Correlation_Manders_ER_AGP -inf NaN -inf -inf 153308\n", "Cytoplasm_Correlation_Manders_ER_DNA -inf NaN -inf -inf 153184\n", "Cytoplasm_Correlation_Manders_ER_Mito -inf NaN -inf -inf 153091\n", "Cytoplasm_Correlation_Manders_ER_RNA -inf NaN -inf -inf 153367\n", "Cytoplasm_Correlation_Manders_Mito_AGP -inf NaN -inf -inf 153193\n", "Cytoplasm_Correlation_Manders_Mito_DNA -inf NaN -inf -inf 152635\n", "Cytoplasm_Correlation_Manders_Mito_RNA -inf NaN -inf -inf 153358\n", "Cytoplasm_Correlation_Manders_RNA_AGP -inf NaN -inf -inf 153135\n", "Cytoplasm_Correlation_Manders_RNA_DNA -inf NaN -inf -inf 152606\n", "Cytoplasm_Correlation_Manders_RNA_Mito -inf NaN -inf -inf 152669\n", "Nuclei_AreaShape_EulerNumber -inf NaN -inf -inf 153378\n", "Nuclei_Correlation_Manders_AGP_DNA -inf NaN -inf -inf 152875\n", "Nuclei_Correlation_Manders_AGP_ER -inf NaN -inf -inf 153250\n", "Nuclei_Correlation_Manders_AGP_Mito -inf NaN -inf -inf 153372\n", "Nuclei_Correlation_Manders_AGP_RNA -inf NaN -inf -inf 153382\n", "Nuclei_Correlation_Manders_DNA_AGP -inf NaN -inf -inf 153373\n", "Nuclei_Correlation_Manders_DNA_ER -inf NaN -inf -inf 153278\n", "Nuclei_Correlation_Manders_DNA_Mito -inf NaN -inf -inf 153374\n", "Nuclei_Correlation_Manders_DNA_RNA -inf NaN -inf -inf 153384\n", "Nuclei_Correlation_Manders_ER_AGP -inf NaN -inf -inf 153380\n", "Nuclei_Correlation_Manders_ER_DNA -inf NaN -inf -inf 152884\n", "Nuclei_Correlation_Manders_ER_Mito -inf NaN -inf -inf 153377\n", "Nuclei_Correlation_Manders_ER_RNA -inf NaN -inf -inf 153384\n", "Nuclei_Correlation_Manders_Mito_AGP -inf NaN -inf -inf 153374\n", "Nuclei_Correlation_Manders_Mito_DNA -inf NaN -inf -inf 152876\n", "Nuclei_Correlation_Manders_Mito_ER -inf NaN -inf -inf 153247\n", "Nuclei_Correlation_Manders_Mito_RNA -inf NaN -inf -inf 153381\n", "Nuclei_Correlation_Manders_RNA_AGP -inf NaN -inf -inf 153366\n", "Nuclei_Correlation_Manders_RNA_DNA -inf NaN -inf -inf 152875\n", "Nuclei_Correlation_Manders_RNA_ER -inf NaN -inf -inf 153246\n", "Nuclei_Correlation_Manders_RNA_Mito -inf NaN -inf -inf 153368\n" ] } ], "source": [ "check_dataframe_stats(CP_CSV, \"CellPainting\")" ] }, { "cell_type": "code", "execution_count": 6, "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", "
221227_x_at212345_s_at218597_s_at217140_s_at209253_at214404_x_at219888_at201225_s_at202535_at219499_at...203897_atpert_idpert_doseBROAD_CPD_IDCPD_NAMECPD_TYPECPD_SMILESpert_sample_dosepert_typecontrol_type
0-0.440750-0.980983-1.4656981.760966-0.4768692.4799180.758642-0.595733-3.3612791.425795...1.622410BRD-K07762753-001-03-650.0BRD-K07762753aminopurvalanol ABIOCC(C)[C@H](CO)Nc1nc(Nc2cc(N)cc(Cl)c2)c2ncn(C(C...BRD-K07762753-001-03-6_50.0trtNaN
10.160911-0.885708-0.0031570.0056240.580509-1.2856310.6558230.5404520.286736-0.206910...-0.786290BRD-K09991945-001-02-012.7BRD-K09991945GSK-3 inhibitor IIBIOIc1cccc(CSc2nnc(o2)-c2ccncc2)c1BRD-K09991945-001-02-0_12.7trtNaN
2-0.2633420.6544070.022953-0.245757-0.220124-0.506183-0.1627810.629234-0.579788-1.092600...0.958410BRD-K46678324-001-03-750.0BRD-K46678324RHO-kinase inhibitor IIBIOClc1cc(Cl)c(NC(=O)Nc2ccncc2)c(Cl)c1BRD-K46678324-001-03-7_50.0trtNaN
30.101031-0.4999270.862773-0.605716-1.010951-0.529362-0.9914231.104611-0.999595-0.398834...-0.159014BRD-K67860401-001-02-316.2BRD-K67860401GSK-3beta inhibitor VIIIBIOCOc1ccc(CNC(=O)Nc2ncc(s2)[N+]([O-])=O)cc1BRD-K67860401-001-02-3_16.2trtNaN
41.1280230.850640-0.276194-0.3226340.001487-0.2778500.0961630.1666310.6010530.651396...0.198551BRD-K52620403-001-01-812.5BRD-K52620403STO 609BIOOC(=O)c1ccc2c3nc4ccccc4n3c(=O)c3cccc1c23BRD-K52620403-001-01-8_12.5trtNaN
\n", "

5 rows × 986 columns

\n", "
" ], "text/plain": [ " 221227_x_at 212345_s_at 218597_s_at 217140_s_at 209253_at 214404_x_at \\\n", "0 -0.440750 -0.980983 -1.465698 1.760966 -0.476869 2.479918 \n", "1 0.160911 -0.885708 -0.003157 0.005624 0.580509 -1.285631 \n", "2 -0.263342 0.654407 0.022953 -0.245757 -0.220124 -0.506183 \n", "3 0.101031 -0.499927 0.862773 -0.605716 -1.010951 -0.529362 \n", "4 1.128023 0.850640 -0.276194 -0.322634 0.001487 -0.277850 \n", "\n", " 219888_at 201225_s_at 202535_at 219499_at ... 203897_at \\\n", "0 0.758642 -0.595733 -3.361279 1.425795 ... 1.622410 \n", "1 0.655823 0.540452 0.286736 -0.206910 ... -0.786290 \n", "2 -0.162781 0.629234 -0.579788 -1.092600 ... 0.958410 \n", "3 -0.991423 1.104611 -0.999595 -0.398834 ... -0.159014 \n", "4 0.096163 0.166631 0.601053 0.651396 ... 0.198551 \n", "\n", " pert_id pert_dose BROAD_CPD_ID CPD_NAME \\\n", "0 BRD-K07762753-001-03-6 50.0 BRD-K07762753 aminopurvalanol A \n", "1 BRD-K09991945-001-02-0 12.7 BRD-K09991945 GSK-3 inhibitor II \n", "2 BRD-K46678324-001-03-7 50.0 BRD-K46678324 RHO-kinase inhibitor II \n", "3 BRD-K67860401-001-02-3 16.2 BRD-K67860401 GSK-3beta inhibitor VIII \n", "4 BRD-K52620403-001-01-8 12.5 BRD-K52620403 STO 609 \n", "\n", " CPD_TYPE CPD_SMILES \\\n", "0 BIO CC(C)[C@H](CO)Nc1nc(Nc2cc(N)cc(Cl)c2)c2ncn(C(C... \n", "1 BIO Ic1cccc(CSc2nnc(o2)-c2ccncc2)c1 \n", "2 BIO Clc1cc(Cl)c(NC(=O)Nc2ccncc2)c(Cl)c1 \n", "3 BIO COc1ccc(CNC(=O)Nc2ncc(s2)[N+]([O-])=O)cc1 \n", "4 BIO OC(=O)c1ccc2c3nc4ccccc4n3c(=O)c3cccc1c23 \n", "\n", " pert_sample_dose pert_type control_type \n", "0 BRD-K07762753-001-03-6_50.0 trt NaN \n", "1 BRD-K09991945-001-02-0_12.7 trt NaN \n", "2 BRD-K46678324-001-03-7_50.0 trt NaN \n", "3 BRD-K67860401-001-02-3_16.2 trt NaN \n", "4 BRD-K52620403-001-01-8_12.5 trt NaN \n", "\n", "[5 rows x 986 columns]" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "GE_CSV.head()" ] }, { "cell_type": "code", "execution_count": 10, "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_PlateMetadata_WellMetadata_Assay_Plate_BarcodeMetadata_Plate_Map_NameMetadata_well_positionMetadata_ASSAY_WELL_ROLEMetadata_broad_sampleMetadata_mmoles_per_literMetadata_solventMetadata_pert_id...Nuclei_Texture_Variance_ER_5_0Nuclei_Texture_Variance_RNA_5_0Metadata_pert_inameMetadata_pert_iname2Metadata_moaMetadata_targetMetadata_mmoles_per_liter2Metadata_Sample_Dosepert_typecontrol_type
024277a0124277H-BIOA-004-3a01treatedBRD-K18250272-003-03-73.022516DMSOBRD-K18250272...-0.199967-0.075658propoxycainepropoxycainelocal anestheticNaN6.05BRD-K18250272-003-03-7_6.05trtNaN
124277a0224277H-BIOA-004-3a02treatedBRD-K18316707-001-01-95.000000DMSOBRD-K18316707...-0.1261830.018563O-1918BRD-K18316707cannabinoid receptor antagonistNaN10.00BRD-K18316707-001-01-9_10.0trtNaN
224277a0324277H-BIOA-004-3a03treatedBRD-K18438502-001-02-65.000000DMSOBRD-K18438502...-0.0343550.052914NaNNaNNaNNaN10.00BRD-K18438502-001-02-6_10.0trtNaN
324277a0424277H-BIOA-004-3a04treatedBRD-K18550767-001-02-85.000000DMSOBRD-K18550767...-0.0422410.249977bergeninbergenininterleukin inhibitorIL1B, TNF10.00BRD-K18550767-001-02-8_10.0trtNaN
424277a0524277H-BIOA-004-3a05treatedBRD-K18574842-323-03-32.195487DMSOBRD-K18574842...0.0800180.335890nafcillinnafcillinbacterial cell wall synthesis inhibitorCYP1A2, CYP3A4, SLC22A64.39BRD-K18574842-323-03-3_4.39trtNaN
\n", "

5 rows × 919 columns

\n", "
" ], "text/plain": [ " Metadata_Plate Metadata_Well Metadata_Assay_Plate_Barcode \\\n", "0 24277 a01 24277 \n", "1 24277 a02 24277 \n", "2 24277 a03 24277 \n", "3 24277 a04 24277 \n", "4 24277 a05 24277 \n", "\n", " Metadata_Plate_Map_Name Metadata_well_position Metadata_ASSAY_WELL_ROLE \\\n", "0 H-BIOA-004-3 a01 treated \n", "1 H-BIOA-004-3 a02 treated \n", "2 H-BIOA-004-3 a03 treated \n", "3 H-BIOA-004-3 a04 treated \n", "4 H-BIOA-004-3 a05 treated \n", "\n", " Metadata_broad_sample Metadata_mmoles_per_liter Metadata_solvent \\\n", "0 BRD-K18250272-003-03-7 3.022516 DMSO \n", "1 BRD-K18316707-001-01-9 5.000000 DMSO \n", "2 BRD-K18438502-001-02-6 5.000000 DMSO \n", "3 BRD-K18550767-001-02-8 5.000000 DMSO \n", "4 BRD-K18574842-323-03-3 2.195487 DMSO \n", "\n", " Metadata_pert_id ... Nuclei_Texture_Variance_ER_5_0 \\\n", "0 BRD-K18250272 ... -0.199967 \n", "1 BRD-K18316707 ... -0.126183 \n", "2 BRD-K18438502 ... -0.034355 \n", "3 BRD-K18550767 ... -0.042241 \n", "4 BRD-K18574842 ... 0.080018 \n", "\n", " Nuclei_Texture_Variance_RNA_5_0 Metadata_pert_iname Metadata_pert_iname2 \\\n", "0 -0.075658 propoxycaine propoxycaine \n", "1 0.018563 O-1918 BRD-K18316707 \n", "2 0.052914 NaN NaN \n", "3 0.249977 bergenin bergenin \n", "4 0.335890 nafcillin nafcillin \n", "\n", " Metadata_moa Metadata_target \\\n", "0 local anesthetic NaN \n", "1 cannabinoid receptor antagonist NaN \n", "2 NaN NaN \n", "3 interleukin inhibitor IL1B, TNF \n", "4 bacterial cell wall synthesis inhibitor CYP1A2, CYP3A4, SLC22A6 \n", "\n", " Metadata_mmoles_per_liter2 Metadata_Sample_Dose pert_type \\\n", "0 6.05 BRD-K18250272-003-03-7_6.05 trt \n", "1 10.00 BRD-K18316707-001-01-9_10.0 trt \n", "2 10.00 BRD-K18438502-001-02-6_10.0 trt \n", "3 10.00 BRD-K18550767-001-02-8_10.0 trt \n", "4 4.39 BRD-K18574842-323-03-3_4.39 trt \n", "\n", " control_type \n", "0 NaN \n", "1 NaN \n", "2 NaN \n", "3 NaN \n", "4 NaN \n", "\n", "[5 rows x 919 columns]" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "CP_CSV.head()" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "ename": "KeyError", "evalue": "'det_plate'", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", "File \u001b[0;32m~/anaconda3/envs/boom/lib/python3.11/site-packages/pandas/core/indexes/base.py:3802\u001b[0m, in \u001b[0;36mIndex.get_loc\u001b[0;34m(self, key, method, tolerance)\u001b[0m\n\u001b[1;32m 3801\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m-> 3802\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_engine\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_loc\u001b[49m\u001b[43m(\u001b[49m\u001b[43mcasted_key\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 3803\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mKeyError\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m err:\n", "File \u001b[0;32m~/anaconda3/envs/boom/lib/python3.11/site-packages/pandas/_libs/index.pyx:138\u001b[0m, in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[0;34m()\u001b[0m\n", "File \u001b[0;32m~/anaconda3/envs/boom/lib/python3.11/site-packages/pandas/_libs/index.pyx:165\u001b[0m, in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[0;34m()\u001b[0m\n", "File \u001b[0;32mpandas/_libs/hashtable_class_helper.pxi:5745\u001b[0m, in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[0;34m()\u001b[0m\n", "File \u001b[0;32mpandas/_libs/hashtable_class_helper.pxi:5753\u001b[0m, in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[0;34m()\u001b[0m\n", "\u001b[0;31mKeyError\u001b[0m: 'det_plate'", "\nThe above exception was the direct cause of the following exception:\n", "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", "Cell \u001b[0;32mIn[5], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;28mlen\u001b[39m(GE_CSV[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mCPD_SMILES\u001b[39m\u001b[38;5;124m'\u001b[39m]\u001b[38;5;241m.\u001b[39munique()), \u001b[38;5;28mlen\u001b[39m(\u001b[43mGE_CSV\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mdet_plate\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m]\u001b[49m\u001b[38;5;241m.\u001b[39munique())) \u001b[38;5;66;03m# 这里错了\u001b[39;00m\n", "File \u001b[0;32m~/anaconda3/envs/boom/lib/python3.11/site-packages/pandas/core/frame.py:3807\u001b[0m, in \u001b[0;36mDataFrame.__getitem__\u001b[0;34m(self, key)\u001b[0m\n\u001b[1;32m 3805\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mcolumns\u001b[38;5;241m.\u001b[39mnlevels \u001b[38;5;241m>\u001b[39m \u001b[38;5;241m1\u001b[39m:\n\u001b[1;32m 3806\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_getitem_multilevel(key)\n\u001b[0;32m-> 3807\u001b[0m indexer \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcolumns\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_loc\u001b[49m\u001b[43m(\u001b[49m\u001b[43mkey\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 3808\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m is_integer(indexer):\n\u001b[1;32m 3809\u001b[0m indexer \u001b[38;5;241m=\u001b[39m [indexer]\n", "File \u001b[0;32m~/anaconda3/envs/boom/lib/python3.11/site-packages/pandas/core/indexes/base.py:3804\u001b[0m, in \u001b[0;36mIndex.get_loc\u001b[0;34m(self, key, method, tolerance)\u001b[0m\n\u001b[1;32m 3802\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_engine\u001b[38;5;241m.\u001b[39mget_loc(casted_key)\n\u001b[1;32m 3803\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mKeyError\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m err:\n\u001b[0;32m-> 3804\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mKeyError\u001b[39;00m(key) \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01merr\u001b[39;00m\n\u001b[1;32m 3805\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mTypeError\u001b[39;00m:\n\u001b[1;32m 3806\u001b[0m \u001b[38;5;66;03m# If we have a listlike key, _check_indexing_error will raise\u001b[39;00m\n\u001b[1;32m 3807\u001b[0m \u001b[38;5;66;03m# InvalidIndexError. Otherwise we fall through and re-raise\u001b[39;00m\n\u001b[1;32m 3808\u001b[0m \u001b[38;5;66;03m# the TypeError.\u001b[39;00m\n\u001b[1;32m 3809\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_check_indexing_error(key)\n", "\u001b[0;31mKeyError\u001b[0m: 'det_plate'" ] } ], "source": [ "print(len(GE_CSV['CPD_SMILES'].unique()), len(GE_CSV['det_plate'].unique())) # 这里错了" ] }, { "cell_type": "code", "execution_count": 11, "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", "
indexpert_type
0trt126814
1control26572
\n", "
" ], "text/plain": [ " index pert_type\n", "0 trt 126814\n", "1 control 26572" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "CP_CSV['pert_type'].value_counts().reset_index()" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "30413" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "len(CP_CSV['Metadata_pert_id'].unique())" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "映射字典大小: 21782\n", "匹配成功: 86844/153386 (56.62%)\n" ] } ], "source": [ "# 创建BROAD_CPD_ID到CPD_SMILES的映射字典\n", "smiles_mapping = dict(zip(GE_CSV['BROAD_CPD_ID'], GE_CSV['CPD_SMILES']))\n", "\n", "# 检查映射是否唯一(键值对数量应等于唯一ID数量)\n", "print(f\"映射字典大小: {len(smiles_mapping)}\")\n", "\n", "# 使用映射为CP_CSV添加SMILES列\n", "CP_CSV['SMILES'] = CP_CSV['Metadata_pert_id'].map(smiles_mapping)\n", "\n", "# 检查匹配情况\n", "matched = CP_CSV['SMILES'].notna().sum()\n", "total = len(CP_CSV)\n", "print(f\"匹配成功: {matched}/{total} ({matched/total:.2%})\")\n", "\n", "# 保存结果\n", "# CP_CSV.to_csv('path/to/updated_cp_data.csv', index=False) " ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(113416, 920)" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# 提取匹配成功或者pert_type为'control'的记录(或关系)\n", "\n", "CP_CSV_matched = CP_CSV[\n", " (CP_CSV['SMILES'].notna()) | # 匹配成功的记录\n", " (CP_CSV['pert_type'] == 'control') # 或pert_type为control的记录\n", "].copy()\n", "CP_CSV_matched.shape" ] }, { "cell_type": "code", "execution_count": 23, "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_PlateMetadata_WellMetadata_Assay_Plate_BarcodeMetadata_Plate_Map_NameMetadata_well_positionMetadata_ASSAY_WELL_ROLEMetadata_broad_sampleMetadata_mmoles_per_literMetadata_solventMetadata_pert_id...Nuclei_Texture_Variance_RNA_5_0Metadata_pert_inameMetadata_pert_iname2Metadata_moaMetadata_targetMetadata_mmoles_per_liter2Metadata_Sample_Dosepert_typecontrol_typeSMILES
024277a0124277H-BIOA-004-3a01treatedBRD-K18250272-003-03-73.022516DMSOBRD-K18250272...-0.075658propoxycainepropoxycainelocal anestheticNaN6.05BRD-K18250272-003-03-7_6.05trtNaNCCCOc1cc(N)ccc1C(=O)OCCN(CC)CC
124277a0224277H-BIOA-004-3a02treatedBRD-K18316707-001-01-95.000000DMSOBRD-K18316707...0.018563O-1918BRD-K18316707cannabinoid receptor antagonistNaN10.00BRD-K18316707-001-01-9_10.0trtNaNCOc1cc(C)cc(OC)c1[C@@H]1C=C(C)CC[C@H]1C(C)=C
224277a0324277H-BIOA-004-3a03treatedBRD-K18438502-001-02-65.000000DMSOBRD-K18438502...0.052914NaNNaNNaNNaN10.00BRD-K18438502-001-02-6_10.0trtNaNCOc1cc(O)cc(\\C=C\\c2ccccc2)c1
324277a0424277H-BIOA-004-3a04treatedBRD-K18550767-001-02-85.000000DMSOBRD-K18550767...0.249977bergeninbergenininterleukin inhibitorIL1B, TNF10.00BRD-K18550767-001-02-8_10.0trtNaNCOc1c(O)cc2C(=O)O[C@H]3[C@@H](O)[C@H](O)[C@@H]...
424277a0524277H-BIOA-004-3a05treatedBRD-K18574842-323-03-32.195487DMSOBRD-K18574842...0.335890nafcillinnafcillinbacterial cell wall synthesis inhibitorCYP1A2, CYP3A4, SLC22A64.39BRD-K18574842-323-03-3_4.39trtNaNCCOc1ccc2ccccc2c1C(=O)N[C@H]1[C@H]2SC(C)(C)[C@...
\n", "

5 rows × 920 columns

\n", "
" ], "text/plain": [ " Metadata_Plate Metadata_Well Metadata_Assay_Plate_Barcode \\\n", "0 24277 a01 24277 \n", "1 24277 a02 24277 \n", "2 24277 a03 24277 \n", "3 24277 a04 24277 \n", "4 24277 a05 24277 \n", "\n", " Metadata_Plate_Map_Name Metadata_well_position Metadata_ASSAY_WELL_ROLE \\\n", "0 H-BIOA-004-3 a01 treated \n", "1 H-BIOA-004-3 a02 treated \n", "2 H-BIOA-004-3 a03 treated \n", "3 H-BIOA-004-3 a04 treated \n", "4 H-BIOA-004-3 a05 treated \n", "\n", " Metadata_broad_sample Metadata_mmoles_per_liter Metadata_solvent \\\n", "0 BRD-K18250272-003-03-7 3.022516 DMSO \n", "1 BRD-K18316707-001-01-9 5.000000 DMSO \n", "2 BRD-K18438502-001-02-6 5.000000 DMSO \n", "3 BRD-K18550767-001-02-8 5.000000 DMSO \n", "4 BRD-K18574842-323-03-3 2.195487 DMSO \n", "\n", " Metadata_pert_id ... Nuclei_Texture_Variance_RNA_5_0 Metadata_pert_iname \\\n", "0 BRD-K18250272 ... -0.075658 propoxycaine \n", "1 BRD-K18316707 ... 0.018563 O-1918 \n", "2 BRD-K18438502 ... 0.052914 NaN \n", "3 BRD-K18550767 ... 0.249977 bergenin \n", "4 BRD-K18574842 ... 0.335890 nafcillin \n", "\n", " Metadata_pert_iname2 Metadata_moa \\\n", "0 propoxycaine local anesthetic \n", "1 BRD-K18316707 cannabinoid receptor antagonist \n", "2 NaN NaN \n", "3 bergenin interleukin inhibitor \n", "4 nafcillin bacterial cell wall synthesis inhibitor \n", "\n", " Metadata_target Metadata_mmoles_per_liter2 \\\n", "0 NaN 6.05 \n", "1 NaN 10.00 \n", "2 NaN 10.00 \n", "3 IL1B, TNF 10.00 \n", "4 CYP1A2, CYP3A4, SLC22A6 4.39 \n", "\n", " Metadata_Sample_Dose pert_type control_type \\\n", "0 BRD-K18250272-003-03-7_6.05 trt NaN \n", "1 BRD-K18316707-001-01-9_10.0 trt NaN \n", "2 BRD-K18438502-001-02-6_10.0 trt NaN \n", "3 BRD-K18550767-001-02-8_10.0 trt NaN \n", "4 BRD-K18574842-323-03-3_4.39 trt NaN \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 920 columns]" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "CP_CSV_matched.head()" ] }, { "cell_type": "code", "execution_count": 24, "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", "
indexpert_type
0trt86844
1control26572
\n", "
" ], "text/plain": [ " index pert_type\n", "0 trt 86844\n", "1 control 26572" ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "CP_CSV_matched['pert_type'].value_counts().reset_index()" ] }, { "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", "
Metadata_PlateMetadata_WellMetadata_Assay_Plate_BarcodeMetadata_Plate_Map_NameMetadata_well_positionMetadata_ASSAY_WELL_ROLEMetadata_broad_sampleMetadata_mmoles_per_literMetadata_solventMetadata_pert_id...Nuclei_Texture_Variance_RNA_5_0Metadata_pert_inameMetadata_pert_iname2Metadata_moaMetadata_targetMetadata_mmoles_per_liter2Metadata_Sample_Dosepert_typecontrol_typeSMILES
024277a0124277H-BIOA-004-3a01treatedBRD-K18250272-003-03-73.022516DMSOBRD-K18250272...-0.075658propoxycainepropoxycainelocal anestheticNaN6.05BRD-K18250272-003-03-7_6.05trtNaNCCCOc1cc(N)ccc1C(=O)OCCN(CC)CC
124277a0224277H-BIOA-004-3a02treatedBRD-K18316707-001-01-95.000000DMSOBRD-K18316707...0.018563O-1918BRD-K18316707cannabinoid receptor antagonistNaN10.00BRD-K18316707-001-01-9_10.0trtNaNCOc1cc(C)cc(OC)c1[C@@H]1C=C(C)CC[C@H]1C(C)=C
224277a0324277H-BIOA-004-3a03treatedBRD-K18438502-001-02-65.000000DMSOBRD-K18438502...0.052914NaNNaNNaNNaN10.00BRD-K18438502-001-02-6_10.0trtNaNCOc1cc(O)cc(\\C=C\\c2ccccc2)c1
324277a0424277H-BIOA-004-3a04treatedBRD-K18550767-001-02-85.000000DMSOBRD-K18550767...0.249977bergeninbergenininterleukin inhibitorIL1B, TNF10.00BRD-K18550767-001-02-8_10.0trtNaNCOc1c(O)cc2C(=O)O[C@H]3[C@@H](O)[C@H](O)[C@@H]...
424277a0524277H-BIOA-004-3a05treatedBRD-K18574842-323-03-32.195487DMSOBRD-K18574842...0.335890nafcillinnafcillinbacterial cell wall synthesis inhibitorCYP1A2, CYP3A4, SLC22A64.39BRD-K18574842-323-03-3_4.39trtNaNCCOc1ccc2ccccc2c1C(=O)N[C@H]1[C@H]2SC(C)(C)[C@...
\n", "

5 rows × 920 columns

\n", "
" ], "text/plain": [ " Metadata_Plate Metadata_Well Metadata_Assay_Plate_Barcode \\\n", "0 24277 a01 24277 \n", "1 24277 a02 24277 \n", "2 24277 a03 24277 \n", "3 24277 a04 24277 \n", "4 24277 a05 24277 \n", "\n", " Metadata_Plate_Map_Name Metadata_well_position Metadata_ASSAY_WELL_ROLE \\\n", "0 H-BIOA-004-3 a01 treated \n", "1 H-BIOA-004-3 a02 treated \n", "2 H-BIOA-004-3 a03 treated \n", "3 H-BIOA-004-3 a04 treated \n", "4 H-BIOA-004-3 a05 treated \n", "\n", " Metadata_broad_sample Metadata_mmoles_per_liter Metadata_solvent \\\n", "0 BRD-K18250272-003-03-7 3.022516 DMSO \n", "1 BRD-K18316707-001-01-9 5.000000 DMSO \n", "2 BRD-K18438502-001-02-6 5.000000 DMSO \n", "3 BRD-K18550767-001-02-8 5.000000 DMSO \n", "4 BRD-K18574842-323-03-3 2.195487 DMSO \n", "\n", " Metadata_pert_id ... Nuclei_Texture_Variance_RNA_5_0 Metadata_pert_iname \\\n", "0 BRD-K18250272 ... -0.075658 propoxycaine \n", "1 BRD-K18316707 ... 0.018563 O-1918 \n", "2 BRD-K18438502 ... 0.052914 NaN \n", "3 BRD-K18550767 ... 0.249977 bergenin \n", "4 BRD-K18574842 ... 0.335890 nafcillin \n", "\n", " Metadata_pert_iname2 Metadata_moa \\\n", "0 propoxycaine local anesthetic \n", "1 BRD-K18316707 cannabinoid receptor antagonist \n", "2 NaN NaN \n", "3 bergenin interleukin inhibitor \n", "4 nafcillin bacterial cell wall synthesis inhibitor \n", "\n", " Metadata_target Metadata_mmoles_per_liter2 \\\n", "0 NaN 6.05 \n", "1 NaN 10.00 \n", "2 NaN 10.00 \n", "3 IL1B, TNF 10.00 \n", "4 CYP1A2, CYP3A4, SLC22A6 4.39 \n", "\n", " Metadata_Sample_Dose pert_type control_type \\\n", "0 BRD-K18250272-003-03-7_6.05 trt NaN \n", "1 BRD-K18316707-001-01-9_10.0 trt NaN \n", "2 BRD-K18438502-001-02-6_10.0 trt NaN \n", "3 BRD-K18550767-001-02-8_10.0 trt NaN \n", "4 BRD-K18574842-323-03-3_4.39 trt NaN \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 920 columns]" ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "CP_CSV_matched.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# 删除无关元素,保留核心" ] }, { "cell_type": "code", "execution_count": 33, "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_PlateMetadata_pert_mfc_idMetadata_pert_wellMetadata_pert_id_vendorMetadata_cell_idMetadata_broad_sample_typeMetadata_pert_vehicleMetadata_pert_typeCells_AreaShape_CompactnessCells_AreaShape_EulerNumber...Nuclei_Texture_Variance_RNA_5_0Metadata_pert_inameMetadata_pert_iname2Metadata_moaMetadata_targetMetadata_mmoles_per_liter2Metadata_Sample_Dosepert_typecontrol_typeSMILES
024277BRD-K18250272-003-03-7a01NaNU2OStrtDMSOtrt0.256710NaN...-0.075658propoxycainepropoxycainelocal anestheticNaN6.05BRD-K18250272-003-03-7_6.05trtNaNCCCOc1cc(N)ccc1C(=O)OCCN(CC)CC
124277BRD-K18316707-001-01-9a02NaNU2OStrtDMSOtrt0.050962NaN...0.018563O-1918BRD-K18316707cannabinoid receptor antagonistNaN10.00BRD-K18316707-001-01-9_10.0trtNaNCOc1cc(C)cc(OC)c1[C@@H]1C=C(C)CC[C@H]1C(C)=C
224277BRD-K18438502-001-02-6a03NaNU2OStrtDMSOtrt-0.098185NaN...0.052914NaNNaNNaNNaN10.00BRD-K18438502-001-02-6_10.0trtNaNCOc1cc(O)cc(\\C=C\\c2ccccc2)c1
324277BRD-K18550767-001-02-8a04NaNU2OStrtDMSOtrt0.410722NaN...0.249977bergeninbergenininterleukin inhibitorIL1B, TNF10.00BRD-K18550767-001-02-8_10.0trtNaNCOc1c(O)cc2C(=O)O[C@H]3[C@@H](O)[C@H](O)[C@@H]...
424277BRD-K18574842-323-03-3a05NaNU2OStrtDMSOtrt0.248559NaN...0.335890nafcillinnafcillinbacterial cell wall synthesis inhibitorCYP1A2, CYP3A4, SLC22A64.39BRD-K18574842-323-03-3_4.39trtNaNCCOc1ccc2ccccc2c1C(=O)N[C@H]1[C@H]2SC(C)(C)[C@...
\n", "

5 rows × 911 columns

\n", "
" ], "text/plain": [ " Metadata_Plate Metadata_pert_mfc_id Metadata_pert_well \\\n", "0 24277 BRD-K18250272-003-03-7 a01 \n", "1 24277 BRD-K18316707-001-01-9 a02 \n", "2 24277 BRD-K18438502-001-02-6 a03 \n", "3 24277 BRD-K18550767-001-02-8 a04 \n", "4 24277 BRD-K18574842-323-03-3 a05 \n", "\n", " Metadata_pert_id_vendor Metadata_cell_id Metadata_broad_sample_type \\\n", "0 NaN U2OS trt \n", "1 NaN U2OS trt \n", "2 NaN U2OS trt \n", "3 NaN U2OS trt \n", "4 NaN U2OS trt \n", "\n", " Metadata_pert_vehicle Metadata_pert_type Cells_AreaShape_Compactness \\\n", "0 DMSO trt 0.256710 \n", "1 DMSO trt 0.050962 \n", "2 DMSO trt -0.098185 \n", "3 DMSO trt 0.410722 \n", "4 DMSO trt 0.248559 \n", "\n", " Cells_AreaShape_EulerNumber ... Nuclei_Texture_Variance_RNA_5_0 \\\n", "0 NaN ... -0.075658 \n", "1 NaN ... 0.018563 \n", "2 NaN ... 0.052914 \n", "3 NaN ... 0.249977 \n", "4 NaN ... 0.335890 \n", "\n", " Metadata_pert_iname Metadata_pert_iname2 \\\n", "0 propoxycaine propoxycaine \n", "1 O-1918 BRD-K18316707 \n", "2 NaN NaN \n", "3 bergenin bergenin \n", "4 nafcillin nafcillin \n", "\n", " Metadata_moa Metadata_target \\\n", "0 local anesthetic NaN \n", "1 cannabinoid receptor antagonist NaN \n", "2 NaN NaN \n", "3 interleukin inhibitor IL1B, TNF \n", "4 bacterial cell wall synthesis inhibitor CYP1A2, CYP3A4, SLC22A6 \n", "\n", " Metadata_mmoles_per_liter2 Metadata_Sample_Dose pert_type \\\n", "0 6.05 BRD-K18250272-003-03-7_6.05 trt \n", "1 10.00 BRD-K18316707-001-01-9_10.0 trt \n", "2 10.00 BRD-K18438502-001-02-6_10.0 trt \n", "3 10.00 BRD-K18550767-001-02-8_10.0 trt \n", "4 4.39 BRD-K18574842-323-03-3_4.39 trt \n", "\n", " control_type SMILES \n", "0 NaN CCCOc1cc(N)ccc1C(=O)OCCN(CC)CC \n", "1 NaN COc1cc(C)cc(OC)c1[C@@H]1C=C(C)CC[C@H]1C(C)=C \n", "2 NaN COc1cc(O)cc(\\C=C\\c2ccccc2)c1 \n", "3 NaN COc1c(O)cc2C(=O)O[C@H]3[C@@H](O)[C@H](O)[C@@H]... \n", "4 NaN CCOc1ccc2ccccc2c1C(=O)N[C@H]1[C@H]2SC(C)(C)[C@... \n", "\n", "[5 rows x 911 columns]" ] }, "execution_count": 33, "metadata": {}, "output_type": "execute_result" } ], "source": [ "CP_CSV_matched_filter = CP_CSV_matched.drop(columns=['Metadata_Well', 'Metadata_Assay_Plate_Barcode', 'Metadata_Plate_Map_Name', 'Metadata_well_position',\\\n", " 'Metadata_ASSAY_WELL_ROLE', 'Metadata_broad_sample', 'Metadata_mmoles_per_liter', 'Metadata_solvent', 'Metadata_pert_id'])\n", "CP_CSV_matched_filter.head()" ] }, { "cell_type": "code", "execution_count": 34, "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_PlateMetadata_pert_mfc_idMetadata_pert_wellMetadata_pert_id_vendorMetadata_cell_idMetadata_broad_sample_typeMetadata_pert_vehicleMetadata_pert_typeCells_AreaShape_CompactnessCells_AreaShape_EulerNumber...Nuclei_Texture_SumVariance_ER_3_0Nuclei_Texture_SumVariance_Mito_5_0Nuclei_Texture_SumVariance_RNA_10_0Nuclei_Texture_Variance_AGP_5_0Nuclei_Texture_Variance_ER_5_0Nuclei_Texture_Variance_RNA_5_0Metadata_moaMetadata_mmoles_per_liter2control_typeSMILES
024277BRD-K18250272-003-03-7a01NaNU2OStrtDMSOtrt0.256710NaN...-0.156442-0.018014-0.024573-0.383890-0.199967-0.075658local anesthetic6.05NaNCCCOc1cc(N)ccc1C(=O)OCCN(CC)CC
124277BRD-K18316707-001-01-9a02NaNU2OStrtDMSOtrt0.050962NaN...-0.113721-0.089807-0.041392-0.248967-0.1261830.018563cannabinoid receptor antagonist10.00NaNCOc1cc(C)cc(OC)c1[C@@H]1C=C(C)CC[C@H]1C(C)=C
224277BRD-K18438502-001-02-6a03NaNU2OStrtDMSOtrt-0.098185NaN...-0.0079790.081155-0.0896330.043140-0.0343550.052914NaN10.00NaNCOc1cc(O)cc(\\C=C\\c2ccccc2)c1
324277BRD-K18550767-001-02-8a04NaNU2OStrtDMSOtrt0.410722NaN...-0.034251-0.0475970.103611-0.139579-0.0422410.249977interleukin inhibitor10.00NaNCOc1c(O)cc2C(=O)O[C@H]3[C@@H](O)[C@H](O)[C@@H]...
424277BRD-K18574842-323-03-3a05NaNU2OStrtDMSOtrt0.248559NaN...0.2575980.1933700.238471-0.0337970.0800180.335890bacterial cell wall synthesis inhibitor4.39NaNCCOc1ccc2ccccc2c1C(=O)N[C@H]1[C@H]2SC(C)(C)[C@...
\n", "

5 rows × 906 columns

\n", "
" ], "text/plain": [ " Metadata_Plate Metadata_pert_mfc_id Metadata_pert_well \\\n", "0 24277 BRD-K18250272-003-03-7 a01 \n", "1 24277 BRD-K18316707-001-01-9 a02 \n", "2 24277 BRD-K18438502-001-02-6 a03 \n", "3 24277 BRD-K18550767-001-02-8 a04 \n", "4 24277 BRD-K18574842-323-03-3 a05 \n", "\n", " Metadata_pert_id_vendor Metadata_cell_id Metadata_broad_sample_type \\\n", "0 NaN U2OS trt \n", "1 NaN U2OS trt \n", "2 NaN U2OS trt \n", "3 NaN U2OS trt \n", "4 NaN U2OS trt \n", "\n", " Metadata_pert_vehicle Metadata_pert_type Cells_AreaShape_Compactness \\\n", "0 DMSO trt 0.256710 \n", "1 DMSO trt 0.050962 \n", "2 DMSO trt -0.098185 \n", "3 DMSO trt 0.410722 \n", "4 DMSO trt 0.248559 \n", "\n", " Cells_AreaShape_EulerNumber ... Nuclei_Texture_SumVariance_ER_3_0 \\\n", "0 NaN ... -0.156442 \n", "1 NaN ... -0.113721 \n", "2 NaN ... -0.007979 \n", "3 NaN ... -0.034251 \n", "4 NaN ... 0.257598 \n", "\n", " Nuclei_Texture_SumVariance_Mito_5_0 Nuclei_Texture_SumVariance_RNA_10_0 \\\n", "0 -0.018014 -0.024573 \n", "1 -0.089807 -0.041392 \n", "2 0.081155 -0.089633 \n", "3 -0.047597 0.103611 \n", "4 0.193370 0.238471 \n", "\n", " Nuclei_Texture_Variance_AGP_5_0 Nuclei_Texture_Variance_ER_5_0 \\\n", "0 -0.383890 -0.199967 \n", "1 -0.248967 -0.126183 \n", "2 0.043140 -0.034355 \n", "3 -0.139579 -0.042241 \n", "4 -0.033797 0.080018 \n", "\n", " Nuclei_Texture_Variance_RNA_5_0 Metadata_moa \\\n", "0 -0.075658 local anesthetic \n", "1 0.018563 cannabinoid receptor antagonist \n", "2 0.052914 NaN \n", "3 0.249977 interleukin inhibitor \n", "4 0.335890 bacterial cell wall synthesis inhibitor \n", "\n", " Metadata_mmoles_per_liter2 control_type \\\n", "0 6.05 NaN \n", "1 10.00 NaN \n", "2 10.00 NaN \n", "3 10.00 NaN \n", "4 4.39 NaN \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 906 columns]" ] }, "execution_count": 34, "metadata": {}, "output_type": "execute_result" } ], "source": [ "CP_CSV_matched_filter = CP_CSV_matched_filter.drop(columns=['Metadata_pert_iname', 'Metadata_Sample_Dose', \\\n", " 'Metadata_pert_iname2', 'Metadata_target', 'pert_type'])\n", "CP_CSV_matched_filter.head()" ] }, { "cell_type": "code", "execution_count": 35, "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_PlateCells_AreaShape_CompactnessCells_AreaShape_EulerNumberCells_AreaShape_ExtentCells_AreaShape_FormFactorCells_AreaShape_MaxFeretDiameterCells_AreaShape_MaximumRadiusCells_AreaShape_SolidityCells_AreaShape_Zernike_0_0Cells_AreaShape_Zernike_1_1...Nuclei_Texture_SumEntropy_RNA_5_0Nuclei_Texture_SumVariance_ER_3_0Nuclei_Texture_SumVariance_Mito_5_0Nuclei_Texture_SumVariance_RNA_10_0Nuclei_Texture_Variance_AGP_5_0Nuclei_Texture_Variance_ER_5_0Nuclei_Texture_Variance_RNA_5_0Metadata_moaMetadata_mmoles_per_liter2SMILES
0242770.256710NaN-0.114990-0.2370900.6155940.5504340.072795-0.2109080.008488...0.118997-0.156442-0.018014-0.024573-0.383890-0.199967-0.075658local anesthetic6.05CCCOc1cc(N)ccc1C(=O)OCCN(CC)CC
1242770.050962NaN0.051053-0.0337330.2719530.1727140.145941-0.039057-0.070826...0.065822-0.113721-0.089807-0.041392-0.248967-0.1261830.018563cannabinoid receptor antagonist10.00COc1cc(C)cc(OC)c1[C@@H]1C=C(C)CC[C@H]1C(C)=C
224277-0.098185NaN0.0442120.1646680.0119850.1270980.0947360.0782570.119333...0.079777-0.0079790.081155-0.0896330.043140-0.0343550.052914NaN10.00COc1cc(O)cc(\\C=C\\c2ccccc2)c1
3242770.410722NaN-0.236208-0.0550840.6946480.5167850.154239-0.347572-0.172400...0.339100-0.034251-0.0475970.103611-0.139579-0.0422410.249977interleukin inhibitor10.00COc1c(O)cc2C(=O)O[C@H]3[C@@H](O)[C@H](O)[C@@H]...
4242770.248559NaN-0.0200580.0857720.6787420.6718970.214587-0.221396-0.086168...0.4156230.2575980.1933700.238471-0.0337970.0800180.335890bacterial cell wall synthesis inhibitor4.39CCOc1ccc2ccccc2c1C(=O)N[C@H]1[C@H]2SC(C)(C)[C@...
\n", "

5 rows × 898 columns

\n", "
" ], "text/plain": [ " Metadata_Plate Cells_AreaShape_Compactness Cells_AreaShape_EulerNumber \\\n", "0 24277 0.256710 NaN \n", "1 24277 0.050962 NaN \n", "2 24277 -0.098185 NaN \n", "3 24277 0.410722 NaN \n", "4 24277 0.248559 NaN \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_MaxFeretDiameter Cells_AreaShape_MaximumRadius \\\n", "0 0.615594 0.550434 \n", "1 0.271953 0.172714 \n", "2 0.011985 0.127098 \n", "3 0.694648 0.516785 \n", "4 0.678742 0.671897 \n", "\n", " Cells_AreaShape_Solidity Cells_AreaShape_Zernike_0_0 \\\n", "0 0.072795 -0.210908 \n", "1 0.145941 -0.039057 \n", "2 0.094736 0.078257 \n", "3 0.154239 -0.347572 \n", "4 0.214587 -0.221396 \n", "\n", " Cells_AreaShape_Zernike_1_1 ... Nuclei_Texture_SumEntropy_RNA_5_0 \\\n", "0 0.008488 ... 0.118997 \n", "1 -0.070826 ... 0.065822 \n", "2 0.119333 ... 0.079777 \n", "3 -0.172400 ... 0.339100 \n", "4 -0.086168 ... 0.415623 \n", "\n", " Nuclei_Texture_SumVariance_ER_3_0 Nuclei_Texture_SumVariance_Mito_5_0 \\\n", "0 -0.156442 -0.018014 \n", "1 -0.113721 -0.089807 \n", "2 -0.007979 0.081155 \n", "3 -0.034251 -0.047597 \n", "4 0.257598 0.193370 \n", "\n", " Nuclei_Texture_SumVariance_RNA_10_0 Nuclei_Texture_Variance_AGP_5_0 \\\n", "0 -0.024573 -0.383890 \n", "1 -0.041392 -0.248967 \n", "2 -0.089633 0.043140 \n", "3 0.103611 -0.139579 \n", "4 0.238471 -0.033797 \n", "\n", " Nuclei_Texture_Variance_ER_5_0 Nuclei_Texture_Variance_RNA_5_0 \\\n", "0 -0.199967 -0.075658 \n", "1 -0.126183 0.018563 \n", "2 -0.034355 0.052914 \n", "3 -0.042241 0.249977 \n", "4 0.080018 0.335890 \n", "\n", " Metadata_moa Metadata_mmoles_per_liter2 \\\n", "0 local anesthetic 6.05 \n", "1 cannabinoid receptor antagonist 10.00 \n", "2 NaN 10.00 \n", "3 interleukin inhibitor 10.00 \n", "4 bacterial cell wall synthesis inhibitor 4.39 \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 898 columns]" ] }, "execution_count": 35, "metadata": {}, "output_type": "execute_result" } ], "source": [ "CP_CSV_matched_filter = CP_CSV_matched_filter.drop(columns=['Metadata_pert_mfc_id', 'Metadata_pert_type', 'control_type', \\\n", " 'Metadata_pert_well', 'Metadata_pert_id_vendor', 'Metadata_cell_id', 'Metadata_broad_sample_type', 'Metadata_pert_vehicle'])\n", "CP_CSV_matched_filter.head()" ] }, { "cell_type": "code", "execution_count": 36, "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_CompactnessCells_AreaShape_EulerNumberCells_AreaShape_ExtentCells_AreaShape_FormFactorCells_AreaShape_MaxFeretDiameterCells_AreaShape_MaximumRadius...Nuclei_Texture_SumEntropy_DNA_5_0Nuclei_Texture_SumEntropy_ER_3_0Nuclei_Texture_SumEntropy_Mito_3_0Nuclei_Texture_SumEntropy_RNA_5_0Nuclei_Texture_SumVariance_ER_3_0Nuclei_Texture_SumVariance_Mito_5_0Nuclei_Texture_SumVariance_RNA_10_0Nuclei_Texture_Variance_AGP_5_0Nuclei_Texture_Variance_ER_5_0Nuclei_Texture_Variance_RNA_5_0
0local anesthetic6.05CCCOc1cc(N)ccc1C(=O)OCCN(CC)CC242770.256710NaN-0.114990-0.2370900.6155940.550434...0.0900210.375747-0.0104270.118997-0.156442-0.018014-0.024573-0.383890-0.199967-0.075658
1cannabinoid receptor antagonist10.00COc1cc(C)cc(OC)c1[C@@H]1C=C(C)CC[C@H]1C(C)=C242770.050962NaN0.051053-0.0337330.2719530.172714...-0.0303380.390687-0.0585600.065822-0.113721-0.089807-0.041392-0.248967-0.1261830.018563
2NaN10.00COc1cc(O)cc(\\C=C\\c2ccccc2)c124277-0.098185NaN0.0442120.1646680.0119850.127098...0.1029460.2791480.0298910.079777-0.0079790.081155-0.0896330.043140-0.0343550.052914
3interleukin inhibitor10.00COc1c(O)cc2C(=O)O[C@H]3[C@@H](O)[C@H](O)[C@@H]...242770.410722NaN-0.236208-0.0550840.6946480.516785...0.4705160.2147920.0154080.339100-0.034251-0.0475970.103611-0.139579-0.0422410.249977
4bacterial cell wall synthesis inhibitor4.39CCOc1ccc2ccccc2c1C(=O)N[C@H]1[C@H]2SC(C)(C)[C@...242770.248559NaN-0.0200580.0857720.6787420.671897...0.6717900.4241860.1188730.4156230.2575980.1933700.238471-0.0337970.0800180.335890
\n", "

5 rows × 898 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 NaN 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_Compactness Cells_AreaShape_EulerNumber \\\n", "0 0.256710 NaN \n", "1 0.050962 NaN \n", "2 -0.098185 NaN \n", "3 0.410722 NaN \n", "4 0.248559 NaN \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_MaxFeretDiameter Cells_AreaShape_MaximumRadius ... \\\n", "0 0.615594 0.550434 ... \n", "1 0.271953 0.172714 ... \n", "2 0.011985 0.127098 ... \n", "3 0.694648 0.516785 ... \n", "4 0.678742 0.671897 ... \n", "\n", " Nuclei_Texture_SumEntropy_DNA_5_0 Nuclei_Texture_SumEntropy_ER_3_0 \\\n", "0 0.090021 0.375747 \n", "1 -0.030338 0.390687 \n", "2 0.102946 0.279148 \n", "3 0.470516 0.214792 \n", "4 0.671790 0.424186 \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_3_0 Nuclei_Texture_SumVariance_Mito_5_0 \\\n", "0 -0.156442 -0.018014 \n", "1 -0.113721 -0.089807 \n", "2 -0.007979 0.081155 \n", "3 -0.034251 -0.047597 \n", "4 0.257598 0.193370 \n", "\n", " Nuclei_Texture_SumVariance_RNA_10_0 Nuclei_Texture_Variance_AGP_5_0 \\\n", "0 -0.024573 -0.383890 \n", "1 -0.041392 -0.248967 \n", "2 -0.089633 0.043140 \n", "3 0.103611 -0.139579 \n", "4 0.238471 -0.033797 \n", "\n", " Nuclei_Texture_Variance_ER_5_0 Nuclei_Texture_Variance_RNA_5_0 \n", "0 -0.199967 -0.075658 \n", "1 -0.126183 0.018563 \n", "2 -0.034355 0.052914 \n", "3 -0.042241 0.249977 \n", "4 0.080018 0.335890 \n", "\n", "[5 rows x 898 columns]" ] }, "execution_count": 36, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# 把最后3列移动到前面\n", "cols = CP_CSV_matched_filter.columns.tolist()\n", "cols = cols[-3:] + cols[:-3] # 取最后3列 + 前面所有列\n", "CP_CSV_matched_filter = CP_CSV_matched_filter[cols]\n", "CP_CSV_matched_filter.head()" ] }, { "cell_type": "code", "execution_count": 38, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "NaN count in SMILES: 26572\n", "NaN ratio in SMILES: 23.43%\n" ] } ], "source": [ "# 统计 NaN 数量\n", "nan_count = CP_CSV_matched_filter['SMILES'].isna().sum()\n", "print(f\"NaN count in SMILES: {nan_count}\")\n", "\n", "# 也可以看比例\n", "nan_ratio = nan_count / len(CP_CSV_matched_filter)\n", "print(f\"NaN ratio in SMILES: {nan_ratio:.2%}\")\n" ] }, { "cell_type": "code", "execution_count": 39, "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", "
indexSMILES
0DMSO26572
1CC(C)(C)NC[C@@H](O)COc1cccc2C(=O)CCCc1216
2CC(C)NCC(O)COc1cccc2[nH]ccc1216
3COCC(=O)O[C@]1(CCN(C)CCCc2nc3ccccc3[nH]2)CCc2c...12
4COc1c(oc2cc3oc(=O)ccc3cc12)C(C)C12
.........
20337OC[C@H]1O[C@@H](CC(=O)N2CCCCC2)C[C@@H]2[C@H]1O...1
20338OC[C@@H]1O[C@H](CC(=O)N2CCCCC2)C[C@H]2[C@@H]1O...1
20339OC[C@H]1O[C@H](CC(=O)N2CCCCC2)C[C@@H]2[C@H]1Oc...1
20340OC[C@@H]1O[C@@H](CC(=O)N2CCCCC2)C[C@H]2[C@@H]1...1
20341CS(=O)(=O)Nc1ccc2O[C@H]3[C@H](C[C@H](CC(=O)NCc...1
\n", "

20342 rows × 2 columns

\n", "
" ], "text/plain": [ " index SMILES\n", "0 DMSO 26572\n", "1 CC(C)(C)NC[C@@H](O)COc1cccc2C(=O)CCCc12 16\n", "2 CC(C)NCC(O)COc1cccc2[nH]ccc12 16\n", "3 COCC(=O)O[C@]1(CCN(C)CCCc2nc3ccccc3[nH]2)CCc2c... 12\n", "4 COc1c(oc2cc3oc(=O)ccc3cc12)C(C)C 12\n", "... ... ...\n", "20337 OC[C@H]1O[C@@H](CC(=O)N2CCCCC2)C[C@@H]2[C@H]1O... 1\n", "20338 OC[C@@H]1O[C@H](CC(=O)N2CCCCC2)C[C@H]2[C@@H]1O... 1\n", "20339 OC[C@H]1O[C@H](CC(=O)N2CCCCC2)C[C@@H]2[C@H]1Oc... 1\n", "20340 OC[C@@H]1O[C@@H](CC(=O)N2CCCCC2)C[C@H]2[C@@H]1... 1\n", "20341 CS(=O)(=O)Nc1ccc2O[C@H]3[C@H](C[C@H](CC(=O)NCc... 1\n", "\n", "[20342 rows x 2 columns]" ] }, "execution_count": 39, "metadata": {}, "output_type": "execute_result" } ], "source": [ "CP_CSV_matched_filter['SMILES'] = CP_CSV_matched_filter['SMILES'].fillna(\"DMSO\")\n", "\n", "CP_CSV_matched_filter['SMILES'].value_counts().reset_index()" ] }, { "cell_type": "code", "execution_count": 40, "metadata": {}, "outputs": [], "source": [ "CP_CSV_matched_filter.to_parquet('./CP_data.parquet', index=False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# 处理基因表达" ] }, { "cell_type": "code", "execution_count": 41, "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", "
221227_x_at212345_s_at218597_s_at217140_s_at209253_at214404_x_at219888_at201225_s_at202535_at219499_at...pert_dosedet_plateBROAD_CPD_IDCPD_NAMECPD_TYPECPD_SMILESpert_id_dosepert_sample_dosepert_typecontrol_type
0-0.118505-0.293445-0.2940880.292745-0.1458960.973580.247915-0.159028-1.2490490.357185...50.0PAC001_U2OS_6H_X1_B1_UNI4445LBRD-K07762753aminopurvalanol ABIOCC(C)[C@H](CO)Nc1nc(Nc2cc(N)cc(Cl)c2)c2ncn(C(C...BRD-K07762753_50.0BRD-K07762753-001-03-6_50.0trtNaN
10.043264-0.264945-0.0006330.0009350.177604-0.504720.2143150.1442710.106551-0.051834...12.7PAC001_U2OS_6H_X1_B1_UNI4445LBRD-K09991945GSK-3 inhibitor IIBIOIc1cccc(CSc2nnc(o2)-c2ccncc2)c1BRD-K09991945_12.7BRD-K09991945-001-02-0_12.7trtNaN
2-0.0708050.1957550.004606-0.040855-0.067346-0.19872-0.0531950.167971-0.215449-0.273714...50.0PAC001_U2OS_6H_X1_B1_UNI4445LBRD-K46678324RHO-kinase inhibitor IIBIOClc1cc(Cl)c(NC(=O)Nc2ccncc2)c(Cl)c1BRD-K46678324_50.0BRD-K46678324-001-03-7_50.0trtNaN
30.027165-0.1495450.173113-0.100695-0.309296-0.20782-0.3239850.294872-0.371449-0.099914...16.2PAC001_U2OS_6H_X1_B1_UNI4445LBRD-K67860401GSK-3beta inhibitor VIIIBIOCOc1ccc(CNC(=O)Nc2ncc(s2)[N+]([O-])=O)cc1BRD-K67860401_16.2BRD-K67860401-001-02-3_16.2trtNaN
40.3032940.254455-0.055418-0.0536350.000455-0.109080.0314250.0444820.2233510.163186...12.5PAC001_U2OS_6H_X1_B1_UNI4445LBRD-K52620403STO 609BIOOC(=O)c1ccc2c3nc4ccccc4n3c(=O)c3cccc1c23BRD-K52620403_12.5BRD-K52620403-001-01-8_12.5trtNaN
\n", "

5 rows × 988 columns

\n", "
" ], "text/plain": [ " 221227_x_at 212345_s_at 218597_s_at 217140_s_at 209253_at 214404_x_at \\\n", "0 -0.118505 -0.293445 -0.294088 0.292745 -0.145896 0.97358 \n", "1 0.043264 -0.264945 -0.000633 0.000935 0.177604 -0.50472 \n", "2 -0.070805 0.195755 0.004606 -0.040855 -0.067346 -0.19872 \n", "3 0.027165 -0.149545 0.173113 -0.100695 -0.309296 -0.20782 \n", "4 0.303294 0.254455 -0.055418 -0.053635 0.000455 -0.10908 \n", "\n", " 219888_at 201225_s_at 202535_at 219499_at ... pert_dose \\\n", "0 0.247915 -0.159028 -1.249049 0.357185 ... 50.0 \n", "1 0.214315 0.144271 0.106551 -0.051834 ... 12.7 \n", "2 -0.053195 0.167971 -0.215449 -0.273714 ... 50.0 \n", "3 -0.323985 0.294872 -0.371449 -0.099914 ... 16.2 \n", "4 0.031425 0.044482 0.223351 0.163186 ... 12.5 \n", "\n", " det_plate BROAD_CPD_ID CPD_NAME \\\n", "0 PAC001_U2OS_6H_X1_B1_UNI4445L BRD-K07762753 aminopurvalanol A \n", "1 PAC001_U2OS_6H_X1_B1_UNI4445L BRD-K09991945 GSK-3 inhibitor II \n", "2 PAC001_U2OS_6H_X1_B1_UNI4445L BRD-K46678324 RHO-kinase inhibitor II \n", "3 PAC001_U2OS_6H_X1_B1_UNI4445L BRD-K67860401 GSK-3beta inhibitor VIII \n", "4 PAC001_U2OS_6H_X1_B1_UNI4445L BRD-K52620403 STO 609 \n", "\n", " CPD_TYPE CPD_SMILES \\\n", "0 BIO CC(C)[C@H](CO)Nc1nc(Nc2cc(N)cc(Cl)c2)c2ncn(C(C... \n", "1 BIO Ic1cccc(CSc2nnc(o2)-c2ccncc2)c1 \n", "2 BIO Clc1cc(Cl)c(NC(=O)Nc2ccncc2)c(Cl)c1 \n", "3 BIO COc1ccc(CNC(=O)Nc2ncc(s2)[N+]([O-])=O)cc1 \n", "4 BIO OC(=O)c1ccc2c3nc4ccccc4n3c(=O)c3cccc1c23 \n", "\n", " pert_id_dose pert_sample_dose pert_type control_type \n", "0 BRD-K07762753_50.0 BRD-K07762753-001-03-6_50.0 trt NaN \n", "1 BRD-K09991945_12.7 BRD-K09991945-001-02-0_12.7 trt NaN \n", "2 BRD-K46678324_50.0 BRD-K46678324-001-03-7_50.0 trt NaN \n", "3 BRD-K67860401_16.2 BRD-K67860401-001-02-3_16.2 trt NaN \n", "4 BRD-K52620403_12.5 BRD-K52620403-001-01-8_12.5 trt NaN \n", "\n", "[5 rows x 988 columns]" ] }, "execution_count": 41, "metadata": {}, "output_type": "execute_result" } ], "source": [ "GE_CSV.head()" ] }, { "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", "
indexpert_type
0trt64642
1control3478
\n", "
" ], "text/plain": [ " index pert_type\n", "0 trt 64642\n", "1 control 3478" ] }, "execution_count": 42, "metadata": {}, "output_type": "execute_result" } ], "source": [ "GE_CSV['pert_type'].value_counts().reset_index()" ] }, { "cell_type": "code", "execution_count": 43, "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", "
221227_x_at212345_s_at218597_s_at217140_s_at209253_at214404_x_at219888_at201225_s_at202535_at219499_at...211071_s_at203341_at202801_at206414_s_at204978_at205379_at203897_atpert_dosedet_plateCPD_SMILES
0-0.118505-0.293445-0.2940880.292745-0.1458960.973580.247915-0.159028-1.2490490.357185...-0.97559-1.7406050.3403820.4987780.3521520.535910.5248450.0PAC001_U2OS_6H_X1_B1_UNI4445LCC(C)[C@H](CO)Nc1nc(Nc2cc(N)cc(Cl)c2)c2ncn(C(C...
10.043264-0.264945-0.0006330.0009350.177604-0.504720.2143150.1442710.106551-0.051834...0.25051-0.025625-0.024428-0.2251220.533052-0.19329-0.2543612.7PAC001_U2OS_6H_X1_B1_UNI4445LIc1cccc(CSc2nnc(o2)-c2ccncc2)c1
2-0.0708050.1957550.004606-0.040855-0.067346-0.19872-0.0531950.167971-0.215449-0.273714...0.056810.1306950.005919-0.408722-0.057177-0.256990.3100450.0PAC001_U2OS_6H_X1_B1_UNI4445LClc1cc(Cl)c(NC(=O)Nc2ccncc2)c(Cl)c1
30.027165-0.1495450.173113-0.100695-0.309296-0.20782-0.3239850.294872-0.371449-0.099914...-0.161290.365195-0.040848-0.2511220.0407320.17091-0.0514416.2PAC001_U2OS_6H_X1_B1_UNI4445LCOc1ccc(CNC(=O)Nc2ncc(s2)[N+]([O-])=O)cc1
40.3032940.254455-0.055418-0.0536350.000455-0.109080.0314250.0444820.2233510.163186...0.007840.093595-0.3034180.474878-0.022947-0.285890.0642312.5PAC001_U2OS_6H_X1_B1_UNI4445LOC(=O)c1ccc2c3nc4ccccc4n3c(=O)c3cccc1c23
\n", "

5 rows × 980 columns

\n", "
" ], "text/plain": [ " 221227_x_at 212345_s_at 218597_s_at 217140_s_at 209253_at 214404_x_at \\\n", "0 -0.118505 -0.293445 -0.294088 0.292745 -0.145896 0.97358 \n", "1 0.043264 -0.264945 -0.000633 0.000935 0.177604 -0.50472 \n", "2 -0.070805 0.195755 0.004606 -0.040855 -0.067346 -0.19872 \n", "3 0.027165 -0.149545 0.173113 -0.100695 -0.309296 -0.20782 \n", "4 0.303294 0.254455 -0.055418 -0.053635 0.000455 -0.10908 \n", "\n", " 219888_at 201225_s_at 202535_at 219499_at ... 211071_s_at 203341_at \\\n", "0 0.247915 -0.159028 -1.249049 0.357185 ... -0.97559 -1.740605 \n", "1 0.214315 0.144271 0.106551 -0.051834 ... 0.25051 -0.025625 \n", "2 -0.053195 0.167971 -0.215449 -0.273714 ... 0.05681 0.130695 \n", "3 -0.323985 0.294872 -0.371449 -0.099914 ... -0.16129 0.365195 \n", "4 0.031425 0.044482 0.223351 0.163186 ... 0.00784 0.093595 \n", "\n", " 202801_at 206414_s_at 204978_at 205379_at 203897_at pert_dose \\\n", "0 0.340382 0.498778 0.352152 0.53591 0.52484 50.0 \n", "1 -0.024428 -0.225122 0.533052 -0.19329 -0.25436 12.7 \n", "2 0.005919 -0.408722 -0.057177 -0.25699 0.31004 50.0 \n", "3 -0.040848 -0.251122 0.040732 0.17091 -0.05144 16.2 \n", "4 -0.303418 0.474878 -0.022947 -0.28589 0.06423 12.5 \n", "\n", " det_plate \\\n", "0 PAC001_U2OS_6H_X1_B1_UNI4445L \n", "1 PAC001_U2OS_6H_X1_B1_UNI4445L \n", "2 PAC001_U2OS_6H_X1_B1_UNI4445L \n", "3 PAC001_U2OS_6H_X1_B1_UNI4445L \n", "4 PAC001_U2OS_6H_X1_B1_UNI4445L \n", "\n", " CPD_SMILES \n", "0 CC(C)[C@H](CO)Nc1nc(Nc2cc(N)cc(Cl)c2)c2ncn(C(C... \n", "1 Ic1cccc(CSc2nnc(o2)-c2ccncc2)c1 \n", "2 Clc1cc(Cl)c(NC(=O)Nc2ccncc2)c(Cl)c1 \n", "3 COc1ccc(CNC(=O)Nc2ncc(s2)[N+]([O-])=O)cc1 \n", "4 OC(=O)c1ccc2c3nc4ccccc4n3c(=O)c3cccc1c23 \n", "\n", "[5 rows x 980 columns]" ] }, "execution_count": 43, "metadata": {}, "output_type": "execute_result" } ], "source": [ "GE_CSV_filter = GE_CSV.drop(columns=['CPD_TYPE', 'pert_id', 'BROAD_CPD_ID', 'CPD_NAME', 'pert_type', 'control_type', 'pert_sample_dose', 'pert_id_dose'])\n", "GE_CSV_filter.head()" ] }, { "cell_type": "code", "execution_count": 44, "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_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": 44, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# 把最后3列换成前面3列\n", "\n", "cols = GE_CSV_filter.columns.tolist()\n", "cols = cols[-3:] + cols[:-3]\n", "GE_CSV_filter = GE_CSV_filter[cols]\n", "GE_CSV_filter.head()" ] }, { "cell_type": "code", "execution_count": 45, "metadata": {}, "outputs": [], "source": [ "# save as GE_data.parquet\n", "\n", "GE_CSV_filter.to_parquet('./GE_data.parquet', index=False)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# GE_CSV_filter.to_csv('./GE_data.csv', index=False) " ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(68120, 980)" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "GE_CSV_filter.shape" ] } ], "metadata": { "kernelspec": { "display_name": "boom", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.10" } }, "nbformat": 4, "nbformat_minor": 2 }