test_differential_cellularity() 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 returns a consistent object (to the input) with additional columns for the statistics from the hypothesis test.

test_differential_cellularity(
  .data,
  .formula,
  .sample = NULL,
  .transcript = NULL,
  .abundance = NULL,
  method = "cibersort",
  reference = X_cibersort,
  significance_threshold = 0.05,
  ...
)

# S4 method for spec_tbl_df
test_differential_cellularity(
  .data,
  .formula,
  .sample = NULL,
  .transcript = NULL,
  .abundance = NULL,
  method = "cibersort",
  reference = X_cibersort,
  significance_threshold = 0.05,
  ...
)

# S4 method for tbl_df
test_differential_cellularity(
  .data,
  .formula,
  .sample = NULL,
  .transcript = NULL,
  .abundance = NULL,
  method = "cibersort",
  reference = X_cibersort,
  significance_threshold = 0.05,
  ...
)

# S4 method for tidybulk
test_differential_cellularity(
  .data,
  .formula,
  .sample = NULL,
  .transcript = NULL,
  .abundance = NULL,
  method = "cibersort",
  reference = X_cibersort,
  significance_threshold = 0.05,
  ...
)

# S4 method for SummarizedExperiment
test_differential_cellularity(
  .data,
  .formula,
  .sample = NULL,
  .transcript = NULL,
  .abundance = NULL,
  method = "cibersort",
  reference = X_cibersort,
  significance_threshold = 0.05,
  ...
)

# S4 method for RangedSummarizedExperiment
test_differential_cellularity(
  .data,
  .formula,
  .sample = NULL,
  .transcript = NULL,
  .abundance = NULL,
  method = "cibersort",
  reference = X_cibersort,
  significance_threshold = 0.05,
  ...
)

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))

.formula

A formula representing the desired linear model. The formula can be of two forms: multivariable (recommended) or univariable Respectively: \"factor_of_interest ~ .\" or \". ~ factor_of_interest\". The dot represents cell-type proportions, and it is mandatory. If censored regression is desired (coxph) the formula should be of the form \"survival::Surv\(y, dead\) ~ .\"

.sample

The name of the sample column

.transcript

The name of the transcript/gene column

.abundance

The name of the transcript/gene abundance column

method

A string character. Either \"cibersort\", \"epic\" or \"llsr\". The regression method will be chosen based on being multivariable: lm or cox-regression (both on logit-transformed proportions); or univariable: beta or cox-regression (on logit-transformed proportions). See .formula for multi- or univariable choice.

reference

A data frame. The transcript/cell_type data frame of integer transcript abundance

significance_threshold

A real between 0 and 1 (usually 0.05).

...

Further parameters passed to the method deconvolve_cellularity

Value

A consistent object (to the input) with additional columns for the statistics from the hypothesis test (e.g., log fold change, p-value and false discovery rate).

A `SummarizedExperiment` object

A `SummarizedExperiment` object

Details

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

This routine applies a deconvolution method (e.g., Cibersort; DOI: 10.1038/nmeth.3337) and passes the proportions inferred into a generalised linear model (DOI:dx.doi.org/10.1007/s11749-010-0189-z) or a cox regression model (ISBN: 978-1-4757-3294-8)

Underlying method for the generalised linear model: data deconvolve_cellularity( !!.sample, !!.transcript, !!.abundance, method=method, reference = reference, action="get", ... ) [..] betareg::betareg(.my_formula, .)

Underlying method for the cox regression: data deconvolve_cellularity( !!.sample, !!.transcript, !!.abundance, method=method, reference = reference, action="get", ... ) [..] mutate(.proportion_0_corrected = .proportion_0_corrected survival::coxph(.my_formula, .)

Examples


 # Regular regression
  test_differential_cellularity(
   tidybulk::se_mini ,
      . ~ condition,
      cores = 1
  )
#> # A tibble: 22 × 7
#>    .cell_type                   cell_t…¹ estim…² estim…³ std.e…⁴ stati…⁵ p.val…⁶
#>    <chr>                        <list>     <dbl>   <dbl>   <dbl>   <dbl>   <dbl>
#>  1 cibersort.B.cells.naive      <tibble>   -2.37   1.54    1.05    1.47   0.142 
#>  2 cibersort.B.cells.memory     <tibble>   -2.75   0.821   0.962   0.853  0.393 
#>  3 cibersort.Plasma.cells       <tibble>   NA     NA      NA      NA     NA     
#>  4 cibersort.T.cells.CD8        <tibble>   NA     NA      NA      NA     NA     
#>  5 cibersort.T.cells.CD4.naive  <tibble>   NA     NA      NA      NA     NA     
#>  6 cibersort.T.cells.CD4.memor… <tibble>   -3.81   1.93    0.900   2.14   0.0323
#>  7 cibersort.T.cells.CD4.memor… <tibble>   NA     NA      NA      NA     NA     
#>  8 cibersort.T.cells.follicula… <tibble>   -6.01   0.678   0.835   0.811  0.417 
#>  9 cibersort.T.cells.regulator… <tibble>   NA     NA      NA      NA     NA     
#> 10 cibersort.T.cells.gamma.del… <tibble>   NA     NA      NA      NA     NA     
#> # … with 12 more rows, and abbreviated variable names ¹​cell_type_proportions,
#> #   ²​`estimate_(Intercept)`, ³​estimate_conditionTRUE, ⁴​std.error_conditionTRUE,
#> #   ⁵​statistic_conditionTRUE, ⁶​p.value_conditionTRUE

  # Cox regression - multiple

tidybulk::se_mini |>

  # Test
  test_differential_cellularity(
      survival::Surv(days, dead) ~ .,
      cores = 1
  )
#> Warning: Ran out of iterations and did not converge
#> # A tibble: 22 × 6
#>    .cell_type                        cell_t…¹ estimate std.e…² statistic p.value
#>    <chr>                             <list>      <dbl>   <dbl>     <dbl>   <dbl>
#>  1 cibersort.B.cells.naive           <tibble>   -0.616   3148.  -1.96e-4   1.00 
#>  2 cibersort.B.cells.memory          <tibble> -100.      2796.  -3.58e-2   0.971
#>  3 cibersort.Plasma.cells            <tibble>    0          0  NaN       NaN    
#>  4 cibersort.T.cells.CD8             <tibble>  118.      4318.   2.74e-2   0.978
#>  5 cibersort.T.cells.CD4.naive       <tibble> -164.      3555.  -4.61e-2   0.963
#>  6 cibersort.T.cells.CD4.memory.res… <tibble>   -1.93    2430.  -7.96e-4   0.999
#>  7 cibersort.T.cells.CD4.memory.act… <tibble>    0.935  13450.   6.95e-5   1.00 
#>  8 cibersort.T.cells.follicular.hel… <tibble>   13.3     5004.   2.67e-3   0.998
#>  9 cibersort.T.cells.regulatory..Tr… <tibble> -302.     49862.  -6.07e-3   0.995
#> 10 cibersort.T.cells.gamma.delta     <tibble>    0          0  NaN       NaN    
#> # … with 12 more rows, and abbreviated variable names ¹​cell_type_proportions,
#> #   ²​std.error