{ "cells": [ { "cell_type": "markdown", "id": "e8c73ac7", "metadata": {}, "source": [ "# Figure 2B: inter-method correlation of delta-22 ¹H stationary shieldings\n", "\n", "Lower-triangle Pearson correlation matrix of per-site ¹H delta-22 stationary shieldings across methods\n", "(pcSseg-2 basis). The colorbar is Pearson r; the published panel mislabels it r², a typo, corrected here." ] }, { "cell_type": "code", "execution_count": null, "id": "ae047e23", "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 (\"data/delta22\", \"analysis/code\", \"analysis/code/shared\"):\n", " sys.path.insert(0, os.path.join(REPO, _p))" ] }, { "cell_type": "code", "execution_count": null, "id": "3d783476", "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "\n", "import delta22\n", "import paths\n", "import fig2b_plots" ] }, { "cell_type": "code", "execution_count": null, "id": "9f91feb0", "metadata": {}, "outputs": [], "source": [ "DELTA22_HDF5 = paths.dataset_file(\"delta22\", root=REPO)\n", "XLSX = os.path.join(REPO, \"data\", \"delta22\", \"delta22_experimental.xlsx\")\n", "\n", "def figure_path(name):\n", " os.makedirs(\"figures\", exist_ok=True)\n", " return os.path.join(\"figures\", name)" ] }, { "cell_type": "code", "execution_count": null, "id": "569d9eef", "metadata": {}, "outputs": [], "source": [ "# Gas-phase (\"stationary\") shieldings, one value per (solute, geometry, basis, site, nucleus, method).\n", "# The stationary shielding does not depend on solvent, so keep one solvent (TIP4P) to deduplicate.\n", "NUCLEUS = \"H\"\n", "BASIS = \"pcSseg2\"\n", "\n", "dft = delta22.load_query_df_dft(DELTA22_HDF5, XLSX, verbose=False)\n", "corr_df = dft[[\"solute\", \"sap_geometry_type\", \"sap_nmr_method\", \"sap_basis\",\n", " \"nucleus\", \"site\", \"solvent\", \"stationary\"]].copy()\n", "corr_df.columns = [c.replace(\"sap_\", \"\") for c in corr_df.columns]\n", "corr_df = corr_df.query('solvent == \"TIP4P\"').drop(columns=[\"solvent\"])\n", "\n", "pivot = corr_df.pivot(index=[\"solute\", \"geometry_type\", \"basis\", \"site\", \"nucleus\"],\n", " columns=\"nmr_method\", values=\"stationary\")\n", "sub = pivot.query(\"nucleus == @NUCLEUS and basis == @BASIS\")\n", "correlations = sub.corr()\n", "off_diag = correlations.where(~np.eye(len(correlations), dtype=bool))\n", "print(f\"{correlations.shape[0]} methods; worst pairwise Pearson r = {off_diag.min().min():.5f}\")" ] }, { "cell_type": "code", "execution_count": null, "id": "f866aab1", "metadata": {}, "outputs": [], "source": [ "fig2b_plots.plot_correlation_matrix(correlations, save_png=figure_path(\"fig2b_correlation_1H.png\"))" ] } ], "metadata": { "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.12.13" } }, "nbformat": 4, "nbformat_minor": 5 }