run_cacomp: Internal function for 'cacomp'

Description Usage Arguments Details Value References

View source: R/CA.R

Description

'run_cacomp' performs correspondence analysis on a matrix and returns the transformed data.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
run_cacomp(
  obj,
  coords = TRUE,
  princ_coords = 3,
  python = FALSE,
  dims = NULL,
  top = NULL,
  inertia = TRUE,
  rm_zeros = TRUE,
  ...
)

Arguments

obj

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

coords

Logical. Indicates whether CA standard coordinates should be calculated. Default TRUE

princ_coords

Integer. Number indicating whether principal coordinates should be calculated for the rows (=1), columns (=2), both (=3) or none (=0). Default 1.

python

A logical value indicating whether to use singular-value decomposition from the python package torch. This implementation dramatically speeds up computation compared to 'svd()' in R.

dims

Integer. Number of CA dimensions to retain. Default NULL (keeps all dimensions).

top

Integer. Number of most variable rows to retain. Default NULL.

inertia

Logical.. Whether total, row and column inertias should be calculated and returned. Default TRUE.

rm_zeros

Logical. Whether rows & cols containing only 0s should be removed. Keeping zero only rows/cols might lead to unexpected results. Default TRUE.

...

Arguments forwarded to methods.

Details

The calculation is performed according to Greenacre. Singular value decomposition can be performed either with the base R function 'svd' or preferably by the much faster pytorch implementation (python = TRUE). When working on large matrices, CA coordinates and principal coordinates should only computed when needed to save computational time.

Value

Returns a named list of class "cacomp" with components U, V and D: The results from the SVD. row_masses and col_masses: Row and columns masses. top_rows: How many of the most variable rows were retained for the analysis. tot_inertia, row_inertia and col_inertia: Only if inertia = TRUE. Total, row and column inertia respectively.

References

Greenacre, M. Correspondence Analysis in Practice, Third Edition, 2017.


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