Package development for PMDA Oncology inquiries

>100 Views

April 05, 26

スライド概要

profile-image

SAS言語を中心として,解析業務担当者・プログラマなのコミュニティを活性化したいです

シェア

またはPlayer版

埋め込む »CMSなどでJSが使えない場合

ダウンロード

関連スライド

各ページのテキスト
1.

Package development for PMDA Oncology inquiries PHUSE OST Shunsuke Goto Hiro Kosako Tomoyuki Namai Hiroki Yamanobe Yuichi Nakajima

2.

本日の発表のゴール PHUSE OSTの活動の一環である{anaume} packageについて知っていただく {anaume}を例に、一般的なPackageの構成要素について理解を深める Insert menu > Header & Footer button

3.

Introduction of {anaume} Insert menu > Header & Footer button

4.

Challenges regarding to AE analysis of PMDA queries in oncology Age group • A large number of similar-format reports are required within a short period. ALL AE • No standardized format like those defined by the FDA. AE with Grade >=3 -> This leads to challenges in preparation and streamlining. Serious AE Insert menu > Header & Footer button

5.

Package to solve this challenge: {anaume} • Analysis Utility for AE Mapping & Embedding • Package to accelerate table generation for query from PMDA • Using ARD to generate table Insert menu > Header & Footer button

6.

Analysis Results Data (ARD) is structured dataset that represents the outputs of statistical analyses. CDISC-AnalysisResultsLogicalModel-Presentation-FINAL.pdf Analysis Results Datasets – Analysis Results Datasets Using Open-Source Tools from the {pharmaverse} Insert menu > Header & Footer button

7.

Strong points of using ARD Standardization Efficiency Reproductivity /Automation • Uniformity of summary table aggregation units, column names, and results between analyses • Quick tabulation and re-formatting • Enable QC easier • The same analysis logic can be easily applied to other study or subgroup. • ARD can be used in a variety of ways, such as in tables, R Shiny, figures, etc. Insert menu > Header & Footer button

8.

Working flow from data to reports using ARD ADaM ARD Reports Insert menu > Header & Footer button

9.

make_ae_type() To create event flag jpn_query_overview() To create ARD for summary information Inquiry # 1 AE1 Analysis Results (summary) For AE1 ARD Summary For AE1 jpn_query_summary_pt To create ARD for PT summary ADAE make_ae_type() To create event flag Analysis Results (PT summary) For AE1 ARD PT summary For AE1 jpn_query_overview() To create ARD for summary information Inquiry # 1 AE2 ARD Summary For AE2 Analysis Results (summary) For AE1 Insert menu > Header & Footer button

10.

Step1: Define the event make_ae_type() To create event flag jpn_query_overview() To create ARD for summary information Step3: Generate outputs from ARD Inquiry # 1 AE1 Analysis Results (summary) For AE1 ARD Summary For AE1 jpn_query_summary_pt To create ARD for PT summary ADAE make_ae_type() To create event flag Step2: Create Inquiry ARD # 1 AE2 Analysis Results (PT summary) For AE1 ARD PT summary For AE1 jpn_query_overview() To create ARD for summary information ARD Summary For AE2 Analysis Results (summary) For AE1 Insert menu > Header & Footer button

11.

Step1: Define the event make_ae_type • Define conditions for target AEs and display labels for tables • Create an object of class ae_type (essentially a list) • Pass this object as an argument to subsequent functions for flexible analysis > make_ae_type("aeg3", "AE >= Grade 3",expr(AEGRD == "Y")) ae_type id: aeg3 Label to be displayed Condition for this ae type label: AE >= Grade 3 condition: AEGRD == "Y" > ae_types <- list( + make_ae_type("any_ae", + make_ae_type("aeg3", + make_ae_type("sae", + make_ae_type("fatal", + make_ae_type("disc", + make_ae_type("itrr", + make_ae_type("redu", + ) "Any AE", "AE >= Grade 3", "Any SAE", "Fatal SAEs", "AE leads drug withdraw", "AE leads drug interrupt", "AE leads to dose reduction", expr(TRUE)), expr(AEGRD == "Y")), expr(AESER == "Y")), expr(AESER == "Y" & AEFAT == "Y")), expr(AEDISCON == "Y")), expr(AEITRR == "Y")), expr(AEREDUCE == "Y")) Insert menu > Header & Footer button

12.

Step2: Create ARD jpn_query_overview/jpn_query_summary_pt • jpn_query_overview() – Function to Generate ARD for AE Overview • jpn_query_summary_pt() – Function to Generate ARD for AE by PT Both functions internally use {cards}. Insert menu > Header & Footer button

13.

Step2: Create ARD ex) jpn_query_overview • jpn_query_overview() > jpn_query_overview( + data = adae, + denominator = adsl, + ae_types = ae_types, + by = TRT01A + ) Insert menu > Header & Footer button

14.

Step3: Create outputs from ARD • Provide template program to generate table from ARD instead of functions for flexible modification in actual queries. • Generate Output from ARD using: ✓{gt} ✓{gtsummary} ✓{tfrmt} • Next Slides Will Show Examples Using {tfrmt} Insert menu > Header & Footer button

15.

Structure of R package Insert menu > Header & Footer button

16.

Basic components of R Package • DESCRIPTION • NAMESPACE • R • README • man • Vignettes • _pkgdown.yml • tests Insert menu > Header & Footer button

17.

Basic components of R Package • DESCRIPTION • NAMESPACE • R • README • man • vignettes • _pkgdown.yml • tests Packageに必須となるMetadata Packageに含まれるR pgm Document PackageのValidation用のUnit test Insert menu > Header & Footer button

18.

Basic components of R Package • DESCRIPTION • NAMESPACE • R • README • man • vignettes • _pkgdown.yml • tests Packageに必須となるMetadata Insert menu > Header & Footer button

19.

Metadata DESCRIPTION • パッケージ名、概要、作者、ライセンス、依存関係(Depends/Imports/Suggests など)と いった 全体情報を宣言 Package: anaume Title: Adverse Event Analysis Utilities for Clinical Trials Version: 0.0.0.9000 Authors@R: person("First", "Last", , "first.last@example.com", role = c("aut", "cre")) Description: Provides utilities for summarizing adverse events in clinical trials following Japanese regulatory conventions. Includes helpers for defining AE type filters, binding datasets by AE type, and generating ARD (Analysis Results Data) objects. License: MIT + file LICENSE Encoding: UTF-8 Roxygen: list(markdown = TRUE) RoxygenNote: 7.3.2 Depends: R (>= 3.5) Imports: cli, dplyr, purrr, rlang, cards Suggests: testthat (>= 3.0.0) Config/testthat/edition: 3 URL: https://github.com/yourname/anaume BugReports: https://github.com/yourname/anaume/issues Insert menu > Header & Footer button

20.

Metadata NAMESPACE • どの関数・クラス等をPackageから参照できるようにするかを決める • 他パッケージの関数等を自パッケージからどう参照するかを決める(imports) • 通常Manualでは編集しない S3method(format,ae_type) S3method(print,ae_type) export(ae_condition) export(ae_id) export(ae_label) export(jpn_query_aggregate) export(jpn_query_base) export(jpn_query_overview) export(make_ae_type) export(merge_ae_types) importFrom(cards,ard_stack_hierarchical) importFrom(dplyr,all_of) importFrom(dplyr,filter) importFrom(dplyr,group_vars) importFrom(dplyr,mutate) importFrom(dplyr,select) importFrom(purrr,map_dfr) importFrom(rlang,enquo) importFrom(rlang,eval_tidy) importFrom(rlang,quo_is_null) importFrom(tidyselect,eval_select) Insert menu > Header & Footer button

21.

Basic components of R Package • DESCRIPTION • NAMESPACE • R • README • man • vignettes • _pkgdown.yml • tests Packageに含まれるR pgm Insert menu > Header & Footer button

22.

Programs R pgm • 関数などの R コードを格納する。 • .R ファイルは、パッケージ読み込み時に自動的にソースされる。 • 外部に公開されるかどうかは NAMESPACE によって制御される。 Insert menu > Header & Footer button

23.

Basic components of R Package • DESCRIPTION • NAMESPACE • R • README • man • vignettes • _pkgdown.yml • tests Document Insert menu > Header & Footer button

24.

Document Readme • GithubやGithub pagesのTop pageに表示される内容 Insert menu > Header & Footer button

25.

Github pagesとは?? • GitHub のリポジトリ内容から、Webサイト(HTML/CSS/JS)を公開できる機能 • Packageの使い方などの情報を掲載するために使用されることが多い Insert menu > Header & Footer button

26.

Document man • 各関数のDocumentを格納したFolder • 各関数のDocumentはGithub pagesやRstudioの Help画面に表示される。 • Manualでは編集しないことが多く、roxygenに よって記載した内容がDocumentとなる Insert menu > Header & Footer button

27.
[beta]
roxygen
•

R コード中のコメントから、ドキュメント(man/*.Rd)やNAMESPACE を自動生成する仕組み。

•

コードとドキュメントを同じ場所で管理することで、保守性を高める。

#' Create an `ae_type` object
#'
#' @param id ID value for the object.
#' @param label Label for the AE type.
#' @param condition Expression for
subsetting the dataset.
#'
#' @returns An `ae_type` object.
#' @export
#'
#' @examples
#' make_ae_type("all_ae", "All AEs")
#' make_ae_type("rel_ae", "Related
AEs", AEREL == "Y")
make_ae_type <- function(id, label,
condition = NULL) {
. . .
}
Insert menu > Header & Footer button

28.

Document vignettes • 関数横断的な内容としてDocumentを格納したFolder • Github pages上で、関数横断的な内容をArticlesに相当することが多い。 Insert menu > Header & Footer button

29.

Document _pkgdown.yml • Github pages生成時の設定ファイル • サイトの見た目・構成・表示内容をYAML形式で制御する。 url: https://yuichinakaima.github.io/anaume/ template: bootstrap: 5 lang: en title: anaume description: "{Package documentation for anaume}." repo: url: home: https://github.com/yuichinakaima/anaume issue: https://github.com/yuichinakaima/anaume/issues どの項目に何のDocumentを 配置するか等を設定 Insert menu > Header & Footer button

30.

Basic components of R Package • DESCRIPTION • NAMESPACE • R • README • man • vignettes • _pkgdown.yml • tests PackageのValidation用のUnit test Insert menu > Header & Footer button

31.

Test Unit test • Packageでは関数やFeatureが意図通り機能しているかをDevloperがテストしている。 • 個別のTESTはtestthat folder内に保管されることが多く、testthat内の全てのtestを testthat.Rで実行する構造を持つことが多い。 • R CMD check 時に自動実行されるため、関数修正時に意図しない挙動の変化を防ぐ。 # This file is part of the standard setup for testthat. # It is recommended that you do not modify it. # # Where should you do additional test configuration? # Learn more about the roles of various files in: # * https://r-pkgs.org/testing-design.html#sec-tests-filesoverview # * https://testthat.r-lib.org/articles/special-files.html library(testthat) library(anaume) test_check("anaume") Insert menu > Header & Footer button

32.
[beta]
Test

Unit testの例
test_that("make_ae_type creates ae_type object
without condition", {
obj <- make_ae_type("all_ae", "All AEs")
expect_s3_class(obj, "ae_type")
expect_equal(obj$id, "all_ae")
expect_equal(obj$label, "All AEs")
expect_true(rlang::quo_is_null(obj$condition)
)
})

意図した値が返ってくるかを確認

test_that("make_ae_type creates ae_type object
with condition", {
obj <- make_ae_type("rel_ae", "Related AEs",
AEREL == "Y")
expect_s3_class(obj, "ae_type")
expect_equal(obj$id, "rel_ae")
expect_equal(obj$label, "Related AEs")
expect_false(rlang::quo_is_null(obj$condition
))
})

条件を変えて動作確認

test_that("make_ae_type errors when id is not a
string", {
expect_error(make_ae_type(123, "label"))
expect_error(make_ae_type(c("a", "b"),
"label"))
})

意図したErrorが出ることを確認

Insert menu > Header & Footer button

33.

本日の発表のゴール(再掲) PHUSE OSTの活動の一環である{anaume} packageについて知っていただく {anaume}を例に、一般的なPackageの構成要素について理解を深める Insert menu > Header & Footer button

34.

End of slides Insert menu > Header & Footer button

35.

BU Insert menu > Header & Footer button

36.

{cards} package • Part of Pharmaverse • R package to create ARD ard_categorical( data = adae, by = c('AGEGR1','TRT01A’), variables = AEDECOD, denominator = adsl ) Insert menu > Header & Footer button