mcpbeat Sign in

Analysis Methods Agent Skill

Teaches the analyst agent how to write correct, robust Python analysis code for FHIR clinical data using pandas, matplotlib, and scipy.

4k tokens
context cost
the whole folder, loaded on every use
2
files
ships runnable scripts
0
copies elsewhere
how many repositories repackaged it
1211
stars on the repo
on the repository, not the skill itself

Install

one command, takes just this skill from the repository
npx skills add https://github.com/NVIDIA/dgx-spark-playbooks --skill analysis-methods

What comes with it

11 681 bytes besides the instruction
scripts/fhir_helpers.py

The instruction itself

11 sections, as written by the author

Analysis Code Guidelines

FHIR Helpers Library

Always import the helpers library at the top of every analysis script:

import sys
sys.path.insert(0, '/sandbox/clinical-intelligence/skills/analysis-methods/scripts')
from fhir_helpers import *

Available functions

| Function | Use for | HTTP calls |

|----------|---------|------------|

| get_patients_with_condition(snomed_code) | Find patients with a condition → list of IDs | 1-2 |

| get_latest_labs_batch(loinc_code, patient_ids) | Labs for a cohort → dict: pid → (value, unit, date) | 1-2 |

| get_all_medications_batch(patient_ids) | Meds for a cohort → dict: pid → [med names] | 1-2 |

| build_cohort_df(patient_ids, loinc, lab_name, drug_check_fn) | Full DataFrame with labs + meds | 2-3 |

| get_latest_lab(patient_id, loinc_code) | Lab for ONE patient → (value, unit, date) | 1 |

| get_medications(patient_id) | Meds for ONE patient → [names] | 1 |

| get_latest_bp(patient_id) | BP for ONE patient → (sys, dia, date) | 1-2 |

| check_drug_class(med_list, drug_names) | Check if any med matches drug list → bool | 0 |

| fhir_get(path, params) | Raw FHIR GET → parsed JSON | 1 |

| get_all_pages(path, params) | Paginated FHIR GET → all entries | 1+ |

| save_chart_to_canvas(fig, filename) | Save matplotlib figure to canvas directory | 0 |

Performance rules

  • Cohort queries (2+ patients): Use get_latest_labs_batch() and get_all_medications_batch(). These make 1-2 HTTP calls total regardless of patient count.
  • Single patient: Use get_latest_lab(), get_medications(), get_latest_bp().
  • NEVER loop over patients calling get_latest_lab() per patient. Each HTTP call through the sandbox proxy adds 1-3s. For 48 patients = 48 calls = 2+ minutes. The batch function does it in one call.

Execution Rules

  • Run scripts with python (NOT python3)
  • Write a SINGLE Python script for the entire task
  • Write the script to /tmp/<name>.py, then execute it
  • All HTTP inside the sandbox must use subprocess.run(["curl", ...]) — the requests library does NOT work

Mandatory Workflow

STEP 1 - WRITE SCRIPT (import fhir_helpers, write analysis)
STEP 2 - VALIDATE: python /sandbox/clinical-intelligence/scripts/validate_and_run.py --validate-only /tmp/<name>.py
STEP 3 - EXECUTE: python /tmp/<name>.py
STEP 4 - INTERPRET: explain results using clinical-knowledge skill

Code Structure

  • Imports (always start with fhir_helpers import)
  • Data collection (use batch functions)
  • DataFrame construction
  • Analysis (filters, aggregations)
  • Visualization -- use save_chart_to_canvas(fig, filename) (NOT plt.savefig)
  • Summary (print findings)
  • Disclaimer

Care Gap Analysis Pattern

# Example: diabetes care gap
patients = get_patients_with_condition("44054006")  # SNOMED for diabetes
df = build_cohort_df(patients, "4548-4", "HbA1c",
                     lambda meds: check_drug_class(meds, ["metformin", "insulin", "glipizide"]))

gap = df[(df['HbA1c'] > 9) & (~df['on_target_med'])]
denom = len(df[df['HbA1c'].notna()])
pct = f"{len(gap)/denom*100:.1f}%" if denom > 0 else "N/A (no HbA1c data)"
print(f"Care gap: {len(gap)}/{denom} ({pct})")

Visualization

Always use dark theme. Use save_chart_to_canvas() instead of plt.savefig() directly.

import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt

plt.style.use('dark_background')
fig, ax = plt.subplots(figsize=(10, 6))
fig.patch.set_facecolor('#1a1a1a')
ax.set_facecolor('#1a1a1a')

# Histogram with NVIDIA green
ax.hist(values, bins=15, color='#76B900', edgecolor='#1a1a1a', alpha=0.85)
ax.axvline(x=threshold, color='#ff4444', linestyle='--', linewidth=2, label=f'Threshold ({threshold})')
ax.set_title("Title", fontsize=14, fontweight='bold', color='white')
ax.legend()
ax.grid(axis='y', alpha=0.2, color='#444444')
ax.text(0.98, 0.95, f"N = {len(values)}", transform=ax.transAxes, fontsize=11, color='#888888', ha='right', va='top')

# MANDATORY: use save_chart_to_canvas (NOT plt.savefig)
save_chart_to_canvas(fig, "chart.png")
plt.close()

Guardrails

  • Never compute statistics on fewer than 5 data points
  • Always report sample size: "45.0% (27 out of 60)"
  • Flag data quality issues if >30% missing
  • Do not fabricate data — report what exists, flag what's missing
  • All charts must include N annotation

Output Format

End every script with:

print(f"\nDisclaimer: This analysis is for research and operational purposes.")
print("Clinical decisions should be made by qualified clinicians.")

Other skills for the same job

different authors, same section of the catalogue
D3 Viz
by chrisvoncsefalvay
×3

Creating interactive data visualisations using d3.js. This skill should be used when creating custom charts, graphs, network diagrams, geographic visualisations, or any complex SVG-based data visualisation that requires fine-grained control over visual elements, transitions, or interactions. Use this for bespoke visualisations beyond standard charting libraries, whether in React, Vue, Svelte, vanilla JavaScript, or any other environment.

20k tokens
Astropy
by christophacham
×3

Comprehensive Python library for astronomy and astrophysics. This skill should be used when working with astronomical data including celestial coordinates, physical units, FITS files, cosmological calculations, time systems, tables, world coordinate systems (WCS), and astronomical data analysis. Use when tasks involve coordinate transformations, unit conversions, FITS file manipulation, cosmological distance calculations, time scale conversions, or astronomical data processing.

16k tokens
Instrument Data To Allotrope
by anthropics
vendor ×2

Convert laboratory instrument output files (PDF, CSV, Excel, TXT) to Allotrope Simple Model (ASM) JSON format or flattened 2D CSV. Use this skill when scientists need to standardize instrument data for LIMS systems, data lakes, or downstream analysis. Supports auto-detection of instrument types. Outputs include full ASM JSON, flattened CSV for easy import, and exportable Python code for data engineers. Common triggers include converting instrument files, standardizing lab data, preparing data for upload to LIMS/ELN systems, or generating parser code for production pipelines.

33k tokens scripts
Qutip
by ComeOnOliver
×2

Quantum mechanics simulations and analysis using QuTiP (Quantum Toolbox in Python). Use when working with quantum systems including: (1) quantum states (kets, bras, density matrices), (2) quantum operators and gates, (3) time evolution and dynamics (Schrödinger, master equations, Monte Carlo), (4) open quantum systems with dissipation, (5) quantum measurements and entanglement, (6) visualization (Bloch sphere, Wigner functions), (7) steady states and correlation functions, or (8) advanced methods (Floquet theory, HEOM, stochastic solvers). Handles both closed and open quantum systems across various domains including quantum optics, quantum computing, and condensed matter physics.

27k tokens
Copilot Usage Metrics
by github
vendor ×1

Retrieve and display GitHub Copilot usage metrics for organizations and enterprises using the GitHub CLI and REST API.

1k tokens scripts
Mentoring Juniors
by github
vendor ×1

Socratic mentoring for junior developers and AI newcomers. Guides through questions, never answers. Triggers: "help me understand", "explain this code", "I''m stuck", "Im stuck", "I''m confused", "Im confused", "I don''t understand", "I dont understand", "can you teach me", "teach me", "mentor me", "guide me", "what does this error mean", "why doesn''t this work", "why does not this work", "I''m a beginner", "Im a beginner", "I''m learning", "Im learning", "I''m new to this", "Im new to this", "walk me through", "how does this work", "what''s wrong with my code", "what''s wrong", "can you break this down", "ELI5", "step by step", "where do I start", "what am I missing", "newbie here", "junior dev", "first time using", "how do I", "what is", "is this right", "not sure", "need help", "struggling", "show me", "help me debug", "best practice", "too complex", "overwhelmed", "lost", "debug this", "/socratic", "/hint", "/concept", "/pseudocode". Progressive clue systems, teaching techniques, and success metrics.

4k tokens
Astropy
by K-Dense-AI
×1

Core Python library for astronomy and astrophysics workflows that need Astropy APIs, including units/quantities, coordinates, FITS I/O, tables, time systems, WCS, and cosmology. Use when implementing or debugging astronomical data analysis code with Astropy.

18k tokens
Polars
by K-Dense-AI
×1

High-performance DataFrame library for Python ETL, analytics, and pandas migration. Use for expression-based data manipulation with lazy query optimization, parallel execution, streaming out-of-core processing, Arrow interoperability, and optional GPU execution.

20k tokens

How to use it

Copy the folder

Take nvidia/analysis-methods from the repository into ~/.claude/skills for personal use, or into .claude/skills inside a project.

Check the name does not clash

The agent identifies a skill by the name field in its header. Two skills with the same name cannot sit side by side — one of them will be ignored.