### Install GenomicDataCommons Package Source: https://github.com/bioconductor/genomicdatacommons/blob/devel/README.md Installs the GenomicDataCommons package using BiocManager. Ensure BiocManager is installed first. ```r if (!require("BiocManager")) install.packages("BiocManager") BiocManager::install('GenomicDataCommons') ``` -------------------------------- ### Find Gene Expression Data Manifest Source: https://github.com/bioconductor/genomicdatacommons/blob/devel/README.md Builds a manifest to guide the download of raw gene expression files quantified as raw counts using STAR from TCGA ovarian cancer patients. Filters are applied to select specific project, data type, and workflow type. ```r ge_manifest <- files() |> filter( cases.project.project_id == 'TCGA-OV') |> filter( type == 'gene_expression' ) |> filter( analysis.workflow_type == 'STAR - Counts') |> manifest(size = 5) ge_manifest ``` -------------------------------- ### Run Package Tests with devtools Source: https://github.com/bioconductor/genomicdatacommons/blob/devel/tests/README.md Execute all tests for an R package. Ensure tests are located in the tests/testthat/ directory. ```r devtools::test() ``` -------------------------------- ### Basic String Length Test with testthat Source: https://github.com/bioconductor/genomicdatacommons/blob/devel/tests/README.md Tests the `str_length` function from the stringr package. Asserts that the function correctly returns the number of characters in a string. ```r library(stringr) context("String length") test_that("str_length is number of characters", { expect_equal(str_length("a"), 1) expect_equal(str_length("ab"), 2) expect_equal(str_length("abc"), 3) }) ``` -------------------------------- ### String Length Test for Factors with testthat Source: https://github.com/bioconductor/genomicdatacommons/blob/devel/tests/README.md Tests the `str_length` function with factor inputs. Asserts that the function correctly returns the number of characters in the factor levels. ```r test_that("str_length of factor is length of level", { expect_equal(str_length(factor("a")), 1) expect_equal(str_length(factor("ab")), 2) expect_equal(str_length(factor("abc")), 3) }) ``` -------------------------------- ### Load GenomicDataCommons Library Source: https://github.com/bioconductor/genomicdatacommons/blob/devel/README.md Loads the GenomicDataCommons library into the R session for use. ```r library(GenomicDataCommons) ``` -------------------------------- ### Display Exposures Data Frame Source: https://github.com/bioconductor/genomicdatacommons/blob/devel/README.md Displays the first four columns of the exposures data frame (exposuresDF). This provides a snapshot of exposure-related information, including submitter ID, creation date, alcohol intensity, and smoking pack years. ```r exposuresDF[, 1:4] #> submitter_id created_datetime alcohol_intensity pack_years_smoked #> 2525bfef-6962-4b7f-8e80-6186400ce624 C3N-03839-EXP 2019-12-30T10:23:07.190853-06:00 Lifelong Non-Drinker NA #> 126507c3-c0d7-41fb-9093-7deed5baf431 C3N-01518-EXP 2018-06-21T14:27:48.817254-05:00 Lifelong Non-Drinker NA #> c43ac461-9f03-44bc-be7d-3d867eb708a0 C3N-03933-EXP 2019-03-14T08:23:14.054975-05:00 Lifelong Non-Drinker NA #> a59a90d9-f1b0-49dd-9c97-bcaa6ba55d44 C3N-02695-EXP 2019-03-14T08:23:14.054975-05:00 Occasional Drinker 16.8 #> 59122a43-606a-4669-806b-6747e0ac9985 C3L-03642-EXP 2019-06-24T07:53:15.534197-05:00 Lifelong Non-Drinker 39.0 #> 4447a969-e5c8-4291-b83c-53a0f7e77cbc C3L-03728-EXP 2019-06-24T07:53:15.534197-05:00 Lifelong Non-Drinker NA ``` -------------------------------- ### Display Demographic Data Frame Source: https://github.com/bioconductor/genomicdatacommons/blob/devel/README.md Displays the first four columns of the demographic data frame (demoDF). This is useful for a quick inspection of the demographic information retrieved. ```r demoDF[, 1:4] #> cause_of_death race gender ethnicity #> 2525bfef-6962-4b7f-8e80-6186400ce624 not reported female not reported #> 126507c3-c0d7-41fb-9093-7deed5baf431 Cancer Related not reported female not reported #> c43ac461-9f03-44bc-be7d-3d867eb708a0 not reported female not reported #> a59a90d9-f1b0-49dd-9c97-bcaa6ba55d44 Cancer Related not reported male not reported #> 59122a43-606a-4669-806b-6747e0ac9985 white male not hispanic or latino #> 4447a969-e5c8-4291-b83c-53a0f7e77cbc Cancer Related white female not hispanic or latino ``` -------------------------------- ### String Length Test for Missing Values with testthat Source: https://github.com/bioconductor/genomicdatacommons/blob/devel/tests/README.md Tests the `str_length` function with missing values (NA). Asserts correct handling of NA in strings and vectors, and distinguishes between NA and the string "NA". ```r test_that("str_length of missing is missing", { expect_equal(str_length(NA), NA_integer_) expect_equal(str_length(c(NA, 1)), c(NA, 1)) expect_equal(str_length("NA"), 2) }) ``` -------------------------------- ### Display Diagnosis Data Frame Source: https://github.com/bioconductor/genomicdatacommons/blob/devel/README.md Displays the first four columns of the diagnoses data frame (diagDF), which has been processed using bindrowname. This shows details like AJCC stage, creation date, tissue origin, and age at diagnosis, highlighting that diagnoses can have multiple entries per patient. ```r diagDF <- bindrowname(clinResults$diagnoses) diagDF[, 1:4] #> ajcc_pathologic_stage created_datetime tissue_or_organ_of_origin age_at_diagnosis #> 2525bfef-6962-4b7f-8e80-6186400ce624 Stage IIB 2019-07-22T06:40:02.183501-05:00 Head of pancreas 19956 #> 126507c3-c0d7-41fb-9093-7deed5baf431 Not Reported 2018-12-03T12:05:16.846188-06:00 Temporal lobe 26312 #> c43ac461-9f03-44bc-be7d-3d867eb708a0 Stage III 2019-03-14T10:37:34.405260-05:00 Floor of mouth, NOS 25635 #> a59a90d9-f1b0-49dd-9c97-bcaa6ba55d44 Not Reported 2019-03-14T10:37:34.405260-05:00 Floor of mouth, NOS 16652 #> 59122a43-606a-4669-806b-6747e0ac9985 Not Reported 2019-07-22T06:40:02.183501-05:00 Upper lobe, lung 23384 #> 4447a969-e5c8-4291-b83c-53a0f7e77cbc Not Reported 2019-05-07T07:41:33.411909-05:00 Frontal lobe 29326 ``` -------------------------------- ### Download Gene Expression Data Source: https://github.com/bioconductor/genomicdatacommons/blob/devel/README.md Downloads gene expression files specified in a manifest. It utilizes BiocParallel for multi-process downloads to speed up transfer. Ensure you have the necessary authentication tokens if downloading controlled-access data. ```r library(BiocParallel) register(MulticoreParam()) destdir <- tempdir() fnames <- lapply(ge_manifest$id,gdcdata) ``` -------------------------------- ### Create Data Frame from Clinical Data Source: https://github.com/bioconductor/genomicdatacommons/blob/devel/README.md Constructs a data frame from clinical data by expanding specified fields and filtering out rows with missing demographic information. Requires the GenomicDataCommons package and helper functions like filterAllNA and bindrowname. ```r expands <- c("diagnoses","annotations", "demographic","exposures") clinResults <- cases() | GenomicDataCommons::select(NULL) | GenomicDataCommons::expand(expands) | results(size=6) demoDF <- filterAllNA(clinResults$demographic) exposuresDF <- bindrowname(clinResults$exposures) ``` -------------------------------- ### Check GenomicDataCommons Status Source: https://github.com/bioconductor/genomicdatacommons/blob/devel/README.md Checks the status of the GenomicDataCommons API, including commit hash, data release version, and operational status. This is useful for verifying connectivity and the current data version. ```r status() #> $commit #> [1] "4dd3680528a19ed33cfc83c7d049426c97bb903b" #> #> $data_release #> [1] "Data Release 34.0 - July 27, 2022" #> #> $status #> [1] "OK" #> #> $tag #> [1] "3.0.0" #> #> $version #> [1] 1 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.