6
6
<!-- badges: start -->
7
7
8
8
![ GitHub
9
- version] ( https://img.shields.io/badge/Version-6.1 .0.9000-success.svg?style=flat&logo=github )
9
+ version] ( https://img.shields.io/badge/Version-6.2 .0.9000-success.svg?style=flat&logo=github )
10
10
[ ![ CRAN
11
11
status] ( http://www.r-pkg.org/badges/version/SomaDataIO )] ( https://cran.r-project.org/package=SomaDataIO )
12
12
[ ![ Downloads] ( https://cranlogs.r-pkg.org/badges/SomaDataIO )] ( https://cran.r-project.org/package=SomaDataIO )
@@ -132,7 +132,7 @@ library(help = SomaDataIO)
132
132
133
133
## Objects and Data
134
134
135
- The ` SomaDataIO ` package comes with four (4 ) objects available to users
135
+ The ` SomaDataIO ` package comes with five (5 ) objects available to users
136
136
to run canned examples (or analyses). They can be accessed once
137
137
` SomaDataIO ` has been attached via ` library() ` . They are:
138
138
@@ -157,6 +157,10 @@ to run canned examples (or analyses). They can be accessed once
157
157
158
158
- `ex_target_names` : a mapping object for analyte - \> target
159
159
160
+ - `ex_clin_data` : a table containing variables `SampleId` ,
161
+ `smoking_status` and `alcohol_use` to demonstrate merging clinical
162
+ sample annotation information to a `soma_adat` object
163
+
160
164
- See also `?SomaScanObjects`
161
165
162
166
------------------------------------------------------------------------
@@ -192,7 +196,7 @@ adat_path
192
196
193
197
# `adat_path` should be the elaborated path and file name of the *.adat file to
194
198
# be loaded into the R workspace from your local file system
195
- # (e.g. file_path = "PATH_TO_ADAT/my_adat.adat")
199
+ # (e.g. adat_path = "PATH_TO_ADAT/my_adat.adat")
196
200
my_adat <- read_adat(file = adat_path )
197
201
198
202
# test object class
@@ -260,6 +264,54 @@ methods(class = "soma_adat")
260
264
# > see '?methods' for accessing help and source code
261
265
```
262
266
267
+ #### Merging Sample Annotation Data
268
+
269
+ The ` example_data ` object includes some sample annotation data built-in,
270
+ with the variables ` Age ` and ` Sex ` included for clinical samples, but in
271
+ practice ADAT files generally do not have any clinical or sample
272
+ annotation data fields included.
273
+
274
+ To merge sample annotation data into an existing ` soma_adat ` class
275
+ object, use the ` left_join() ` method. Here, joining the ` ex_clin_data `
276
+ object adds in two additional clinical variables, ` smoking_status ` and
277
+ ` alcohol_use ` :
278
+
279
+ ``` r
280
+ # `clin_path` should be the elaborated path and file name of the *.csv or
281
+ # similar file to be loaded into the R workspace from your local file system
282
+ # (e.g. clin_path = "PATH_TO_CLIN/clin_data.csv")
283
+ # clin_data <- readr::read_csv(clin_path)
284
+
285
+ merged_adat <- my_adat | >
286
+ dplyr :: left_join(ex_clin_data , by = " SampleId" )
287
+
288
+ merged_adat | >
289
+ dplyr :: select(SampleId , Age , Sex , smoking_status , alcohol_use ) | >
290
+ head(n = 3 )
291
+ # > ══ SomaScan Data ═══════════════════════════════════════════════════════════════
292
+ # > SomaScan version V4 (5k)
293
+ # > Signal Space 5k
294
+ # > Attributes intact ✓
295
+ # > Rows 3
296
+ # > Columns 5
297
+ # > Clinical Data 5
298
+ # > Features 0
299
+ # > ── Column Meta ─────────────────────────────────────────────────────────────────
300
+ # > ℹ SeqId, SeqIdVersion, SomaId, TargetFullName, Target, UniProt, EntrezGeneID,
301
+ # > ℹ EntrezGeneSymbol, Organism, Units, Type, Dilution, PlateScale_Reference,
302
+ # > ℹ CalReference, Cal_Example_Adat_Set001, ColCheck,
303
+ # > ℹ CalQcRatio_Example_Adat_Set001_170255, QcReference_170255,
304
+ # > ℹ Cal_Example_Adat_Set002, CalQcRatio_Example_Adat_Set002_170255, Dilution2
305
+ # > ── Tibble ──────────────────────────────────────────────────────────────────────
306
+ # > # A tibble: 3 × 6
307
+ # > row_names SampleId Age Sex smoking_status alcohol_use
308
+ # > <chr> <chr> <int> <chr> <chr> <chr>
309
+ # > 1 258495800012_3 1 76 F Never Yes
310
+ # > 2 258495800004_7 2 55 F Never Yes
311
+ # > 3 258495800010_8 3 47 M Never No
312
+ # > ════════════════════════════════════════════════════════════════════════════════
313
+ ```
314
+
263
315
Please see the article [ Loading and Wrangling
264
316
SomaScan] ( https://somalogic.github.io/SomaDataIO/articles/tips-loading-and-wrangling.html )
265
317
for more details about available ` soma_adat ` methods.
0 commit comments