From 3c465884a5c044cf37baf5ae430b15ba9a2b1752 Mon Sep 17 00:00:00 2001 From: Ju Yeong Kim Date: Thu, 13 Dec 2018 16:03:58 -0800 Subject: [PATCH] Reexport Rlabkey::makeFilter --- DESCRIPTION | 2 +- NAMESPACE | 1 + R/DataSpaceStudy.R | 2 +- R/helpers.R | 4 + man/reexports.Rd | 16 ++++ vignettes/Intro_to_DataSpaceR.Rmd | 1 - vignettes/Intro_to_DataSpaceR.html | 128 ++++++++++++++++++----------- 7 files changed, 103 insertions(+), 51 deletions(-) create mode 100644 man/reexports.Rd diff --git a/DESCRIPTION b/DESCRIPTION index 1e3204c..da23f5e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -30,4 +30,4 @@ Suggests: knitr, pryr VignetteBuilder: knitr -RoxygenNote: 6.1.0 +RoxygenNote: 6.1.1 diff --git a/NAMESPACE b/NAMESPACE index dba85ce..0198eed 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -2,6 +2,7 @@ export(checkNetrc) export(connectDS) +export(makeFilter) export(writeNetrc) importFrom(R6,R6Class) importFrom(Rlabkey,getSession) diff --git a/R/DataSpaceStudy.R b/R/DataSpaceStudy.R index e33cce0..5b100ce 100644 --- a/R/DataSpaceStudy.R +++ b/R/DataSpaceStudy.R @@ -105,7 +105,7 @@ #' } #' @docType class #' @importFrom digest digest -#' @importFrom Rlabkey labkey.getQueryDetails labkey.executeSql makeFilter +#' @importFrom Rlabkey labkey.getQueryDetails labkey.executeSql DataSpaceStudy <- R6Class( classname = "DataSpaceStudy", public = list( diff --git a/R/helpers.R b/R/helpers.R index 350d4e7..399d0a6 100644 --- a/R/helpers.R +++ b/R/helpers.R @@ -222,3 +222,7 @@ makeCountQuery <- function(dataset, group) { query } + +#' @importFrom Rlabkey makeFilter +#' @export +Rlabkey::makeFilter diff --git a/man/reexports.Rd b/man/reexports.Rd new file mode 100644 index 0000000..1e27860 --- /dev/null +++ b/man/reexports.Rd @@ -0,0 +1,16 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/helpers.R +\docType{import} +\name{reexports} +\alias{reexports} +\alias{makeFilter} +\title{Objects exported from other packages} +\keyword{internal} +\description{ +These objects are imported from other packages. Follow the links +below to see their documentation. + +\describe{ + \item{Rlabkey}{\code{\link[Rlabkey]{makeFilter}}} +}} + diff --git a/vignettes/Intro_to_DataSpaceR.Rmd b/vignettes/Intro_to_DataSpaceR.Rmd index 7d1a9d4..9bdbaf0 100644 --- a/vignettes/Intro_to_DataSpaceR.Rmd +++ b/vignettes/Intro_to_DataSpaceR.Rmd @@ -96,7 +96,6 @@ knitr::kable(cvd256$getVariableInfo("NAb")) To get only a subset of the data and speed up the download, filters can be passed to `getDataset`. The filters are created using the `makeFilter` function of the `Rlabkey` package. ```{r getDataset-filter} -library(Rlabkey) cvd256Filter <- makeFilter(c("visit_day", "EQUAL", "0")) NAb_day0 <- cvd256$getDataset("NAb", colFilter = cvd256Filter) dim(NAb_day0) diff --git a/vignettes/Intro_to_DataSpaceR.html b/vignettes/Intro_to_DataSpaceR.html index 796334c..0f803f6 100644 --- a/vignettes/Intro_to_DataSpaceR.html +++ b/vignettes/Intro_to_DataSpaceR.html @@ -12,7 +12,7 @@ - + Introduction to DataSpaceR @@ -70,7 +70,7 @@

Introduction to DataSpaceR

Ju Yeong Kim

-

2018-10-16

+

2018-12-13

@@ -78,21 +78,21 @@

2018-10-16

Configuration

First, go to DataSpace now and set yourself up with an account.

-

In order to connect to the CAVD DataSpace via DataSpaceR, you will need a netrc file in your home directory that will contain a machine name (hostname of DataSpace), and login and password. There are two ways to creat a netrc file.

+

In order to connect to the CAVD DataSpace via DataSpaceR, you will need a netrc file in your home directory that will contain a machine name (hostname of DataSpace), and login and password. There are two ways to create a netrc file.

Creating a netrc file with writeNetrc

-

On your R console, create a netrc file using a function from DataSpaceR:

+

On your R console, create a netrc file using a function from DataSpaceR:

DataSpaceR::writeNetrc("yourEmail@address.com", "yourSecretPassword")
-

This will create a netrc file in your home directory. Make sure you have a valid login and password.

+

This will create a netrc file in your home directory. Make sure you have a valid login and password.

Manually creating a netrc file

-

Alternatively, you can manually create a netrc file in the computer running R.

+

Alternatively, you can manually create a netrc file.

  • On Windows, this file sould be named _netrc
  • -
  • On UNIX, it should be named .netrc
  • +
  • On UNIX/Mac, it should be named .netrc
  • The file should be located in the user’s home directory, and the permissions on the file should be unreadable for everybody except the owner
  • -
  • To determine home directory, run Sys.getenv("HOME") in R
  • +
  • To determine your home directory, run Sys.getenv("HOME") in R

The following three lines must be included in the .netrc or _netrc file either separated by white space (spaces, tabs, or newlines) or commas. Multiple such blocks can exist in one file.

machine dataspace.cavd.org
@@ -103,19 +103,19 @@ 

Manually creating a netrc file

Initiate a connection

-

We’ll be looking at study cvd256. If you want to use a different study, change that string. The connections have state, so you can instantiate multiple connections to different studies simultaneously.

+

We’ll be looking at study cvd256. If you want to use a different study, change that string. You can instantiate multiple connections to different studies simultaneously.

library(DataSpaceR)
 con <- connectDS()
 con
## <DataSpaceConnection>
 ##   URL: https://dataspace.cavd.org
 ##   User: jkim2345@scharp.org
-##   Available studies: 245
-##     - 62 studies with data
-##     - 1835 subjects
+##   Available studies: 249
+##     - 65 studies with data
+##     - 4499 subjects
 ##     - 5 assays
-##     - 240602 data points
-##   Available groups: 4
+## - 288603 data points +## Available groups: 6

The call to connectDS instantiates the connection. Printing the object shows where it’s connected and the available studies.

cvd256 <- con$getStudy("cvd256")
 cvd256
@@ -191,7 +191,7 @@

Initiate a connection

-

Available datasets and treatment arm information for the connection can be access by availableDatasets and treatmentArm.

+

Available datasets and treatment arm information for the connection can be accessed by availableDatasets and treatmentArm.

Fetching datasets

@@ -402,6 +402,11 @@

Fetching datasets

library(Rlabkey)
## Loading required package: httr
## Loading required package: jsonlite
+
## 
+## Attaching package: 'jsonlite'
+
## The following object is masked from 'package:DataSpaceR':
+## 
+##     fromJSON
cvd256Filter <- makeFilter(c("visit_day", "EQUAL", "0"))
 NAb_day0 <- cvd256$getDataset("NAb", colFilter = cvd256Filter)
 dim(NAb_day0)
@@ -410,10 +415,10 @@

Fetching datasets

Cross-study connection

-

To fetch data from multiple studies, simply create a connection at the project level.

+

To fetch data from multiple studies, create a connection at the project level.

cavd <- con$getStudy("")

This will instantiate a connection at the CAVD level. Most functions work cross study connections just like they do on single studies.

-

You can get a list of datasets available accross all studies.

+

You can get a list of datasets available across all studies.

cavd
## <DataSpaceStudy>
 ##   Study: CAVD
@@ -437,12 +442,12 @@ 

Cross-study connection

BAMA Binding Ab multiplex assay -63579 +86289 Demographics Demographics -1835 +4499 ELISPOT @@ -452,37 +457,39 @@

Cross-study connection

ICS Intracellular Cytokine Staining -128226 +150910 NAb Neutralizing antibody -43187 +45794 -

In cross-study connections, getDataset will combine the requested datasets. Note that in most cases the datasets will have too many subjects, making the filtering of the data a necessity. The colFilter argument can be used here, as described in the getDataset section.

+

In cross-study connections, getDataset will combine the requested datasets. Note that in most cases the datasets will have too many subjects for quick data transfer, making filtering of the data a necessity. The colFilter argument can be used here, as described in the getDataset section.

conFilter <- makeFilter(c("species", "EQUAL", "Human"))
 human <- cavd$getDataset("Demographics", colFilter = conFilter)
 dim(human)
-
## [1] 250  32
+
## [1] 2754   36
colnames(human)
##  [1] "SubjectId"                       "SubjectVisit/Visit"             
 ##  [3] "species"                         "subspecies"                     
 ##  [5] "sexatbirth"                      "race"                           
 ##  [7] "ethnicity"                       "country_enrollment"             
 ##  [9] "circumcised_enrollment"          "bmi_enrollment"                 
-## [11] "agegroup_range"                  "age_enrollment"                 
-## [13] "study_label"                     "study_start_date"               
-## [15] "study_first_enr_date"            "study_fu_complete_date"         
-## [17] "study_public_date"               "study_network"                  
-## [19] "study_last_vaccination_day"      "study_type"                     
-## [21] "study_part"                      "study_group"                    
-## [23] "study_arm"                       "study_arm_summary"              
-## [25] "study_arm_coded_label"           "study_randomization"            
-## [27] "study_product_class_combination" "study_product_combination"      
-## [29] "study_short_name"                "study_grant_pi_name"            
-## [31] "study_strategy"                  "study_prot"
+## [11] "agegroup_range" "agegroup_enrollment" +## [13] "age_enrollment" "study_label" +## [15] "study_start_date" "study_first_enr_date" +## [17] "study_fu_complete_date" "study_public_date" +## [19] "study_network" "study_last_vaccination_day" +## [21] "study_type" "study_part" +## [23] "study_group" "study_arm" +## [25] "study_arm_summary" "study_arm_coded_label" +## [27] "study_randomization" "study_product_class_combination" +## [29] "study_product_combination" "study_short_name" +## [31] "study_grant_pi_name" "study_strategy" +## [33] "study_prot" "genderidentity" +## [35] "studycohort" "bmi_category"

Connect to a saved group

@@ -542,9 +549,29 @@

Connect to a saved group

36 cvd338 + +228 +HVTN 505 case control subjects +HVTN 505 case control subjects +Participants from HVTN 505 included in the case-control analysis +drienna +TRUE +189 +vtn505 + + +230 +HVTN 505 polyfunctionality vs BAMA +HVTN 505 polyfunctionality vs BAMA +Compares ICS polyfunctionality (CD8+, Any Env) to BAMA mfi-delta (single Env antigen) in the HVTN 505 case control cohort +drienna +TRUE +170 +vtn505 + -

To fetch data from a saved group, create a connection at the project level with a group ID. For example, we can connect to mice group which has group ID 208 by getGroup.

+

To fetch data from a saved group, create a connection at the project level with a group ID. For example, we can connect to mice group which has group ID 216 by getGroup.

mice <- con$getGroup(216)
 mice
## <DataSpaceStudy>
@@ -576,7 +603,7 @@ 

Retrieve NAb dataset

invisible(cvd408$getDataset("NAb")) proc.time() - ptm
##    user  system elapsed 
-##   0.163   0.004   0.213
+## 0.235 0.021 0.298
str(cvd408$cache, max.level = 2)
## List of 1
 ##  $ c77008daa024cbb89510cbcb600cef37:List of 2
@@ -630,21 +657,26 @@ 

Session information

## [1] stats graphics grDevices utils datasets methods base ## ## other attached packages: -## [1] pryr_0.1.4 Rlabkey_2.2.2 jsonlite_1.5 httr_1.3.1 +## [1] pryr_0.1.4 Rlabkey_2.2.4 jsonlite_1.5 httr_1.3.1 ## [5] DataSpaceR_0.5.2 ## ## loaded via a namespace (and not attached): -## [1] Rcpp_0.12.19 rstudioapi_0.8 knitr_1.20 -## [4] xml2_1.2.0 magrittr_1.5 roxygen2_6.1.0 -## [7] devtools_1.13.6 rjson_0.2.20 R6_2.3.0 -## [10] rlang_0.2.2 highr_0.7 stringr_1.3.1 -## [13] tools_3.5.1 data.table_1.11.8 withr_2.1.2 -## [16] htmltools_0.3.6 commonmark_1.6 yaml_2.2.0 -## [19] rprojroot_1.3-2 digest_0.6.17 assertthat_0.2.0 -## [22] crayon_1.3.4 purrr_0.2.5 codetools_0.2-15 -## [25] testthat_2.0.0 curl_3.2 evaluate_0.11 -## [28] memoise_1.1.0 rmarkdown_1.10 stringi_1.2.4 -## [31] compiler_3.5.1 backports_1.1.2 desc_1.2.0
+## [1] Rcpp_1.0.0 highr_0.7 compiler_3.5.1 +## [4] prettyunits_1.0.2 base64enc_0.1-3 remotes_2.0.2 +## [7] tools_3.5.1 testthat_2.0.1 digest_0.6.18 +## [10] pkgbuild_1.0.2 pkgload_1.0.2 evaluate_0.12 +## [13] memoise_1.1.0 debugme_1.1.0 rlang_0.3.0.1 +## [16] cli_1.0.1 rstudioapi_0.8 commonmark_1.7 +## [19] yaml_2.2.0 curl_3.2 knitr_1.20 +## [22] withr_2.1.2 stringr_1.3.1 roxygen2_6.1.1 +## [25] xml2_1.2.0 desc_1.2.0 fs_1.2.6 +## [28] devtools_2.0.1 rprojroot_1.3-2 data.table_1.11.8 +## [31] glue_1.3.0 R6_2.3.0 processx_3.2.0 +## [34] rmarkdown_1.10 sessioninfo_1.1.1 callr_3.0.0 +## [37] purrr_0.2.5 magrittr_1.5 codetools_0.2-15 +## [40] htmltools_0.3.6 backports_1.1.2 ps_1.2.1 +## [43] usethis_1.4.0 assertthat_0.2.0 stringi_1.2.4 +## [46] rjson_0.2.20 crayon_1.3.4