Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
^_pkgdown\.yml$
^docs$
^pkgdown$
^CRAN-SUBMISSION$
3 changes: 3 additions & 0 deletions CRAN-SUBMISSION
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Version: 0.0.1
Date: 2025-03-25 16:28:12 UTC
SHA: 5604d351f4f9ba9555d221c81eb5c49da1654358
13 changes: 7 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
Package: meddra.read
Title: Load and Merge MedDRA Data for Clinical Trials
Version: 0.0.0.9000
Title: Load and Use 'MedDRA' Data for Clinical Trials
Version: 0.0.1
Authors@R:
person("Bill", "Denney", email="wdenney@humanpredictions.com", role=c("aut", "cre"), comment=c(ORCID="0000-0002-5759-428X"))
Description:
MedDRA data is used for defining adverse events in clinical studies. You
'MedDRA' data is used for defining adverse events in clinical studies. You
can load and merge the data for use in categorizing the adverse events
using this package.
using this package. The package requires the data licensed from 'MedDRA'
<https://www.meddra.org/>.
License: MIT + file LICENSE
Imports:
dplyr
Suggests:
spelling,
testthat (>= 3.0.0)
Config/testthat/edition: 3
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.2
Imports:
dplyr
URL: https://humanpred.github.io/meddra.read/
Language: en-US
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# meddra.read 0.0.1

* Initial CRAN submission.
21 changes: 12 additions & 9 deletions R/join_meddra.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@
#' @return A data.frame with the "soc_code", "soc_name", "soc_abbrev",
#' "hlgt_code", "hlgt_name", "hlt_code", "hlt_name", "pt_code", "pt_name",
#' "pt_soc_code", "llt_code", "llt_name", and "llt_currency"
#' @examples
#' \dontrun{
#' meddra_raw <- read_meddra("/path/to/meddra/distribution")
#' meddra_df <- join_meddra(meddra_raw)
#' }
#' @export
join_meddra <- function(data) {
ret <-
data$soc.asc |>
dplyr::left_join(data$soc_hlgt.asc, by = "soc_code") |>
dplyr::left_join(data$hlgt.asc, by = "hlgt_code") |>
dplyr::left_join(data$hlgt_hlt.asc, by = "hlgt_code") |>
dplyr::left_join(data$hlt.asc, by = "hlt_code") |>
dplyr::left_join(data$hlt_pt.asc, by = "hlt_code") |>
dplyr::left_join(data$pt.asc, by = "pt_code") |>
dplyr::left_join(data$llt.asc, by = "pt_code")
ret <- dplyr::left_join(data$soc.asc, data$soc_hlgt.asc, by = "soc_code")
ret <- dplyr::left_join(ret, data$hlgt.asc, by = "hlgt_code")
ret <- dplyr::left_join(ret, data$hlgt_hlt.asc, by = "hlgt_code")
ret <- dplyr::left_join(ret, data$hlt.asc, by = "hlt_code")
ret <- dplyr::left_join(ret, data$hlt_pt.asc, by = "hlt_code")
ret <- dplyr::left_join(ret, data$pt.asc, by = "pt_code")
ret <- dplyr::left_join(ret, data$llt.asc, by = "pt_code")
ret
}
8 changes: 6 additions & 2 deletions R/read_meddra.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
#' @param directory the directory containing the MedAscii and SeqAscii
#' directories
#' @return A list of data.frames for each file in the MedDRA source distribution
#' @examples
#' \dontrun{
#' read_meddra("/path/to/meddra/distribution")
#' }
#' @export
read_meddra <- function(directory) {
dirs_available <- list.dirs(path = directory, full.names = FALSE)
Expand All @@ -21,7 +25,7 @@ read_meddra <- function(directory) {
read_meddra_dir <- function(directory, extension) {
files <- list.files(directory, full.names = TRUE, pattern = sprintf("\\.%s$", extension))
stopifnot(length(files) > 0)
files <- setNames(files, tolower(basename(files)))[order(tolower(basename(files)))]
files <- stats::setNames(files, tolower(basename(files)))[order(tolower(basename(files)))]
lapply(X = files, FUN = read_meddra_file)
}

Expand Down Expand Up @@ -121,7 +125,7 @@ read_meddra_file <- function(filename) {
))
} else {
ret <-
read.delim(
utils::read.delim(
# Some files (at least meddra_release.asc in version 28.0) are missing
# newlines at the end, this suppresses a warning about that.
text = file_text,
Expand Down
14 changes: 14 additions & 0 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## R CMD check results

0 errors | 0 warnings | 1 note

* From initial review: "Ideally, add small executable examples in your Rd-files
to illustrate the use of the exported function but also enable automatic
testing."
* Due to 'MedDRA' licensing restrictions, I cannot include any actual data
in the package or read it from a remote source. I have added "dontrun"
examples which I know are not preferred.
* For clarity, there are example files intended to test some of the oddities
of loading 'MedDRA' data, but they are not real data. And, I would prefer
not to point users to those files so that they are not confusing to the
user.
6 changes: 6 additions & 0 deletions man/join_meddra.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions man/read_meddra.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.