Communitygithub.com

pkpd-modeling

药代动力学和药效学建模与模拟——非房室分析、房室模型与群体PK、PK/PD与暴露-效应、TMDD、PBPK导向、生物等效性、异速放大与首次人体剂量、药物相互作用预测及贝叶斯治疗药物监测。用于分析浓度-时间数据、推导暴露指标、拟合PK或PD模型、评估给药方案。触发条件包括

pkpd-modeling 是什么?

该技能为AI智能体提供了一套完整的药代动力学(PK)和药效学(PD)建模与模拟脚本库,涵盖从非房室分析(NCA)、房室模型拟合、群体PK数据集检查到生物等效性分析、异速缩放与首次人体剂量计算、药物相互作用预测以及贝叶斯治疗药物监测(TDM)等核心工作流。它特别强调“三个规则”:先固定暴露指标和分析人群、区分结构/变异/协变量模型、识别收敛性与可辨识性之间的区别。技能中的所有脚本均以Python编写,支持`table|tsv|json`格式输出,并通过退出码(0/1/2)区分正常、有发现和输入错误。该技能适用于Claude Code等代码驱动型智能体,主要面向从事临床前或临床PK/PD分析的定量药理学家和临床药理学家。需要注意的是,该技能明确声明它仅提供计算和诊断辅助,不能替代合格的专业人员的监管决策或临床判断。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/K-Dense-AI/scientific-agent-skills/tree/main/skills/pkpd-modeling

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

药代动力学与药效学建模

何时使用

任何关于身体对药物作用或药物对身体作用的问题:从浓度-时间数据推导暴露指标、拟合结构模型、构建或检查群体分析、选择剂量或给药方案、关联暴露与效应、比较制剂,或向新群体进行缩放。

三条规则

1. 在计算之前先固定暴露指标和分析人群。 AUC(0-t)、AUC(0-inf)、稳态AUC(0-tau)和Cavg是不同的量,回答不同的问题。基于观测值还是预测值计算AUCinf也是如此。在看到数值后才做选择,是阴性研究变为阳性的原因。

2. 结构模型、变异模型和协变量模型是三个独立的决策。 它们经常被混淆——增加一个房室来吸收实际上是未建模的个体间变异,添加一个协变量来修复实际上是错误指定的吸收模型。在改变其中任何一个之前,先诊断哪个是错误的。

3. 收敛不等于可辨识性。 一个参数RSE高达200%或两个参数相关性为0.99的拟合仍然收敛,这表明数据无法区分它们。这里的每个拟合脚本都会报告并标记这两者,因为单看参数表在这种情况下一切正常。

范围

此技能负责计算、诊断和结构化。它不决定制剂是否生物等效、不选择试验剂量、不为患者推荐剂量、不断定药物无QT风险、也不替代合格的数量药理学家、临床药理学家或监管审评。脚本负责报告;它们不下结论。尤其是tdm_bayes.py只是一个建模辅助工具——对患者方案的任何更改均由治疗临床医生决定。

脚本

cd skills/pkpd-modeling/scripts
脚本解决的问题
nca.py暴露指标是什么,末端相是否足够好以报告它们?
fit_compartmental.py这些数据支持哪种结构模型,其参数是否可辨识?
simulate_regimen.py此方案在稳态下如何表现,对多大比例的人群有效?
check_popk_dataset.pyNONMEM会像我预期的那样读取这个数据集吗?
exposure_response.py是否存在暴露-效应关系,数据中是否达到平台期?
bioequivalence.py90% CI是否满足标准,以及适用哪个标准?
allometry_and_fih.py起始剂量是多少,或者在更小/更年轻人群中的剂量是多少?
ddi_static.py体外数据是否触发ICH M12下的临床DDI研究?
tdm_bayes.py根据测量水平,这位患者的个体参数是多少?

所有脚本均接受 --format table|tsv|json。数据输出到stdout,溯源和发现输出到stderr,因此> out.tsv可以保持它们分离。退出码为0表示无发现,1表示发现被提出,2表示输入错误,因此任意脚本都可以用于门控工作流。

两个私有模块包含共享机械部分:_models.py(线性房室模型的解析解,以及集成的米氏动力学、TMDD和间接响应结构)和_common.py(I/O和报告)。请导入它们,而不是重新推导Bateman函数。

工作流

1. 非房室分析

python3 nca.py -i profile.csv --dose 100 --route extravascular --partial-auc 0-24

四个选择决定了答案,通常被隐式处理。此脚本使所有四个选择明确:--auc-method(默认为linup-logdown)、--blq-rule、--lambda-z-points或显式的--lambda-z-window,以及您报告的是auc_inf_obs还是auc_inf_pred。

Lambda_z选择使用标准规则:从最后三个可定量点开始,向后延伸,仅当调整后r平方改善超过0.0001时才保留更长的窗口。简单r平方只会随着点的增加而上升,因此它总是会选择最长的窗口。Tmax或Tmax之前的点永远不符合条件——包括Tmax会拟合吸收尾部,从而偏倚半衰期、Vz和AUCinf。

在一个无噪声的模拟一室口服曲线(CL/F = 5,V/F = 20,ka = 1.2)上:

id  cmax     tmax  auc_last  lambda_z  t_half   r2_adj  auc_inf_obs  pct_auc_extrap  cl_f     vz_f
1   3.29678  1.5   19.8737   0.25      2.77259  1       19.8739      0.000781037     5.03173  20.1269

CL/F高估0.6%是在稀疏采样吸收相上梯形规则的结果,不是错误——这是在该采样方案上NCA不可避免的偏倚,也是为什么NCA和房室模型的清除率估计值永远不会完全一致。

发现是关键。一个在tau处截断的稳态曲线产生:

finding: subject A: 25.2% of AUCinf is extrapolated (above 20%); AUCinf is driven by the
         lambda_z fit, not by data
finding: subject A: lambda_z window spans 0.58 half-lives (below 2.0); the terminal phase may
         not have been reached

两者都是正确的,并且通常被忽略。在稳态下,可报告的暴露指标是AUC(0-tau),而不是AUCinf;脚本仍计算AUCinf并告诉您不要相信它。

2. 房室模型拟合与模型选择

python3 fit_compartmental.py -i profile.csv --dose 500 --route iv-bolus --compare 1cmt,2cmt,3cmt

参数在对数尺度上估计,因此它们不能变为负值,并且它们的置信区间不对称。加权默认为1/y2(恒定CV),这是PK的正确默认值,但对于同方差PD终点则是错误的。

拟合模拟的二室数据(CL 4,V1 12,Q 6,V2 40,8%比例误差):

model  parameters  wssr       aic       bic       f_vs_simpler  f_p_value    compared_with
1cmt   2           3.13201    -19.4956  -18.0795  n/a           n/a          n/a
2cmt   4           0.0309579  -84.7477  -81.9155  550.936       9.38016e-12  1cmt
3cmt   6           0.0232859  -85.0193  -80.771   1.4826        0.27762      2cmt

AIC选择三室模型。BIC和F检验都拒绝它。 AIC每个参数固定惩罚为2,在此样本量下较弱,并且它选择过参数化模型的频率超出从业者的预期。参数表解决了问题:

finding: fit: Q3 has 98% RSE - not estimable from these data at this model size
finding: fit: V3 has 71% RSE - not estimable from these data at this model size

同时,一室模型拟合并未获得以下发现:

finding: fit: residual signs are not random (runs test p = 0.0036) - a structural
         misspecification, which no amount of reweighting will fix

这个区别——结构性错误指定与错误的误差模型——是需要正确的。残差对时间图中相同符号的序列意味着模型形状是错误的。随机符号的异方差残差意味着权重是错误的。对前一种情况进行重新加权会掩盖它而不解决问题。

3. 群体PK

在运行任何操作之前检查数据集。这是实际花费时间的地方。

python3 check_popk_dataset.py -i nmdata.csv --covariates WT,CRCL --time-varying WT

重要的缺陷是那些静默的缺陷。NM-TRAN不会拒绝非数字DV——它将BLQ读取为零,并将其拟合为真正的零浓度。空白协变量变为0,因此缺失的体重变为0 kg的患者。没有II的ADDL不放置任何额外剂量。共享时间戳的记录按文件顺序应用,因此某个水平是给药前还是给药后取决于哪一行在前面。这些都不会阻止运行。

severity  check                            detail
error     non-numeric DV                   DV contains text... NM-TRAN reads them as 0
error     subject with no dose             1 subject(s) have observations but no dose: 2
error     TIME not sorted                  1 subject(s) have out-of-order TIME: 1
error     covariate WT missing             1 record(s) have no value...
warning   duplicate TIME within a subject  NONMEM applies them in file order...

对于估计本身,此技能不重新实现NLME——请参阅references/population-pk.md了解估计方法、BLQ M1-M7方法、协变量模型构建以及决定模型是否可接受的诊断方法,并参阅references/software-ecosystem.md了解使用哪种工具。

4. 模拟与方案选择

python3 simulate_regimen.py --cl 5 --v 40 --dose 500 --interval 12 --n-doses 10 --steady-state
python3 simulate_regimen.py --cl 5 --v 40 --dose 500 --interval 12 --n-doses 10 \
    --simulate 2000 --omega-cl 0.35 --omega-v 0.25 --target-trough 4.0

确定性模拟回答“典型患者看起来像什么”,但这几乎从来不是问题所在:

metric             p5        p25      median   p75      p95      geo_mean
peak               11.861    14.6018  16.6702  19.1476  22.9339  16.6453
trough             0.863226  2.15191  3.64412  5.49655  9.21053  3.27035

target       fraction_attaining
trough >= 4  0.444

典型谷浓度是3.6,目标是4,因此44%的人群达到了目标。根据典型患者调整的方案让大约一半的人群处于目标的错误一侧。这里的达标率报告仍然是乐观的:这仅是个体间变异,没有残差或个体内变异成分。

线性模型通过解析求解并叠加,这是精确的。--nonlinear切换到集成的米氏消除,其中叠加无效,并且不能从单次剂量推断多剂量行为。

5. 暴露-效应

python3 exposure_response.py --emax -i er.csv --sigmoid
python3 exposure_response.py --cqtc -i qt.csv --cmax 250

Emax拟合报告fraction_of_emax_reached并标记其平台期在数据之外的拟合。当最高观测暴露仅达到估计Emax的三分之一时,Emax和EC50是相互强相关的推断值;将它们引用为独立估计是不可支持的,而“线性”暴露-效应仅仅是同一条曲线的低浓度部分。

--cqtc评估预测的安慰剂校正、相对于基线的QTc变化的双侧90%置信区间的上界与10 ms阈值的比较,这正是ICH E14实际提出的问题。点估计或95%区间回答的是不同的问题。打包的模型是一个用于筛选的普通线性回归;提交级C-QTc分析需要一个具有随机截距和每个受试者斜率的混合模型。

每种模式都带有相同的告诫,因为这是最容易忘记的:患者被随机分配到剂量,而不是暴露。即使在随机试验内,跨分位数的暴露-效应也是观察性的,并且可能反映驱动清除率的协变量。

6. 生物等效性

python3 bioequivalence.py -i be.csv --design 2x2 --metric AUC
python3 bioequivalence.py -i be.csv --design replicate --metric Cmax --scaling both
python3 bioequivalence.py --power --cv 0.30 --gmr 0.95 --target-power 0.80

三个标准共享“生物等效性”一词,并且不可互换:平均BE(90% CI在80.00-125.00%内)、EMA的ABEL(限值作为CVwR的函数放宽,上限为69.84-143.19%,点估计仍需要在80-125%内)和FDA的RSABE(通过Hyslop方法计算的缩放线性化边界,根本不是一个区间)。--scaling拒绝在2x2设计上运行:

error: reference-scaling requires --design replicate. High observed variability in a 2x2 study
does not license widening: without replicated reference administrations there is no estimate of
within-subject reference variability to scale to.

样本量精确复现已发表表格(CV 30%,GMR 0.95,80%功效 → 2x2设计需要N = 40)。功效通过积分估计标准差采样分布来计算,而不是将标准误视为已知——正态近似在现实样本量下高估功效。注意,N更多地取决于假定的GMR而不是CV;假设1.00而不是0.95会使计算出的N大约减半,并且这是BE研究动力不足的常见原因。

7. 缩放、儿科与首次人体

python3 allometry_and_fih.py --scale --cl 5 --weight-from 70 --weight-to 6 --pma-weeks 44
python3 allometry_and_fih.py --fih --noael rat=50,dog=10 --safety-factor 10

仅通过大小缩放,在约2岁以下的幼儿中会高估清除率,在新生儿中会高出数倍,因为清除率受酶和肾脏成熟度限制,而不是受大小限制。提供--pma-weeks会添加Anderson-Holford S形成熟项;在20 kg以下省略它会产生一个发现。

parameter  reference  exponent  size_scaled  maturation_factor  final
CL         5          0.75      0.792063     0.30634            0.242641
V          40         1         3.42857      1                  3.42857

仅大小会预测0.79 L/h;在44周胎龄时考虑成熟度则为0.24 L/h,相差3.3倍。体积不受成熟度影响——成熟度描述的是消除能力,而不是分布空间。

--fih使用FDA 2005年最大安全起始剂量指南中的体表面积换算,并且始终发出一个发现,即基于NOAEL的MRSD本身对于激动剂免疫调节剂是不够的:使用--mabel计算MABEL并取较低的值。

8. 药物相互作用

python3 ddi_static.py --basic --ki 0.5 --imax 2.0 --fu 0.05 --dose 0.4
python3 ddi_static.py --msm --ki 0.5 --imax 2.0 --fu 0.05 --dose 0.4 --fm 0.9 --fg 0.7

ICH M12基础模型及其界限(R1 ≥ 1.02肝脏,≥ 11肠道

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

adaptyv

How to use the Adaptyv Bio Foundry API and Python SDK for protein experiment design, submission, and results retrieval. Use this skill whenever the user mentions Adaptyv, Foundry API, protein binding assays, protein screening experiments, BLI/SPR assays, thermostability assays, or wants to submit protein sequences for experimental characterization. Also trigger when code imports `adaptyv`, `adaptyv_sdk`, or `FoundryClient`, or references `foundry-api-public.adaptyvbio.com`.

aeon

This skill should be used for time series machine learning tasks including classification, regression, clustering, forecasting, anomaly detection, segmentation, and similarity search. Use when working with temporal data, sequential patterns, or time-indexed observations requiring specialized algorithms beyond standard ML approaches. Particularly suited for univariate and multivariate time series analysis with scikit-learn compatible APIs.

alphagenome

Look up precomputed AlphaGenome Atlas effects for any GRCh38 single-nucleotide variant (AVI score with Phred and 18 SHAP feature attributions, plus raw and quantile scores for RNA-seq, DNase, ATAC, ChIP-TF, ChIP-histone, CAGE, PRO-cap, splicing, polyadenylation and contact-map tracks), score variants or scan windows on demand with the AlphaGenome model for human and mouse (variant scoring, in silico mutagenesis, REF-versus-ALT track prediction), and build Atlas website deep links. Use when the user mentions AlphaGenome, AlphaGenome Atlas, AVI or AlphaGenome Variant Impact, DeepMind variant effect prediction, or wants to prioritise or mechanistically interpret non-coding, regulatory, splicing, enhancer, promoter, or chromatin-accessibility effects of SNVs from a VCF, credible set, or region. Research use only; not a clinical tool.

analytical-method-validation

Plan, execute, and document validation, verification, and transfer of analytical procedures under the governing framework - ICH Q2(R2) and Q14, USP <1220>/<1225>/<1226>, ICH M10 bioanalytical, CLSI EP, or ISO/IEC 17025. Use for HPLC, LC-MS/MS, GC, CE, ICP-MS, dissolution, qNMR, qPCR, NIR, and ligand binding or cell-based assays whenever the question is whether a procedure is fit for its intended purpose. Triggers include

anndata

Data structure for annotated matrices in single-cell analysis. Use when working with .h5ad files or integrating with the scverse ecosystem. This is the data format skill—for analysis workflows use scanpy; for probabilistic models use scvi-tools; for population-scale queries use cellxgene-census.

arbor

Autonomously improve a real artifact (code, training recipe, agent harness, data pipeline, prompt) against an objective and an evaluator, using Hypothesis Tree Refinement (HTR) from the Arbor paper. Use this whenever someone wants to iteratively optimize something over many experiments without overfitting — e.g.

arboreto

Infer gene regulatory networks (GRNs) from gene expression data using scalable algorithms (GRNBoost2, GENIE3). Use when analyzing transcriptomics data (bulk RNA-seq, single-cell RNA-seq) to identify transcription factor-target gene relationships and regulatory interactions. Supports distributed computation for large-scale datasets.

astropy

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.

autoskill

Observe the user

benchling-integration

Benchling Python SDK and REST API integration for registry entities, inventory, ELN entries, workflows, Benchling Apps, and Data Warehouse queries. Use when automating lab data with benchling-sdk or the v2 API.

bgpt-paper-search

Search scientific papers and retrieve structured experimental data extracted from full-text studies via the BGPT MCP server. Returns 25+ fields per paper including methods, results, sample sizes, quality scores, and conclusions. Use for literature reviews, evidence synthesis, and finding experimental details not available in abstracts alone.

bids

>

biopython

Comprehensive molecular biology toolkit. Use for sequence manipulation, file parsing (FASTA/GenBank/PDB), phylogenetics, and programmatic NCBI/PubMed access (Bio.Entrez). Best for batch processing, custom bioinformatics pipelines, BLAST automation. For quick lookups use gget; for multi-service integration use bioservices.

bioservices

Unified Python interface to 40+ bioinformatics services. Use when querying multiple databases (UniProt, KEGG, ChEMBL, Reactome) in a single workflow with consistent API. Best for cross-database analysis, ID mapping across services. For quick single-database lookups use gget; for sequence/file manipulation use biopython.

bulk-rnaseq

End-to-end bulk RNA-seq orchestrator — takes raw FASTQ reads through QC and trimming (FastQC, fastp/Trim Galore), alignment and quantification (STAR, Salmon, featureCounts), assembles a gene-level counts matrix, then hands off to differential expression (pydeseq2), pathway/GSEA enrichment (pathway-enrichment), and publication figures (scientific-visualization). Use whenever the user has bulk RNA-seq reads or quant output and wants a complete, reproducible differential-expression workflow — e.g.

cellxgene-census

Query the CZ CELLxGENE Census programmatically for versioned public single-cell and spatial transcriptomics data. Use when you need population-scale cell metadata, gene expression slices, Census summary counts, source H5AD URIs/downloads, embeddings, spatial Census data, or reference atlas comparisons across organisms, tissues, diseases, assays, and cell types. For analyzing your own local single-cell data use scanpy, anndata, or scvi-tools.

cirq

Google quantum computing framework. Use when targeting Google Quantum AI hardware, designing noise-aware circuits, or running quantum characterization experiments. Best for Google hardware, noise modeling, and low-level circuit design. For IBM hardware use qiskit; for quantum ML with autodiff use pennylane; for physics simulations use qutip.

citation-management

Comprehensive citation management for academic research. Search OpenAlex, PubMed, and Google Scholar for papers, extract accurate metadata, validate citations, and generate properly formatted BibTeX entries. This skill should be used when you need to find papers, verify citation information, convert DOIs to BibTeX, or ensure reference accuracy in scientific writing.

clinical-decision-support

Prepare and validate research-only clinical decision-support evaluation, evidence-profile, cohort, survival, biomarker/model, privacy, and governance artifacts. Use for aggregate or synthetic research documentation and traceability—not patient care or live clinical operation.

clinical-reports

Create safety-bounded draft structures and run local deterministic checks for clinical case, diagnostic, trial, safety, and aggregate research reports. Use only with synthetic, de-identified, or aggregate inputs and verified source-fact manifests; every output requires qualified review.

相关技能