Convert a wide dataset of species' abundances (gene product, metabolites, lipids, ...) into a triple_omic dataset (one observation per row)

convert_wide_to_tidy_omic(
  wide_df,
  feature_pk,
  feature_vars = NULL,
  sample_var = "sample",
  measurement_var = "abundance",
  omic_type_tag = "general",
  verbose = TRUE
)

Arguments

wide_df

a data.frame (or tibble) containing 1+ columns of feature attributes and many columns of samples

feature_pk

A unique identifier for features

feature_vars

a character vector of additional feature-level variables (or NULL if there are no additional variables)

sample_var

variable name to use for samples

measurement_var

variable name to use for measurements

omic_type_tag

an optional subtype of omic data: metabolomics, lipidomics, proteomics, genomics, general

verbose

extra reporting messages

Value

A tidy_omic object as produced by create_tidy_omic.

Examples


library(dplyr)
#> 
#> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’:
#> 
#>     filter, lag
#> The following objects are masked from ‘package:base’:
#> 
#>     intersect, setdiff, setequal, union

wide_measurements <- brauer_2008_triple[["measurements"]] %>%
  tidyr::spread(sample, expression)

wide_df <- brauer_2008_triple[["features"]] %>%
  left_join(wide_measurements, by = "name")

convert_wide_to_tidy_omic(wide_df,
  feature_pk = "name",
  feature_vars = c("BP", "MF", "systematic_name")
)
#> 1 measurement variables were defined as the
#> left overs from the specified feature and sample varaibles:
#> abundance
#> $data
#> # A tibble: 18,000 × 6
#>    name    BP                             MF    systematic_name sample abundance
#>    <chr>   <chr>                          <chr> <chr>           <chr>      <dbl>
#>  1 YOL029C biological process unknown     mole… YOL029C         G0.05      -0.22
#>  2 SCW11   cytokinesis, completion of se… gluc… YGL028C         G0.05      -0.67
#>  3 YHR036W biological process unknown     mole… YHR036W         G0.05      -0.91
#>  4 BGL2    cell wall organization and bi… gluc… YGR282C         G0.05      -0.08
#>  5 ACT1    cell wall organization and bi… stru… YFL039C         G0.05      -0.04
#>  6 FKH1    pseudohyphal growth*           tran… YIL131C         G0.05      -0.57
#>  7 HOC1    cell wall mannoprotein biosyn… tran… YJR075W         G0.05      -0.42
#>  8 CSN12   adaptation to pheromone durin… mole… YJR084W         G0.05      -0.49
#>  9 YAL046C biological process unknown     mole… YAL046C         G0.05       0.05
#> 10 SLG1    cell wall organization and bi… tran… YOR008C         G0.05      -0.06
#> # ℹ 17,990 more rows
#> 
#> $design
#> $design$features
#> # A tibble: 4 × 2
#>   variable        type               
#>   <chr>           <chr>              
#> 1 name            feature_primary_key
#> 2 BP              character          
#> 3 MF              character          
#> 4 systematic_name character          
#> 
#> $design$samples
#> # A tibble: 1 × 2
#>   variable type              
#>   <chr>    <chr>             
#> 1 sample   sample_primary_key
#> 
#> $design$measurements
#> # A tibble: 3 × 2
#>   variable  type               
#>   <chr>     <chr>              
#> 1 name      feature_primary_key
#> 2 sample    sample_primary_key 
#> 3 abundance numeric            
#> 
#> $design$feature_pk
#> [1] "name"
#> 
#> $design$sample_pk
#> [1] "sample"
#> 
#> 
#> attr(,"class")
#> [1] "tidy_omic" "tomic"     "general"