{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# How To: Correct Edge Effects in Plate Assays\n", "\n", "Colonies on the outer rows and columns of an agar plate often grow\n", "differently due to temperature gradients and humidity effects. Use\n", "`EdgeCorrector` to statistically identify and correct these biases." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from phenotypic.data import load_meas\n", "from phenotypic.analysis import EdgeCorrector" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Load Measurement Data\n", "\n", "`EdgeCorrector` operates on measurement DataFrames, not on images\n", "directly. Start with a DataFrame containing colony measurements and\n", "grid position information." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "df = load_meas()\n", "print(f\"Shape: {df.shape}\")\n", "df.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Apply Edge Correction\n", "\n", "Specify the measurement column to correct (`on`), the grouping columns\n", "(`groupby`), and the grid dimensions." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "corrector = EdgeCorrector(\n", " on=\"Shape_Area\",\n", " groupby=[\"Metadata_Strain\"],\n", " nrows=8,\n", " ncols=12,\n", " top_n=3,\n", " pvalue=0.05,\n", ")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "corrected = corrector.analyze(df)\n", "corrected.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The corrected DataFrame contains adjusted values for edge-affected\n", "colonies. The `top_n` parameter controls how many interior colonies\n", "are used as the reference baseline." ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "name": "python", "version": "3.11.0" } }, "nbformat": 4, "nbformat_minor": 4 }