Using estimated k-mer level affinities returned by kmerFit, this function tests for differential specificities across conditions for each k-mer separately. The call to kmerFit must have been made with contrasts = TRUE. Here, shared specificity is defined as a common ordering of k-mer affinities across conditions. Therefore, differential specificity is tested by assessing the statistical significance of deviations from a common trend of k-mer affinities observed between conditions.

For each condition, the common trend is estimated by fitting either a LOESS curve or B-spline smoother to the corresponding columns of the "contrastAverage" (x) and "contrastDifference" (y) assays of the input SummarizedExperiment object. If useref = TRUE, instead of the "contrastAverage", the "affinityEstimate" values of the reference condition are used as the x-axis. The difference between the observed differential affinity and the estimated trend is taken as the estimate of differential specificity.

When method = "subset" (default), two trends are fit using weighted orinary linear regression and a B-spline basis. The two trends are meant to capture any differential specificities that may be smoothed out by fitting a single trend to the data. The two trends are identified by first splitting the data along the x-axis into 20 equal-width bins and fitting a two-component normal mixture to the "contrastDifference" values of k-mers in each bin. The upper and lower components in each cluster are grouped across the bins. The two trends are fit separately by weighing each k-mer based on the likelihood of belonging to either the upper or lower clusters. Finally, a single trend is selected to be used for testing by taking the trend which minimizes the mean residual across the top 50% of k-mers.

After estimating k-mer level affinities using probe-set aggregate, this function tests for differential specificity between conditions.

kmerTestSpecificity(
  se,
  method = c("subset", "bs", "loess"),
  span = 0.05,
  useref = TRUE,
  ...
)

Arguments

se

SummarizedExperiment of k-mer results from kmerFit.

method

string value specifying method to use for fitting specificity trend. Must be one of "subset", "bs", or "loess". (default = "subset")

span

span parameter to be passed to limma::loessFit. Only used when method = "loess". (default = 0.05)

useref

logical value whether to fit specificity trend as function of reference intensities rather than the average of reference and variant intensities. Must be TRUE if method = "subset". (defualt = TRUE)

...

other parameters to pass to limma::loessFit.

Value

SummarizedExperiment of k-mer differential specificity results with the following assays:

  • "contrastAverage": input k-mer average affinities.

  • "contrastDifference": input k-mer differential affinities.

  • "contrastVariance": input k-mer differential affinity variances.

  • "contrastFit": estimated specificity trend.

  • "contrastResidual": residual from estimated specificity trend (contrastDifference - contrastFit).

  • "specificityZ": studentized differences (contrastResidual / sqrt(contrastVariance)).

  • "specificityP": two-sided tail p-values for studentized differences.

  • "specificityQ": FDR-controlling Benjamini-Hochberg adjusted p-values.