knitr::opts_chunk$set(collapse = TRUE, comment = "#>")
options(DT.options = list(paginate = FALSE, info = FALSE, filter = FALSE))

OVERVIEW

The purpose of this vignette is to demonstrate how to use the functions and data in the R2i package to create the subjectHuman.csv that must be submitted along with assay and other metaData to the public ImmPort database at NIH for projects with patients. Animal subjects require a different template (subjectsAnimal).

When creating your own submission documents, you can create a similar vignette so that the whole process is reproducible.

First, we will load the R2i library, which has the functions and templates we need.

library(R2i)

We will need to create a dataframe with the following variables:
- Arm Or Cohort ID
- Gender
- Min Subject Age
- Max Subject Age
- Age Unit
- Age Event
- Age Event Specify
- Subject Phenotype
- Subject Location
- Ethnicity
- Race
- Race Specify
- Description
- Subject ID - Result Separator Column - Exposure Process Reported - Exposure Material Reported - Exposure Material ID - Disease Reported - Disease Ontology ID - Disease Stage Reported

In order to get a pre-made dataframe for subjectHumans we use the getTemplateDF() function.
The only argument is the name of the template.

subjectHumans <- getTemplateDF("subjectHumans", 3)
DT::datatable(subjectHumans)

Now that we have the subjectHumans dataframe, the easiest way to edit the dataframe by hand is to use the edit() function and save the output by clicking "quit" in the editor. This function is found in the utils package, but depends on the X11 library. If you are on a newer mac you may need to install XQuartz from the project's website as it is no longer bundled. If for some reason edit() does not save the output correctly on your machine, then you will have to input information using an R-based approach.

edit(subjectHumans)

An R-based approach example:

subjectHumans$`Arm Or Cohort ID` <- paste("myArmAndCohortID", seq(1:3), sep = "_")
subjectHumans$Gender <- c("Male", "Female", "Male")
subjectHumans$`Min Subject Age` <- c(25, 22.3, 30)
subjectHumans$`Max Subject Age` <- c(27, 24.3, 32)
subjectHumans$`Age Event` <- "Age at Enrollment"
subjectHumans$`Age Event Specify` <- "study milestone for subject's age that is unsupported by ImmPort"
subjectHumans$`Subject Phenotype` <- "phenotype that captures subject disposition for the study"
subjectHumans$`Subject Location` <- "United States of America"
subjectHumans$Ethnicity <- "Other"
subjectHumans$Race <- "Asian"
subjectHumans$`Race Specify` <- ""
subjectHumans$Description <- ""
subjectHumans$`Subject ID` <- paste("myID", seq(1:3), sep = "_")

DT::datatable(subjectHumans)

Now we can use the checkTemplate() function to ensure that our dataframe meets the ImmPort upload requirements. For the purpose of this vignette we will wrap the function in a tryCatch() method.

results <- tryCatch(
  checkTemplate(subjectHumans, "subjectHumans"),
  error = function(e) {
    return(e)
  }
)

# This will print out which required columns are missing values
results$required

The error tells us that the required column subjectHumans$'Exposure Process Reported' has been left blank. We must correct the dataframe and re-run the check function.

subjectHumans$`Exposure Process Reported` <- "Vaccine"

results <- tryCatch(
  checkTemplate(subjectHumans, "subjectHumans"),
  error = function(e) {
    return(e)
  }
)

# This will print out the error message
results$format

Here the error message is telling us that a non-controlled term is being used in the subjectHumans$'Age Event' column, which requires controlled terms. To look up controlled terms we can use the getLookupValues() function. This function takes the template name and column name as arguments and returns a vector of the allowed terms.

getIPLookupValues("subjectHumans", "Age Event")

From the output we can see that our original entry 'Age at Enrollment' must be corrected to 'Age at enrollment'. We can then check the dataframe again.

subjectHumans$`Age Event` <- "Age at enrollment"

checkTemplate(subjectHumans, "subjectHumans")

Now we can see that Age Unit is not present and should be, so we can look that up and correct it.

getIPLookupValues("subjectHumans", "Age Unit")

subjectHumans$`Age Unit` <- "Years"

checkTemplate(subjectHumans, "subjectHumans")

If there are no errors, the subjectHumans dataframe is complete.


CREATING THE OUTPUT TSV

temp <- tempdir()
transform_Data(
  df = subjectHumans,
  outputDir = temp,
  validate = TRUE
)


RGLab/R2i documentation built on May 20, 2021, 10:14 a.m.