Filters the data to keep only transcripts/genes that are consistently expressed above a threshold across samples. This is a filtering version of identify_abundant() that removes low-abundance features instead of just marking them.

This function is similar to identify_abundant() but instead of adding an .abundant column, it filters out the low-abundance features directly.

keep_abundant(
  .data,
  abundance = assayNames(.data)[1],
  design = NULL,
  formula_design = NULL,
  minimum_counts = 10,
  minimum_proportion = 0.7,
  minimum_count_per_million = NULL,
  factor_of_interest = NULL,
  ...,
  .abundance = NULL
)

Arguments

.data

A `tbl` or `SummarizedExperiment` object containing transcript/gene abundance data

abundance

The name of the transcript/gene abundance column (character, preferred)

design

A design matrix for more complex experimental designs. If provided, this is passed to filterByExpr instead of factor_of_interest.

formula_design

A formula for creating the design matrix

minimum_counts

The minimum count threshold for a feature to be considered abundant

minimum_proportion

The minimum proportion of samples in which a feature must be abundant

minimum_count_per_million

The minimum count per million threshold

factor_of_interest

The name of the column containing groups/conditions for filtering. DEPRECATED: Use 'design' or 'formula_design' instead.

...

Further arguments.

.abundance

DEPRECATED. The name of the transcript/gene abundance column (symbolic, for backward compatibility)

Value

Returns a filtered version of the input object containing only the features that passed the abundance threshold criteria.

Returns a filtered version of the input object containing only the features that passed the abundance threshold criteria.

Details

Filter to keep only abundant transcripts/genes

[Questioning]

This function uses edgeR's filterByExpr() function to identify and keep consistently expressed features. A feature is kept if it has CPM > minimum_counts in at least minimum_proportion of samples in at least one experimental group (defined by factor_of_interest or design).

This function is similar to identify_abundant() but instead of adding an .abundant column, it filters out the low-abundance features directly.

References

McCarthy, D. J., Chen, Y., & Smyth, G. K. (2012). Differential expression analysis of multifactor RNA-Seq experiments with respect to biological variation. Nucleic Acids Research, 40(10), 4288-4297. DOI: 10.1093/bioinformatics/btp616

Examples

## Load airway dataset for examples

  data('airway', package = 'airway')
  # Ensure a 'condition' column exists for examples expecting it

    SummarizedExperiment::colData(airway)$condition <- SummarizedExperiment::colData(airway)$dex


# Basic usage
airway |> keep_abundant()
#> Warning: All samples appear to belong to the same group.
#> # A SummarizedExperiment-tibble abstraction: Features=14224 | Samples=8 | 
#> #   Assays=counts
#> #                                 |----------------- COVARIATES ---------------|
#>        .feature  .sample | counts | SampleName cell  dex   albut Run   avgLength
#>        <chr>     <chr>   | <chr>  | <fct>      <fct> <fct> <fct> <fct> <chr>    
#> 1      ENSG0000… SRR103… | 679    | GSM1275862 N613… untrt untrt SRR1… 126      
#> 2      ENSG0000… SRR103… | 467    | GSM1275862 N613… untrt untrt SRR1… 126      
#> 3      ENSG0000… SRR103… | 260    | GSM1275862 N613… untrt untrt SRR1… 126      
#> 4      ENSG0000… SRR103… | 60     | GSM1275862 N613… untrt untrt SRR1… 126      
#> 5      ENSG0000… SRR103… | 3251   | GSM1275862 N613… untrt untrt SRR1… 126      
#>        --------  ------- - ------ - ---------- ----  ---   ----- ---   ---------
#> 113788 ENSG0000… SRR103… | 34     | GSM1275875 N061… trt   untrt SRR1… 98       
#> 113789 ENSG0000… SRR103… | 82     | GSM1275875 N061… trt   untrt SRR1… 98       
#> 113790 ENSG0000… SRR103… | 17     | GSM1275875 N061… trt   untrt SRR1… 98       
#> 113791 ENSG0000… SRR103… | 12     | GSM1275875 N061… trt   untrt SRR1… 98       
#> 113792 ENSG0000… SRR103… | 11     | GSM1275875 N061… trt   untrt SRR1… 98       
#> # ℹ 16 more variables: Experiment <fct>, Sample <fct>, BioSample <fct>,
#> #   condition <fct>, `|` <|>, gene_id <chr>, gene_name <chr>, entrezid <chr>,
#> #   gene_biotype <chr>, gene_seq_start <chr>, gene_seq_end <chr>,
#> #   seq_name <chr>, seq_strand <chr>, seq_coord_system <chr>, symbol <chr>,
#> #   .abundant <chr>

# With custom thresholds
airway |> keep_abundant(
  minimum_counts = 5,
  minimum_proportion = 0.5
)
#> Warning: All samples appear to belong to the same group.
#> # A SummarizedExperiment-tibble abstraction: Features=15436 | Samples=8 | 
#> #   Assays=counts
#> #                                 |----------------- COVARIATES ---------------|
#>        .feature  .sample | counts | SampleName cell  dex   albut Run   avgLength
#>        <chr>     <chr>   | <chr>  | <fct>      <fct> <fct> <fct> <fct> <chr>    
#> 1      ENSG0000… SRR103… | 679    | GSM1275862 N613… untrt untrt SRR1… 126      
#> 2      ENSG0000… SRR103… | 467    | GSM1275862 N613… untrt untrt SRR1… 126      
#> 3      ENSG0000… SRR103… | 260    | GSM1275862 N613… untrt untrt SRR1… 126      
#> 4      ENSG0000… SRR103… | 60     | GSM1275862 N613… untrt untrt SRR1… 126      
#> 5      ENSG0000… SRR103… | 3251   | GSM1275862 N613… untrt untrt SRR1… 126      
#>        --------  ------- - ------ - ---------- ----  ---   ----- ---   ---------
#> 123484 ENSG0000… SRR103… | 12     | GSM1275875 N061… trt   untrt SRR1… 98       
#> 123485 ENSG0000… SRR103… | 10     | GSM1275875 N061… trt   untrt SRR1… 98       
#> 123486 ENSG0000… SRR103… | 11     | GSM1275875 N061… trt   untrt SRR1… 98       
#> 123487 ENSG0000… SRR103… | 6      | GSM1275875 N061… trt   untrt SRR1… 98       
#> 123488 ENSG0000… SRR103… | 11     | GSM1275875 N061… trt   untrt SRR1… 98       
#> # ℹ 16 more variables: Experiment <fct>, Sample <fct>, BioSample <fct>,
#> #   condition <fct>, `|` <|>, gene_id <chr>, gene_name <chr>, entrezid <chr>,
#> #   gene_biotype <chr>, gene_seq_start <chr>, gene_seq_end <chr>,
#> #   seq_name <chr>, seq_strand <chr>, seq_coord_system <chr>, symbol <chr>,
#> #   .abundant <chr>

# Using a factor of interest
airway |> keep_abundant(factor_of_interest = condition)
#> Warning: The `factor_of_interest` argument of `keep_abundant()` is deprecated as of
#> tidybulk 2.0.0.
#>  Please use the `formula_design` argument instead.
#>  The argument 'factor_of_interest' is deprecated and will be removed in a
#>   future release. Please use the 'design' or 'formula_design' argument instead.
#> # A SummarizedExperiment-tibble abstraction: Features=15926 | Samples=8 | 
#> #   Assays=counts
#> #                                 |----------------- COVARIATES ---------------|
#>        .feature  .sample | counts | SampleName cell  dex   albut Run   avgLength
#>        <chr>     <chr>   | <chr>  | <fct>      <fct> <fct> <fct> <fct> <chr>    
#> 1      ENSG0000… SRR103… | 679    | GSM1275862 N613… untrt untrt SRR1… 126      
#> 2      ENSG0000… SRR103… | 467    | GSM1275862 N613… untrt untrt SRR1… 126      
#> 3      ENSG0000… SRR103… | 260    | GSM1275862 N613… untrt untrt SRR1… 126      
#> 4      ENSG0000… SRR103… | 60     | GSM1275862 N613… untrt untrt SRR1… 126      
#> 5      ENSG0000… SRR103… | 3251   | GSM1275862 N613… untrt untrt SRR1… 126      
#>        --------  ------- - ------ - ---------- ----  ---   ----- ---   ---------
#> 127404 ENSG0000… SRR103… | 17     | GSM1275875 N061… trt   untrt SRR1… 98       
#> 127405 ENSG0000… SRR103… | 12     | GSM1275875 N061… trt   untrt SRR1… 98       
#> 127406 ENSG0000… SRR103… | 10     | GSM1275875 N061… trt   untrt SRR1… 98       
#> 127407 ENSG0000… SRR103… | 11     | GSM1275875 N061… trt   untrt SRR1… 98       
#> 127408 ENSG0000… SRR103… | 11     | GSM1275875 N061… trt   untrt SRR1… 98       
#> # ℹ 16 more variables: Experiment <fct>, Sample <fct>, BioSample <fct>,
#> #   condition <fct>, `|` <|>, gene_id <chr>, gene_name <chr>, entrezid <chr>,
#> #   gene_biotype <chr>, gene_seq_start <chr>, gene_seq_end <chr>,
#> #   seq_name <chr>, seq_strand <chr>, seq_coord_system <chr>, symbol <chr>,
#> #   .abundant <chr>