Skip to contents

Use a Fisher exact test to calculate differential abundance of each sequence in two samples and reports the log2 transformed fold change, P value and adjusted P value.

Usage

differentialAbundance(
  study_table,
  repertoire_ids = NULL,
  abundance = "duplicate_count",
  type = "junction_aa",
  q = 1,
  zero = 1,
  parallel = FALSE
)

Arguments

study_table

A tibble consisting of antigen receptor sequences imported by the LymphoSeq2 function readImmunoSeq().

repertoire_ids

A character vector of two repertoire_ids in study_table to be compared. If NULL (the default), the first two repertoire_ids from study_table will be used.

abundance

The input value for the Fisher exact test. "duplicate_count" is the default value and is also the recommended value.

type

A character vector indicating whether "junction_aa" (the default) or "junction" sequences should be used. If "junction_aa" is specified, then run productiveSeq() first.

q

A numeric value between 0.0 and 1.0 indicating the threshold Holms adjusted P value (also known as the false discovery rate or q value) to subset the results with. Any sequences with a q value greater than this value will not be shown.

zero

A numeric value to set all zero values to when calculating the log2 transformed fold change between samples 1 and 2. This does not apply to the p and q value calculations.

parallel

A Boolean value

  • TRUE : Enable parallel processing

  • FALSE (the default): Disable parallel processing

Value

Returns a data frame with columns corresponding to the frequency of the abundance measure in samples 1 and 2, the P value, Q value (Holms adjusted P value, also known as the false discovery rate), and log2 transformed fold change.

Examples

file_path <- system.file("extdata", "TCRB_sequencing", package = "LymphoSeq2")
study_table <- LymphoSeq2::readImmunoSeq(path = file_path, threads = 1) 
study_table <- LymphoSeq2::topSeqs(study_table, top = 100)
amino_table <- LymphoSeq2::productiveSeq(study_table = study_table, 
  aggregate = "junction_aa")
LymphoSeq2::differentialAbundance(
  study_table = amino_table,
  repertoire_ids = c("TRB_Unsorted_949", "TRB_Unsorted_1320"),
  type = "junction_aa", q = 0.01, zero = 0.001
)
#> # A tibble: 107 × 6
#>    junction_aa     TRB_Unsorted_949 TRB_Unsorted_1320        p        q    l2fc
#>    <chr>                      <dbl>             <dbl>    <dbl>    <dbl>   <dbl>
#>  1 CAIKMETPNGEQYF                29               326 1.14e- 6 1.14e- 6   -3.49
#>  2 CAISEGQGVKPQHF                 0               167 1.09e- 2 1.09e- 2 -Inf   
#>  3 CAISESGVLNEKLFF               13               150 1.20e- 3 1.20e- 3   -3.53
#>  4 CASDGGFRNTIYF                 17               387 1.40e- 1 1.40e- 1   -4.51
#>  5 CASKPPGQGGYGYTF                0               173 1.12e- 2 1.12e- 2 -Inf   
#>  6 CASNRVPEETQYF                  0               127 5.75e- 2 5.75e- 2 -Inf   
#>  7 CASNSKADSTDTQYF               21              1325 1.52e- 3 1.52e- 3   -5.98
#>  8 CASRDGQGSGNTIYF               48               358 6.73e-16 6.73e-16   -2.90
#>  9 CASREDRGSSPLHF                 0               147 2.45e- 2 2.45e- 2 -Inf   
#> 10 CASRLGPGAGDEAFF               12               619 1.26e- 1 1.26e- 1   -5.69
#> # ℹ 97 more rows