---
title: Package development for PMDA Oncology inquiries
tags:  #r with pharma lab meetup 1  
author: [森岡裕[SASユーザー総会世話人]](https://convert.docswell.com/user/6484025)
site: [Docswell](https://www.docswell.com/)
thumbnail: https://bcdn.docswell.com/page/KE4WVK6PJ1.jpg?width=480
description: Package development for PMDA Oncology inquiries by 森岡裕[SASユーザー総会世話人]
published: April 05, 26
canonical: https://convert.docswell.com/s/6484025/KVJ1PX-2026-04-05-102130
---
# Page. 1

![Page Image](https://bcdn.docswell.com/page/KE4WVK6PJ1.jpg)

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


# Page. 2

![Page Image](https://bcdn.docswell.com/page/L71Y3XVXJG.jpg)

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


# Page. 3

![Page Image](https://bcdn.docswell.com/page/G7WGPNLKE2.jpg)

Introduction of {anaume}
Insert menu &gt; Header &amp; Footer button


# Page. 4

![Page Image](https://bcdn.docswell.com/page/4JZLK3MNE3.jpg)

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 &gt;=3
-&gt; This leads to challenges in preparation
and streamlining.
Serious AE
Insert menu &gt; Header &amp; Footer button


# Page. 5

![Page Image](https://bcdn.docswell.com/page/YE6WQXN9EV.jpg)

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


# Page. 6

![Page Image](https://bcdn.docswell.com/page/GE5MRX5DE4.jpg)

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 &gt; Header &amp; Footer button


# Page. 7

![Page Image](https://bcdn.docswell.com/page/9729DXGMJR.jpg)

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 &gt; Header &amp; Footer button


# Page. 8

![Page Image](https://bcdn.docswell.com/page/DJY428VP7M.jpg)

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


# Page. 9

![Page Image](https://bcdn.docswell.com/page/V7NY8QMME8.jpg)

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
ｊpn_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 &gt; Header &amp; Footer button


# Page. 10

![Page Image](https://bcdn.docswell.com/page/YJ9PKDNW73.jpg)

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
ｊpn_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 &gt; Header &amp; Footer button


# Page. 11

![Page Image](https://bcdn.docswell.com/page/GJ8DR3KRJD.jpg)

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
&gt; make_ae_type(&quot;aeg3&quot;, &quot;AE &gt;= Grade 3&quot;,expr(AEGRD == &quot;Y&quot;))
ae_type
id: aeg3
Label to be displayed
Condition for this ae type
label: AE &gt;= Grade 3
condition: AEGRD == &quot;Y&quot;
&gt; ae_types &lt;- list(
+
make_ae_type(&quot;any_ae&quot;,
+
make_ae_type(&quot;aeg3&quot;,
+
make_ae_type(&quot;sae&quot;,
+
make_ae_type(&quot;fatal&quot;,
+
make_ae_type(&quot;disc&quot;,
+
make_ae_type(&quot;itrr&quot;,
+
make_ae_type(&quot;redu&quot;,
+ )
&quot;Any AE&quot;,
&quot;AE &gt;= Grade 3&quot;,
&quot;Any SAE&quot;,
&quot;Fatal SAEs&quot;,
&quot;AE leads drug withdraw&quot;,
&quot;AE leads drug interrupt&quot;,
&quot;AE leads to dose reduction&quot;,
expr(TRUE)),
expr(AEGRD == &quot;Y&quot;)),
expr(AESER == &quot;Y&quot;)),
expr(AESER == &quot;Y&quot; &amp; AEFAT == &quot;Y&quot;)),
expr(AEDISCON == &quot;Y&quot;)),
expr(AEITRR == &quot;Y&quot;)),
expr(AEREDUCE == &quot;Y&quot;))
Insert menu &gt; Header &amp; Footer button


# Page. 12

![Page Image](https://bcdn.docswell.com/page/LJLMKVZ2ER.jpg)

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


# Page. 13

![Page Image](https://bcdn.docswell.com/page/47MY2GV97W.jpg)

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


# Page. 14

![Page Image](https://bcdn.docswell.com/page/P7R9MZ29E9.jpg)

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 &gt; Header &amp; Footer button


# Page. 15

![Page Image](https://bcdn.docswell.com/page/PJXQV9D37X.jpg)

Structure of R package
Insert menu &gt; Header &amp; Footer button


# Page. 16

![Page Image](https://bcdn.docswell.com/page/3JK9QPXNJD.jpg)

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


# Page. 17

![Page Image](https://bcdn.docswell.com/page/LE3WPX5ZE5.jpg)

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 &gt; Header &amp; Footer button


# Page. 18

![Page Image](https://bcdn.docswell.com/page/8EDKL2D47G.jpg)

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


# Page. 19

![Page Image](https://bcdn.docswell.com/page/V7PK21XVJ8.jpg)

Metadata
DESCRIPTION
•
パッケージ名、概要、作者、ライセンス、依存関係（Depends/Imports/Suggests など）と
いった 全体情報を宣言
Package: anaume
Title: Adverse Event Analysis Utilities for Clinical Trials
Version: 0.0.0.9000
Authors@R:
person(&quot;First&quot;, &quot;Last&quot;, , &quot;first.last@example.com&quot;, role = c(&quot;aut&quot;, &quot;cre&quot;))
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 (&gt;= 3.5)
Imports:
cli,
dplyr,
purrr,
rlang,
cards
Suggests:
testthat (&gt;= 3.0.0)
Config/testthat/edition: 3
URL: https://github.com/yourname/anaume
BugReports: https://github.com/yourname/anaume/issues
Insert menu &gt; Header &amp; Footer button


# Page. 20

![Page Image](https://bcdn.docswell.com/page/2JVVDYLRJQ.jpg)

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 &gt; Header &amp; Footer button


# Page. 21

![Page Image](https://bcdn.docswell.com/page/5EGLY9X6JL.jpg)

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


# Page. 22

![Page Image](https://bcdn.docswell.com/page/4JQYMW827P.jpg)

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


# Page. 23

![Page Image](https://bcdn.docswell.com/page/K74WVK2PE1.jpg)

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


# Page. 24

![Page Image](https://bcdn.docswell.com/page/LJ1Y3XMXEG.jpg)

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


# Page. 25

![Page Image](https://bcdn.docswell.com/page/GJWGPN3K72.jpg)

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


# Page. 26

![Page Image](https://bcdn.docswell.com/page/4EZLK3VN73.jpg)

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


# Page. 27

![Page Image](https://bcdn.docswell.com/page/Y76WQX597V.jpg)

roxygen
•
R コード中のコメントから、ドキュメント（man/*.Rd）やNAMESPACE を自動生成する仕組み。
•
コードとドキュメントを同じ場所で管理することで、保守性を高める。
#&#039; Create an `ae_type` object
#&#039;
#&#039; @param id ID value for the object.
#&#039; @param label Label for the AE type.
#&#039; @param condition Expression for
subsetting the dataset.
#&#039;
#&#039; @returns An `ae_type` object.
#&#039; @export
#&#039;
#&#039; @examples
#&#039; make_ae_type(&quot;all_ae&quot;, &quot;All AEs&quot;)
#&#039; make_ae_type(&quot;rel_ae&quot;, &quot;Related
AEs&quot;, AEREL == &quot;Y&quot;)
make_ae_type &lt;- function(id, label,
condition = NULL) {
. . .
}
Insert menu &gt; Header &amp; Footer button


# Page. 28

![Page Image](https://bcdn.docswell.com/page/G75MRXYD74.jpg)

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


# Page. 29

![Page Image](https://bcdn.docswell.com/page/9J29DXYMER.jpg)

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


# Page. 30

![Page Image](https://bcdn.docswell.com/page/DEY428GPJM.jpg)

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


# Page. 31

![Page Image](https://bcdn.docswell.com/page/VJNY8QGM78.jpg)

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(&quot;anaume&quot;)
Insert menu &gt; Header &amp; Footer button


# Page. 32

![Page Image](https://bcdn.docswell.com/page/YE9PKDWWJ3.jpg)

Test
Unit testの例
test_that(&quot;make_ae_type creates ae_type object
without condition&quot;, {
obj &lt;- make_ae_type(&quot;all_ae&quot;, &quot;All AEs&quot;)
expect_s3_class(obj, &quot;ae_type&quot;)
expect_equal(obj$id, &quot;all_ae&quot;)
expect_equal(obj$label, &quot;All AEs&quot;)
expect_true(rlang::quo_is_null(obj$condition)
)
})
意図した値が返ってくるかを確認
test_that(&quot;make_ae_type creates ae_type object
with condition&quot;, {
obj &lt;- make_ae_type(&quot;rel_ae&quot;, &quot;Related AEs&quot;,
AEREL == &quot;Y&quot;)
expect_s3_class(obj, &quot;ae_type&quot;)
expect_equal(obj$id, &quot;rel_ae&quot;)
expect_equal(obj$label, &quot;Related AEs&quot;)
expect_false(rlang::quo_is_null(obj$condition
))
})
条件を変えて動作確認
test_that(&quot;make_ae_type errors when id is not a
string&quot;, {
expect_error(make_ae_type(123, &quot;label&quot;))
expect_error(make_ae_type(c(&quot;a&quot;, &quot;b&quot;),
&quot;label&quot;))
})
意図したErrorが出ることを確認
Insert menu &gt; Header &amp; Footer button


# Page. 33

![Page Image](https://bcdn.docswell.com/page/GE8DR3NRED.jpg)

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


# Page. 34

![Page Image](https://bcdn.docswell.com/page/LELMKVP27R.jpg)

End of slides
Insert menu &gt; Header &amp; Footer button


# Page. 35

![Page Image](https://bcdn.docswell.com/page/4JMY2G49JW.jpg)

BU
Insert menu &gt; Header &amp; Footer button


# Page. 36

![Page Image](https://bcdn.docswell.com/page/PJR9MZW979.jpg)

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


