Update sample metadata to order categorical variables based on a specified factor order.

update_sample_factors(tomic, factor_levels)

Arguments

tomic

Either a tidy_omic or triple_omic object

factor_levels

a character vector specifying the ordering of factor levels.

Value

a tomic object with updated sample metadata

Examples

update_sample_factors(
  brauer_2008_tidy, list(nutrient = c("G", "N", "P", "S", "L", "U"))
)
#> $data
#> # A tibble: 18,000 × 8
#>    name    BP             MF    systematic_name sample nutrient    DR expression
#>    <chr>   <chr>          <chr> <chr>           <chr>  <fct>    <dbl>      <dbl>
#>  1 YOL029C biological pr… mole… YOL029C         G0.05  G         0.05      -0.22
#>  2 YOL029C biological pr… mole… YOL029C         G0.1   G         0.1       -0.18
#>  3 YOL029C biological pr… mole… YOL029C         G0.15  G         0.15       0.27
#>  4 YOL029C biological pr… mole… YOL029C         G0.2   G         0.2        0.18
#>  5 YOL029C biological pr… mole… YOL029C         G0.25  G         0.25       0.03
#>  6 YOL029C biological pr… mole… YOL029C         G0.3   G         0.3       -0.04
#>  7 YOL029C biological pr… mole… YOL029C         N0.05  N         0.05       0.26
#>  8 YOL029C biological pr… mole… YOL029C         N0.1   N         0.1        0.15
#>  9 YOL029C biological pr… mole… YOL029C         N0.15  N         0.15       0.04
#> 10 YOL029C biological pr… mole… YOL029C         N0.2   N         0.2       -0.07
#> # ℹ 17,990 more rows
#> 
#> $design
#> $design$features
#> # A tibble: 4 × 2
#>   variable        type               
#>   <chr>           <chr>              
#> 1 name            feature_primary_key
#> 2 systematic_name character          
#> 3 BP              character          
#> 4 MF              character          
#> 
#> $design$samples
#> # A tibble: 3 × 2
#>   variable type              
#>   <chr>    <chr>             
#> 1 sample   sample_primary_key
#> 2 nutrient factor            
#> 3 DR       numeric           
#> 
#> $design$measurements
#> # A tibble: 3 × 2
#>   variable   type               
#>   <chr>      <chr>              
#> 1 name       feature_primary_key
#> 2 sample     sample_primary_key 
#> 3 expression numeric            
#> 
#> $design$feature_pk
#> [1] "name"
#> 
#> $design$sample_pk
#> [1] "sample"
#> 
#> 
#> attr(,"class")
#> [1] "tidy_omic" "tomic"     "general"