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

add_pcs(
  tomic,
  value_var = NULL,
  center_rows = TRUE,
  npcs = NULL,
  missing_val_method = "drop_samples",
  label_percent_varex = TRUE,
  verbose = TRUE
)

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

label_percent_varex

If true then PCs will be labelled by the percent of variability they explain.

verbose

extra reporting messages

Value

A tomic object with principal components added to samples.

Examples

add_pcs(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                      mole… YOL029C        
#>  2 SCW11   cytokinesis, completion of separation           gluc… YGL028C        
#>  3 YHR036W biological process unknown                      mole… YHR036W        
#>  4 BGL2    cell wall organization and biogenesis           gluc… YGR282C        
#>  5 ACT1    cell wall organization and biogenesis*          stru… YFL039C        
#>  6 FKH1    pseudohyphal growth*                            tran… YIL131C        
#>  7 HOC1    cell wall mannoprotein biosynthesis*            tran… YJR075W        
#>  8 CSN12   adaptation to pheromone during conjugation wit… mole… YJR084W        
#>  9 YAL046C biological process unknown                      mole… YAL046C        
#> 10 SLG1    cell wall organization and biogenesis*          tran… YOR008C        
#> # ℹ 450 more rows
#> 
#> $samples
#> # A tibble: 36 × 8
#>    sample nutrient    DR `PC1 (30%)` `PC2 (24%)` `PC3 (14%)` `PC4 (8%)`
#>    <chr>  <chr>    <dbl>       <dbl>       <dbl>       <dbl>      <dbl>
#>  1 G0.05  G         0.05     -0.252      0.00514       0.317    0.0234 
#>  2 G0.1   G         0.1      -0.169     -0.0478        0.272   -0.104  
#>  3 G0.15  G         0.15     -0.177     -0.0824        0.272   -0.0165 
#>  4 G0.2   G         0.2      -0.153     -0.109         0.257   -0.00839
#>  5 G0.25  G         0.25     -0.0111    -0.177         0.179    0.00250
#>  6 G0.3   G         0.3       0.0561    -0.213         0.154    0.0247 
#>  7 N0.05  N         0.05     -0.380      0.153        -0.175    0.427  
#>  8 N0.1   N         0.1      -0.284      0.0849       -0.255    0.323  
#>  9 N0.15  N         0.15     -0.0754     0.0482       -0.320    0.0141 
#> 10 N0.2   N         0.2      -0.0200    -0.0235       -0.311    0.0379 
#> # ℹ 26 more rows
#> # ℹ 1 more variable: `PC5 (6%)` <dbl>
#> 
#> $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
#> # ℹ 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 (30%) numeric           
#> 5 PC2 (24%) numeric           
#> 6 PC3 (14%) numeric           
#> 7 PC4 (8%)  numeric           
#> 8 PC5 (6%)  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"
#> 
#> 
#> $unstructured
#> $unstructured$scree_df
#> # A tibble: 36 × 4
#>    pc_number eigenvalue fraction_varex pc_label 
#>        <int>      <dbl>          <dbl> <glue>   
#>  1         1      38.9          0.302  PC1 (30%)
#>  2         2      33.9          0.230  PC2 (24%)
#>  3         3      25.6          0.131  PC3 (14%)
#>  4         4      19.1          0.0730 PC4 (8%) 
#>  5         5      18.1          0.0653 PC5 (6%) 
#>  6         6      14.9          0.0444 PC6 (4%) 
#>  7         7      12.4          0.0305 PC7 (4%) 
#>  8         8      11.9          0.0283 PC8 (2%) 
#>  9         9       9.73         0.0189 PC9 (2%) 
#> 10        10       8.15         0.0133 PC10 (2%)
#> # ℹ 26 more rows
#> 
#> 
#> attr(,"class")
#> [1] "triple_omic" "tomic"       "general"