scale_abundance() takes as input A `tbl` (with at least three columns for sample, feature and transcript abundance) or `SummarizedExperiment` (more convenient if abstracted to tibble with library(tidySummarizedExperiment)) and Scales transcript abundance compansating for sequencing depth (e.g., with TMM algorithm, Robinson and Oshlack doi.org/10.1186/gb-2010-11-3-r25).

scale_abundance(
  .data,
  abundance = assayNames(.data)[1],
  method = "TMM",
  reference_sample = NULL,
  .subset_for_scaling = NULL,
  suffix = "_scaled",
  reference_selection_function = NULL,
  ...,
  .abundance = NULL
)

# S4 method for class 'SummarizedExperiment'
scale_abundance(
  .data,
  abundance = assayNames(.data)[1],
  method = "TMM",
  reference_sample = NULL,
  .subset_for_scaling = NULL,
  suffix = "_scaled",
  reference_selection_function = NULL,
  ...,
  .abundance = NULL
)

# S4 method for class 'RangedSummarizedExperiment'
scale_abundance(
  .data,
  abundance = assayNames(.data)[1],
  method = "TMM",
  reference_sample = NULL,
  .subset_for_scaling = NULL,
  suffix = "_scaled",
  reference_selection_function = NULL,
  ...,
  .abundance = NULL
)

Arguments

.data

A `tbl` (with at least three columns for sample, feature and transcript abundance) or `SummarizedExperiment` (more convenient if abstracted to tibble with library(tidySummarizedExperiment))

abundance

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

method

A character string. The scaling method passed to the back-end function (i.e., edgeR::normLibSizes; "TMM","TMMwsp","RLE","upperquartile")

reference_sample

A character string. The name of the reference sample. If NULL the sample with highest total read count will be selected as reference.

.subset_for_scaling

A gene-wise quosure condition. This will be used to filter rows (features/genes) of the dataset. For example

suffix

A character string to append to the scaled abundance column name. Default is "_scaled".

reference_selection_function

DEPRECATED. please use reference_sample.

...

Further arguments.

.abundance

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

Value

A tbl object with additional columns with scaled data as `<NAME OF COUNT COLUMN>_scaled`

A `SummarizedExperiment` object

A `SummarizedExperiment` object

Details

`r lifecycle::badge("maturing")`

Scales transcript abundance compensating for sequencing depth (e.g., with TMM algorithm, Robinson and Oshlack doi.org/10.1186/gb-2010-11-3-r25). Lowly transcribed transcripts/genes (defined with minimum_counts and minimum_proportion parameters) are filtered out from the scaling procedure. The scaling inference is then applied back to all unfiltered data.

Underlying method edgeR::normLibSizes(.data, method = c("TMM","TMMwsp","RLE","upperquartile"))

References

Mangiola, S., Molania, R., Dong, R., Doyle, M. A., & Papenfuss, A. T. (2021). tidybulk: an R tidy framework for modular transcriptomic data analysis. Genome Biology, 22(1), 42. doi:10.1186/s13059-020-02233-7

Robinson, M. D., & Oshlack, A. (2010). A scaling normalization method for differential expression analysis of RNA-seq data. Genome Biology, 11(3), R25. doi:10.1186/gb-2010-11-3-r25

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




 airway |>
   identify_abundant() |>
   scale_abundance()
#> Warning: All samples appear to belong to the same group.
#> tidybulk says: the sample with largest library size SRR1039517 was chosen as reference for scaling
#> # A SummarizedExperiment-tibble abstraction: Features=63677 | Samples=8 | 
#> #   Assays=counts, counts_scaled
#> #                                                 |--------- COVARIATES -------|
#>        .feature    .sample | counts counts_scaled | SampleName cell  dex   albut
#>        <chr>       <chr>   | <chr>  <chr>         | <fct>      <fct> <fct> <fct>
#> 1      ENSG000000… SRR103… | 679    939.94231049… | GSM1275862 N613… untrt untrt
#> 2      ENSG000000… SRR103… | 0      0             | GSM1275862 N613… untrt untrt
#> 3      ENSG000000… SRR103… | 467    646.46989543… | GSM1275862 N613… untrt untrt
#> 4      ENSG000000… SRR103… | 260    359.91899960… | GSM1275862 N613… untrt untrt
#> 5      ENSG000000… SRR103… | 60     83.058230676… | GSM1275862 N613… untrt untrt
#>        --------    ------- - ------ ------------- - ---------- ----  ---   -----
#> 509412 ENSG000002… SRR103… | 0      0             | GSM1275875 N061… trt   untrt
#> 509413 ENSG000002… SRR103… | 0      0             | GSM1275875 N061… trt   untrt
#> 509414 ENSG000002… SRR103… | 0      0             | GSM1275875 N061… trt   untrt
#> 509415 ENSG000002… SRR103… | 0      0             | GSM1275875 N061… trt   untrt
#> 509416 ENSG000002… SRR103… | 0      0             | GSM1275875 N061… trt   untrt
#> # ℹ 20 more variables: Run <fct>, avgLength <chr>, Experiment <fct>,
#> #   Sample <fct>, BioSample <fct>, condition <fct>, TMM <chr>,
#> #   multiplier <chr>, `|` <|>, 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>