Skip to contents

Filtering the experiment to keep only significant variables is a common task. This function provides a convenient way to do this. It supports results from all glystats DEA functions including gly_anova(), gly_ancova(), gly_kruskal(), gly_ttest(), gly_wilcox(), and gly_limma().

Usage

filter_sig_vars(
  exp,
  res,
  p_adj_cutoff = 0.05,
  p_val_cutoff = NULL,
  fc_cutoff = NULL,
  ...
)

# S3 method for class 'glystats_anova_res'
filter_sig_vars(
  exp,
  res,
  p_adj_cutoff = 0.05,
  p_val_cutoff = NULL,
  fc_cutoff = NULL,
  on = "main_test",
  comparison = NULL,
  ...
)

# S3 method for class 'glystats_ancova_res'
filter_sig_vars(
  exp,
  res,
  p_adj_cutoff = 0.05,
  p_val_cutoff = NULL,
  fc_cutoff = NULL,
  on = "main_test",
  comparison = NULL,
  ...
)

# S3 method for class 'glystats_kruskal_res'
filter_sig_vars(
  exp,
  res,
  p_adj_cutoff = 0.05,
  p_val_cutoff = NULL,
  fc_cutoff = NULL,
  on = "main_test",
  comparison = NULL,
  ...
)

# S3 method for class 'glystats_ttest_res'
filter_sig_vars(
  exp,
  res,
  p_adj_cutoff = 0.05,
  p_val_cutoff = NULL,
  fc_cutoff = NULL,
  ...
)

# S3 method for class 'glystats_wilcox_res'
filter_sig_vars(
  exp,
  res,
  p_adj_cutoff = 0.05,
  p_val_cutoff = NULL,
  fc_cutoff = NULL,
  ...
)

# S3 method for class 'glystats_limma_res'
filter_sig_vars(
  exp,
  res,
  p_adj_cutoff = 0.05,
  p_val_cutoff = NULL,
  fc_cutoff = NULL,
  comparison = NULL,
  ...
)

Arguments

exp

An glyexp::experiment(). Please use the same experiment used to generate the DEA result.

res

A glystats result object from a glystats DEA function.

p_adj_cutoff

The threshold for p-adjusted values. Default is 0.05.

p_val_cutoff

The threshold for p-values. We don't recommend using this. Default is NULL. If you insist to use it, please set p_adj_cutoff to NULL.

fc_cutoff

The threshold for fold changes. Only positive value is needed. For example, 2 means fold change > 2 or < 1/2. Default is 2 for glycoproteomics data and NULL for others.

...

Additional arguments passed to methods. See the method-specific documentation for details.

on

(For gly_anova() and gly_kruskal() results only) "main_test" or "post_hoc_test". Should the filter be applied on the main test results or the post-hoc test results? Default is "main_test". If "post_hoc_test", please set a comparison value.

comparison

(For gly_anova(), gly_kruskal(), and gly_limma() results only) Specifies which comparison to filter on. A string with the format "group1_vs_group2". For gly_anova() and gly_kruskal() results, comparison is only used when on is "post_hoc_test". If not provided, filtering will be performed on the main test results for gly_anova() and gly_kruskal(), and variables will be kept if they are significant in any comparison for gly_limma().

Value

An new glyexp::experiment() object.

Examples

library(glyexp)
library(glyclean)
#> 
#> Attaching package: ‘glyclean’
#> The following object is masked from ‘package:stats’:
#> 
#>     aggregate

exp <- auto_clean(real_experiment) |>
  glyexp::slice_head_var(n = 10)
#> 
#> ── Normalizing data ──
#> 
#>  No QC samples found. Using default normalization method based on experiment type.
#>  Experiment type is "glycoproteomics". Using `normalize_median()`.
#>  Normalization completed.
#> 
#> ── Removing variables with too many missing values ──
#> 
#>  No QC samples found. Using all samples.
#>  Applying preset "discovery"...
#>  Total removed: 24 (0.56%) variables.
#>  Variable removal completed.
#> 
#> ── Imputing missing values ──
#> 
#>  No QC samples found. Using default imputation method based on sample size.
#>  Sample size <= 30, using `impute_sample_min()`.
#>  Imputation completed.
#> 
#> ── Aggregating data ──
#> 
#>  Aggregating to "gfs" level
#>  Aggregation completed.
#> 
#> ── Normalizing data again ──
#> 
#>  No QC samples found. Using default normalization method based on experiment type.
#>  Experiment type is "glycoproteomics". Using `normalize_median()`.
#>  Normalization completed.
#> 
#> ── Correcting batch effects ──
#> 
#>  Batch column  not found in sample_info. Skipping batch correction.
#>  Batch correction completed.
res <- gly_anova(exp)
#>  Number of groups: 4
#>  Groups: "H", "M", "Y", and "C"
#>  Pairwise comparisons will be performed, with levels coming first as reference groups.
sig_exp <- filter_sig_vars(exp, res)