Add Principal Components Analysis Loadings to a tidy or triple omics dataset.

add_pca_loadings(
  tomic,
  value_var = NULL,
  center_rows = TRUE,
  npcs = NULL,
  missing_val_method = "drop_samples"
)

Arguments

tomic

Either a tidy_omic or triple_omic object

value_var

An abundance value to use with hclust

center_rows

center rows before performing PCA

npcs

number of principal component loadings to add to samples (default is number of samples)

missing_val_method

Approach to remove missing values:

drop_features

Drop features with missing values

drop_samples

Drop samples which are missing all features, then drop features

impute

Impute missing values

Value

A tomic object with principal components added to samples.

Examples

add_pca_loadings(brauer_2008_triple, npcs = 5)
#> 40 features dropped due to missing values
#> $features
#> # A tibble: 460 × 4
#>    name    BP                            MF                      systematic_name
#>    <chr>   <chr>                         <chr>                   <chr>          
#>  1 YOL029C biological process unknown    molecular function unk… YOL029C        
#>  2 SCW11   cytokinesis, completion of s… glucan 1,3-beta-glucos… YGL028C        
#>  3 YHR036W biological process unknown    molecular function unk… YHR036W        
#>  4 BGL2    cell wall organization and b… glucan 1,3-beta-glucos… YGR282C        
#>  5 ACT1    cell wall organization and b… structural constituent… YFL039C        
#>  6 FKH1    pseudohyphal growth*          transcription factor a… YIL131C        
#>  7 HOC1    cell wall mannoprotein biosy… transferase activity, … YJR075W        
#>  8 CSN12   adaptation to pheromone duri… molecular function unk… YJR084W        
#>  9 YAL046C biological process unknown    molecular function unk… YAL046C        
#> 10 SLG1    cell wall organization and b… transmembrane receptor… YOR008C        
#> # … with 450 more rows
#> 
#> $samples
#> # A tibble: 36 × 8
#>    sample nutrient    DR     PC1      PC2    PC3      PC4     PC5
#>    <chr>  <chr>    <dbl>   <dbl>    <dbl>  <dbl>    <dbl>   <dbl>
#>  1 G0.05  G         0.05 -0.252   0.00514  0.317  0.0234  -0.166 
#>  2 G0.1   G         0.1  -0.169  -0.0478   0.272 -0.104   -0.172 
#>  3 G0.15  G         0.15 -0.177  -0.0824   0.272 -0.0165  -0.193 
#>  4 G0.2   G         0.2  -0.153  -0.109    0.257 -0.00839 -0.174 
#>  5 G0.25  G         0.25 -0.0111 -0.177    0.179  0.00250 -0.163 
#>  6 G0.3   G         0.3   0.0561 -0.213    0.154  0.0247  -0.154 
#>  7 N0.05  N         0.05 -0.380   0.153   -0.175  0.427   -0.135 
#>  8 N0.1   N         0.1  -0.284   0.0849  -0.255  0.323   -0.109 
#>  9 N0.15  N         0.15 -0.0754  0.0482  -0.320  0.0141  -0.0906
#> 10 N0.2   N         0.2  -0.0200 -0.0235  -0.311  0.0379  -0.0873
#> # … with 26 more rows
#> 
#> $measurements
#> # A tibble: 16,560 × 3
#>    name    sample expression
#>    <chr>   <chr>       <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
#> # … with 16,550 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: 9 × 2
#>   variable type              
#>   <chr>    <chr>             
#> 1 sample   sample_primary_key
#> 2 nutrient character         
#> 3 DR       numeric           
#> 4 PC1      numeric           
#> 5 PC2      numeric           
#> 6 PC3      numeric           
#> 7 PC4      numeric           
#> 8 PC5      numeric           
#> 9 sample   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"