Sort a dataset's features or samples

sort_tomic(
  tomic,
  sort_type,
  sort_table,
  sort_variables = NULL,
  value_var = NULL
)

Arguments

tomic

Either a tidy_omic or triple_omic object

sort_type
hclust

Arrange samples by hierarchical clustering of a provided value_var

arrange

Arrange samples by the factor or alphanumeric ordering of a set of sort_variables

sort_table

samples or features

sort_variables

A set of attributes in sort_table to sort with in arrange.

value_var

An abundance value to use with hclust

Value

A tomic object where feature or sample primary keys have been turned into a factor reflecting how they are sorted.

Details

sort_tomic supports the reordering of features or samples using either hierarchical clustering or based on the levels of other variables. Sorting occurs by turning either the feature or sample primary key into a factor whose levels reflect the sort.

Examples


library(dplyr)

sort_tomic(brauer_2008_triple,
  sort_type = "arrange", sort_table = "samples",
  sort_variables = c("nutrient", "DR")
) %>%
  sort_tomic(
    sort_type = "hclust",
    sort_table = "features",
    value_var = "expression"
  )
#> $features
#> # A tibble: 500 × 4
#>    name    systematic_name BP                             MF                    
#>    <fct>   <chr>           <chr>                          <chr>                 
#>  1 DAL5    YJR152W         "allantoate transport"         "allantoate transport…
#>  2 PTR2    YKR093W         "peptide transport"            "peptide transporter …
#>  3 MET17   YLR303W         "methionine metabolism*"       "cysteine synthase ac…
#>  4 MET32   YDR253C         "sulfur amino acid metabolism" "DNA binding*"        
#>  5 YGR154C YGR154C         "biological process unknown"   "molecular function u…
#>  6 YLL056C YLL056C         "biological process unknown"   "molecular function u…
#>  7 IDP3    YNL009W         "fatty acid beta-oxidation*"   "isocitrate dehydroge…
#>  8 YER121W YER121W         ""                             ""                    
#>  9 OM45    YIL136W         "biological process unknown"   "molecular function u…
#> 10 GSY2    YLR258W         "glycogen metabolism"          "glycogen (starch) sy…
#> # ℹ 490 more rows
#> 
#> $samples
#> # A tibble: 36 × 3
#>    sample nutrient    DR
#>    <fct>  <chr>    <dbl>
#>  1 G0.05  G         0.05
#>  2 G0.1   G         0.1 
#>  3 G0.15  G         0.15
#>  4 G0.2   G         0.2 
#>  5 G0.25  G         0.25
#>  6 G0.3   G         0.3 
#>  7 L0.05  L         0.05
#>  8 L0.1   L         0.1 
#>  9 L0.15  L         0.15
#> 10 L0.2   L         0.2 
#> # ℹ 26 more rows
#> 
#> $measurements
#> # A tibble: 18,000 × 3
#>    name    sample expression
#>    <fct>   <fct>       <dbl>
#>  1 YOL029C G0.05       -0.22
#>  2 SCW11   G0.05       -0.67
#>  3 YHR036W G0.05       -0.91
#>  4 BGL2    G0.05       -0.08
#>  5 ACT1    G0.05       -0.04
#>  6 FKH1    G0.05       -0.57
#>  7 HOC1    G0.05       -0.42
#>  8 CSN12   G0.05       -0.49
#>  9 YAL046C G0.05        0.05
#> 10 SLG1    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 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 character         
#> 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] "triple_omic" "tomic"       "general"