Session 0: Automated One-Click Setup — Your Clinical Lab

Why This Matters

This setup refreshes your local dev environment with automation using Bash scripts. Since you're already onboarded with VS Code, Python, and WSL on Windows, we'll focus on quick steps to build a "lab" for clinical biostatistics simulations. By the end, you'll run a script that draws a simple distribution plot—your first biostats output!

We'll use VS Code's terminal. On Windows, remember to type wsl first to switch to Linux mode (where Bash works best). File paths in Bash use / (forward slashes), not \ (backslashes).


Step 1: Open VS Code and Your Project Folder

  1. Open VS Code.
  2. Click "File" > "Open Folder..." and choose/create a folder like ukubona-clinical-lab.
  3. Open the terminal in VS Code (Ctrl+` or Terminal > New Terminal).
  4. If not already in WSL, type wsl and hit Enter to enter Linux mode.

Step 2: Create bootstrap.sh

In the terminal, type code bootstrap.sh and hit Enter. This opens a new file in VS Code.

Copy the code below, paste it into the editor, and save (Ctrl+S).

#!/usr/bin/env bash

set -e

echo "===================================="
echo "🚀 Bootstrapping Ukubona Clinical Lab"
echo "===================================="

# Check for Python
if ! command -v python &> /dev/null && ! command -v python3 &> /dev/null; then
    echo "❌ Python not found. Install Python 3 from python.org."
    exit 1
fi

if command -v python3 &> /dev/null; then
    PYTHON=python3
else
    PYTHON=python
fi

echo "✅ Using: $PYTHON"

# Create venv if missing
if [ ! -d "venv" ]; then
    $PYTHON -m venv venv
fi

# Activate venv
if [[ "$OSTYPE" == "msys"* || "$OSTYPE" == "cygwin"* ]]; then
    source venv/Scripts/activate
else
    source venv/bin/activate
fi

# Create requirements.txt
cat < requirements.txt
numpy
matplotlib
scipy
statsmodels
EOF

# Install packages
pip install --upgrade pip
pip install -r requirements.txt

# Create run.sh
cat < run.sh
#!/usr/bin/env bash

set -e

if [[ "$OSTYPE" == "msys"* || "$OSTYPE" == "cygwin"* ]]; then
    source venv/Scripts/activate
else
    source venv/bin/activate
fi

python s1.py
EOF

# No chmod yet - we'll run with bash

# Create s1.py
cat < s1.py
import numpy as np
import matplotlib.pyplot as plt
import os

os.makedirs("plots", exist_ok=True)

# Simulate simple clinical data: patient ages and blood pressure
np.random.seed(42)
ages = np.random.normal(50, 10, 100)
bp = 80 + 0.5 * ages + np.random.normal(0, 5, 100)

# Simple linear regression
slope, intercept = np.polyfit(ages, bp, 1)

fig, ax = plt.subplots()
ax.scatter(ages, bp, color="blue", label="Data Points")
ax.plot(ages, slope * ages + intercept, color="red", label="Regression Line")

ax.set_xlabel("Age")
ax.set_ylabel("Blood Pressure")
ax.set_title("Simple Regression: Age vs Blood Pressure")
ax.legend()
ax.grid(True)

plt.savefig("plots/session1_regression.png", dpi=200)
plt.close()

print("✅ Plot saved!")
EOF

echo "✅ Bootstrap complete! Your lab is ready."
echo
echo "Next: In terminal, type 'bash run.sh' to test."

Step 3: Run the Bootstrap Script

In the terminal (make sure you're in WSL—type wsl if needed), type:

bash bootstrap.sh

Watch it set up your venv, install tools, and create files.


Step 4: Test Your Setup

In the terminal, type:

bash run.sh

This runs the test and creates plots/session1_regression.png. Open it in VS Code (File > Open File... or right-click in Explorer pane) or your file explorer—it's your first clinical biostats diagram!

Reminder: Before sessions, type source venv/bin/activate (or venv\Scripts\activate if not in WSL) to activate your lab.


Your Project Folder Now

ukubona-clinical-lab/
 ├── venv/              # Your Python setup
 ├── requirements.txt   # Tools list
 ├── run.sh             # Runner script
 ├── s1.py              # Test code
 ├── bootstrap.sh       # Setup script
 └── plots/             # Your output (session1_regression.png)

Why Automation Matters in Clinical Biostatistics

Scripts automate setup, saving time for analysis—like running simulations on clinical data quickly.

Skill Why It Fits Clinical Biostatistics
Bash ScriptsAutomate data processing pipelines for large datasets.
VenvEnsures consistent environments for reproducible analyses.
NumPy/Matplotlib/ScipyFor statistical computations and visualizing distributions/regressions.
ReproducibilityShare analyses via GitHub for collaborative research.

Ukubona Principle

You're building tools to explore clinical patterns—one simple step at a time!

Stuck? Note for Zoom. Head to Session 1!