apl_score: Find rows most highly associated with a condition

Description Usage Arguments Details Value Examples

View source: R/apl.R

Description

Ranks rows by a calculated score which balances the association of the row with the condition and how associated it is with other conditions.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
apl_score(
  caobj,
  mat,
  dims = caobj@dims,
  group = caobj@group,
  reps = 10,
  quant = 0.99,
  python = TRUE,
  store_perm = TRUE
)

Arguments

caobj

A "cacomp" object with principal row coordinates and standard column coordinates calculated.

mat

A numeric matrix. For sequencing a count matrix, gene expression values with genes in rows and samples/cells in columns. Should contain row and column names.

dims

Integer. Number of CA dimensions to retain. Needs to be the same as in caobj!

group

Vector of indices of the columns to calculate centroid/x-axis direction.

reps

Integer. Number of permutations to perform. Default = 10.

quant

Numeric. Single number between 0 and 1 indicating the quantile used to calculate the cutoff. Default 0.99.

python

A logical value indicating whether to use singular-value decomposition from the python package torch.

store_perm

Logical. Whether permuted data should be stored in the CA object. This implementation dramatically speeds up computation compared to 'svd()' in R.

Details

The score is calculated by permuting the values of each row to determine the cutoff angle of the 99

S_{alpha}(x,y)=x-\frac{y}{\tanĪ±}

By default the permutation is repeated 10 times, but for very large matrices this can be reduced. If store_perm is TRUE the permuted data is stored in the cacomp object and can be used for future scoring.

Value

Returns the input "cacomp" object with "APL_score" component added. APL_score contains a data frame with ranked rows, their score and their original row number.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
set.seed(1234)

# Simulate counts
cnts <- mapply(function(x){rpois(n = 500, lambda = x)}, x = sample(1:20, 50, replace = TRUE))
rownames(cnts) <- paste0("gene_", 1:nrow(cnts))
colnames(cnts) <- paste0("cell_", 1:ncol(cnts))

# Run correspondence analysis.
ca <- cacomp(obj = cnts, princ_coords = 3)

# Calculate APL coordinates:
ca <- apl_coords(ca, group = 1:10)

# Rank genes by S-alpha score
ca <- apl_score(ca, mat = cnts)

elagralinska/APLpackage documentation built on Dec. 20, 2021, 4:15 a.m.