File size: 2,640 Bytes
64c992d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | {
"cells": [
{
"cell_type": "markdown",
"id": "dce84895",
"metadata": {},
"source": [
"# Table S8: Dataset Summary Statistics\n",
"\n",
"Molecule and ¹H/¹³C site counts for each training dataset (site counts from each HDF5's\n",
"`atomic_numbers`, ¹H=1/¹³C=6; MagNET-Zero combines both sigma-pepper rounds with sigma-concentrate)."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "df321bd6",
"metadata": {},
"outputs": [],
"source": [
"import os, sys\n",
"\n",
"# make the in-repo modules importable (not pip-installed)\n",
"REPO = os.path.abspath(\"../..\")\n",
"for _p in (\"analysis/code\", \"analysis/code/shared\"):\n",
" sys.path.insert(0, os.path.join(REPO, _p))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "88710ad5",
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import dataset_summary"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "84e5a441",
"metadata": {},
"outputs": [],
"source": [
"DATA_DIR = os.path.join(REPO, \"data\")\n",
"\n",
"def document_path(name):\n",
" os.makedirs(\"documents\", exist_ok=True)\n",
" return os.path.join(\"documents\", name)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6a606891",
"metadata": {},
"outputs": [],
"source": [
"table_s8 = dataset_summary.summary_table(DATA_DIR)\n",
"display(table_s8)\n",
"\n",
"# write the table to this notebook's documents/ folder\n",
"out = document_path(\"si_table_s08_summary.xlsx\")\n",
"with pd.ExcelWriter(out) as writer:\n",
" table_s8.to_excel(writer, sheet_name=\"Table S8\", index=False)\n",
"print(\"wrote\", os.path.relpath(out, REPO))"
]
},
{
"cell_type": "markdown",
"id": "3bf67791",
"metadata": {},
"source": [
"## Exact-reproduction check"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4d5f4416",
"metadata": {},
"outputs": [],
"source": [
"# every count should match the published SI Table S8 value exactly\n",
"for _, row in table_s8.iterrows():\n",
" pub = dataset_summary.PUBLISHED_S8[row[\"dataset\"]]\n",
" got = (row[\"molecules\"], row[\"n_1H_sites\"], row[\"n_13C_sites\"])\n",
" assert got == pub, f\"{row['dataset']}: {got} != published {pub}\"\n",
"print(\"all rows match the published SI Table S8 exactly\")"
]
}
],
"metadata": {
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
|