Convert a triple_omic object into a tidy_omic oobject.

triple_to_tidy(triple_omic)

Arguments

triple_omic

an object of class triple_omic produced by create_triple_omic

Value

A tidy_omic object as created by

create_tidy_omic.

Details

Features, samples and measurements will be merged into a single data table, and the design will be preserved as-is.

Examples


library(dplyr)

measurement_df <- tidyr::expand_grid(
  feature_id = 1:10,
  sample_id = LETTERS[1:5]
) %>%
  dplyr::mutate(value = rnorm(n()))

feature_df <- tibble(
  feature_id = 1:10,
  feature_group = rep(c("a", "b"), each = 5)
)
sample_df <- tibble(
  sample_id = LETTERS[1:5],
  sample_group = c("a", "a", "b", "b", "b")
)

triple_omic <- create_triple_omic(
  measurement_df, feature_df, sample_df,
  "feature_id", "sample_id"
)
triple_to_tidy(triple_omic)
#> $data
#> # A tibble: 50 × 5
#>    feature_id feature_group sample_id sample_group   value
#>         <int> <chr>         <chr>     <chr>          <dbl>
#>  1          1 a             A         a            -0.669 
#>  2          1 a             B         a             0.0900
#>  3          1 a             C         b            -0.331 
#>  4          1 a             D         b            -0.514 
#>  5          1 a             E         b            -0.907 
#>  6          2 a             A         a             0.241 
#>  7          2 a             B         a            -0.478 
#>  8          2 a             C         b            -2.46  
#>  9          2 a             D         b            -1.42  
#> 10          2 a             E         b             0.467 
#> # ℹ 40 more rows
#> 
#> $design
#> $design$features
#> # A tibble: 2 × 2
#>   variable      type               
#>   <chr>         <chr>              
#> 1 feature_id    feature_primary_key
#> 2 feature_group character          
#> 
#> $design$samples
#> # A tibble: 2 × 2
#>   variable     type              
#>   <chr>        <chr>             
#> 1 sample_id    sample_primary_key
#> 2 sample_group character         
#> 
#> $design$measurements
#> # A tibble: 3 × 2
#>   variable   type               
#>   <chr>      <chr>              
#> 1 feature_id feature_primary_key
#> 2 sample_id  sample_primary_key 
#> 3 value      numeric            
#> 
#> $design$feature_pk
#> [1] "feature_id"
#> 
#> $design$sample_pk
#> [1] "sample_id"
#> 
#> 
#> attr(,"class")
#> [1] "tidy_omic" "tomic"     "general"