classify_spectrum {transite} | R Documentation

## Simple spectrum classifier based on empirical thresholds

### Description

Spectra can be classified based on the aggregate spectrum classifier score. If `sum(score) == 3` spectrum considered non-random, random otherwise.

### Usage

    classify_spectrum(
      adj_r_squared,
      degree,
      slope,
      consistency_score_n,
      n_significant,
      n_bins
    )

### Arguments

`adj_r_squared` | adjusted R^2 of polynomial model, returned by score_spectrum
`degree` | degree of polynomial, returned by score_spectrum
`slope` | coefficient of the linear term of the polynomial model (spectrum "direction"), returned by score_spectrum
`consistency_score_n` | number of performed permutations before early stopping, returned by score_spectrum
`n_significant` | number of bins with statistically significant enrichment
`n_bins` | number of bins

### Value

a three-dimensional binary vector with the following components:

`coordinate 1` | `adj_r_squared >= 0.4`
`coordinate 2` | `consistency_score_n > 1000000`
`coordinate 3` | `n_significant >= floor(n_bins / 10)`

### See Also

Other SPMA functions: `run_kmer_spma()`, `run_matrix_spma()`, `score_spectrum()`, `subdivide_data()`

### Examples

    n_bins <- 40

    # random spectrum
    random_sp <- score_spectrum(runif(n = n_bins, min = -1, max = 1),
      max_model_degree = 1)
    score <- classify_spectrum(
      get_adj_r_squared(random_sp), get_model_degree(random_sp),
      get_model_slope(random_sp), get_consistency_score_n(random_sp), 0, n_bins
    )
    sum(score)

    # non-random linear spectrum with strong noise component
    signal <- seq(-1, 0.99, 2 / 40)
    noise <- rnorm(n = 40, mean = 0, sd = 0.5)
    linear_sp <- score_spectrum(signal + noise, max_model_degree = 1,
      max_cs_permutations = 100000)
    score <- classify_spectrum(
      get_adj_r_squared(linear_sp), get_model_degree(linear_sp),
      get_model_slope(linear_sp), get_consistency_score_n(linear_sp), 10, n_bins
    )
    sum(score)
    ## Not run:
    # non-random linear spectrum with weak noise component
    signal <- seq(-1, 0.99, 2 / 40)
    noise <- rnorm(n = 40, mean = 0, sd = 0.2)
    linear_sp <- score_spectrum(signal + noise, max_model_degree = 1,
      max_cs_permutations = 100000)
    score <- classify_spectrum(
      get_adj_r_squared(linear_sp), get_model_degree(linear_sp),
      get_model_slope(linear_sp), get_consistency_score_n(linear_sp), 10, n_bins
    )
    sum(score)

    ## End(Not run)

    # non-random quadratic spectrum with strong noise component
    signal <- seq(-1, 0.99, 2 / 40)^2 - 0.5
    noise <- rnorm(n = 40, mean = 0, sd = 0.2)
    quadratic_sp <- score_spectrum(signal + noise, max_model_degree = 2,
      max_cs_permutations = 100000)
    score <- classify_spectrum(
      get_adj_r_squared(quadratic_sp), get_model_degree(quadratic_sp),
      get_model_slope(quadratic_sp),
      get_consistency_score_n(quadratic_sp), 10, n_bins
    )
    sum(score)
    ## Not run:
    # non-random quadratic spectrum with weak noise component
    signal <- seq(-1, 0.99, 2 / 40)^2 - 0.5
    noise <- rnorm(n = 40, mean = 0, sd = 0.1)
    quadratic_sp <- score_spectrum(signal + noise, max_model_degree = 2)
    score <- classify_spectrum(
      get_adj_r_squared(quadratic_sp), get_model_degree(quadratic_sp),
      get_model_slope(quadratic_sp),
      get_consistency_score_n(quadratic_sp), 10, n_bins
    )
    sum(score)

    ## End(Not run)

[Package transite version 1.8.0 Index]