Skip to contents

Constructs a matrix of gene-gene relationships based on distance metrics.

Usage

extract_angles(x_mat, method = "pearson")

Arguments

x_mat

An FBM object containing raw gene expression data, where rows correspond to genes and columns to samples. The data will be normalized and scaled within the function.

method

A character string specifying the method to compute the gene-gene relationships. Options are:

  • "pearson" (default): Computes the cosine angle between genes.

  • "spearman": Computes the Spearman rank correlation coefficient by rank-transforming the data before computing the correlation.

  • "diem": Computes the Dimension Insensitive Euclidean Metric between genes. Note that this is done in the factorise function.

Value

An FBM object containing the gene-gene correlation matrix. The matrix is square with dimensions equal to the number of genes and contains the pairwise correlations between genes. The diagonal elements are set to NA.

Details

The function returns the gene-gene angle matrix as an FBM object.

Examples


mat <- matrix(
 c(
     5, 3, 0, 0,
     0, 0, 0, 3,
     2, 1, 3, 4,
     0, 0, 1, 0,
     1, 2, 1, 2,
     3, 4, 3, 4
   ),
   nrow = 6, # 6 genes
   ncol = 4, # 4 cells
   byrow = TRUE
)

mat <- bigstatsr::FBM(nrow = nrow(mat), ncol = ncol(mat), init = mat)

angle_mat <- extract_angles(mat)
angle_mat[]
#>             [,1]       [,2]       [,3]       [,4]        [,5]       [,6]
#> [1,]          NA -0.5769815 -0.8855700 -0.5769815 -0.08297916 -0.1231654
#> [2,] -0.57698151         NA  0.4087286 -0.3333333  0.23569456 -0.3202460
#> [3,] -0.88557002  0.4087286         NA  0.6315084 -0.38905020 -0.2197208
#> [4,] -0.57698151 -0.3333333  0.6315084         NA -0.17969901  0.4260250
#> [5,] -0.08297916  0.2356946 -0.3890502 -0.1796990          NA  0.7427533
#> [6,] -0.12316543 -0.3202460 -0.2197208  0.4260250  0.74275335         NA