Skip to content

Commit

Permalink
Moved stuff from empkins-d03-macro-analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaabel committed Jun 6, 2024
1 parent 95a3432 commit 054620d
Show file tree
Hide file tree
Showing 5 changed files with 1,236 additions and 0 deletions.
184 changes: 184 additions & 0 deletions experiments/2022_05_macro/biomarker/Bloodspot_Processing.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "5f638161-775e-4292-977e-0985b9e7533b",
"metadata": {},
"source": [
"# Bloodspot Processing"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6d785b14-abb7-4b01-89c7-93e3f3d754f1",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import json\n",
"import re\n",
"from pathlib import Path\n",
"\n",
"import pandas as pd\n",
"import numpy as np\n",
"import pingouin as pg\n",
"\n",
"import matplotlib.pyplot as plt\n",
"import seaborn as sns\n",
"\n",
"from fau_colors import cmaps\n",
"import biopsykit as bp\n",
"from biopsykit.io import biomarker\n",
"\n",
"from empkins_io.datasets.d03.macro_ap01 import MacroBaseDataset\n",
"\n",
"%load_ext autoreload\n",
"%autoreload 2\n",
"%matplotlib widget"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8eb25a5a-3758-4273-908f-9102fc493a19",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"plt.close(\"all\")\n",
"\n",
"palette = sns.color_palette(cmaps.faculties)\n",
"sns.set_theme(context=\"notebook\", style=\"ticks\", palette=palette)\n",
"\n",
"plt.rcParams[\"figure.figsize\"] = (10, 5)\n",
"plt.rcParams[\"pdf.fonttype\"] = 42\n",
"plt.rcParams[\"mathtext.default\"] = \"regular\"\n",
"\n",
"palette"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1e7feaa7-d152-4ca4-90b8-6b4419331241",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"deploy_type = \"local\""
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d7016885-ae8c-427a-95a1-df14b934e3f5",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"config_dict = json.load(Path(\"../../../config.json\").open(encoding=\"utf-8\"))\n",
"\n",
"base_path = Path(config_dict[deploy_type][\"base_path\"])\n",
"base_path"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "693236a6-2c6a-4f8f-81ad-bce258555342",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"path_out = base_path.joinpath(\"bloodspots/processed\")\n",
"bp.utils.file_handling.mkdirs([path_out])"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9e0df28b-6445-45ee-ae14-15174f249f72",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"dataset = MacroBaseDataset(base_path)\n",
"dataset"
]
},
{
"cell_type": "markdown",
"id": "50ca0ff0-594f-4026-b216-75d89028a9bd",
"metadata": {},
"source": [
"## CRP"
]
},
{
"cell_type": "markdown",
"id": "f741ce0a-6007-49ae-bdfc-502fab7efd39",
"metadata": {},
"source": [
"### Samples"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "79705e08-5eb6-4127-8dd4-14de0c8b2c78",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"crp_data = bp.io.biomarker.load_biomarker_results(\n",
" base_path.joinpath(\"bloodspots/raw/crp_values.xlsx\"), biomarker_type=\"crp\", regex_str=r\"(VP_\\d+)-(T\\w)-(B\\w)\"\n",
")\n",
"\n",
"crp_data = crp_data.join(dataset.day_condition_map).reset_index()\n",
"crp_data = crp_data.drop(columns=\"day\").set_index([\"subject\", \"condition\", \"sample\"])\n",
"crp_data"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0a8865be-d629-4a0f-b675-5d9001dc65dc",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"crp_data.to_csv(path_out.joinpath(\"crp_samples.csv\"))"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "empkins_d03_macro_analysis",
"language": "python",
"name": "empkins_d03_macro_analysis"
},
"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.9.13"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading

0 comments on commit 054620d

Please sign in to comment.