{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# H/Clinical/Grouped Summary\n", "\n", "The module `clinical` include basic functions for processing data generated from clinical trails.\n", "Clinical data include data collected at planning, executing, monitoring and post-study reporting.\n", "\n", "Note that although examples are take from clinical data, the same function may be applicable to nonclinical or other types of data." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 1\n", "\n", "To use an example dataset:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from mtbp3.health.clinical import summary_by_group \n", "\n", "summary = summary_by_group(df=None)\n", "print(summary.df.head(2))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If `df=None`, an example dataset is generated representing a parallel, multi-visit clinical trial that records number of meals taken and calories per meal at each visit. Subject may dropout.\n", "\n", "To count number of meals taken at each visits by each subjects grouped by low, median and high calories:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ " \n", "result = summary.count_to_cate(['study', 'treatment', 'subject', 'visit'], 'calorie', [0,500,1000,2000], stats=['count','total_count'])\n", "print(result.head(2))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To count number subjects with low, median, or high number of meals at each visits:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "summary1 = summary_by_group(df=result)\n", "print( summary1.count_to_cate(['study', 'treatment', 'visit'], 'N(all)', [0,3,5,7], stats=['count','total_count']) )\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To sum the total number of meals within subjects with low, median, or high numbers of meals:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "print( summary1.count_to_cate(['study', 'treatment', 'visit'], 'N(all)', [0,3,5,7], stats=['sum','total_sum']) )" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.10.13" } }, "nbformat": 4, "nbformat_minor": 4 }