R/anglemania.R
anglemania.Rd
anglemania
computes critical angles between genes across all samples
provided in an anglemania_object-class
. It calculates angles,
transforms them to z-scores, computes statistical measures, and selects
genes based on specified thresholds.
anglemania(
angl,
zscore_mean_threshold = 2.5,
zscore_sn_threshold = 2.5,
max_n_genes = NULL,
method = "cosine",
permute_row_or_column = "column",
permutation_function = "sample",
prefilter_threshold = 0.5,
normalization_method = "divide_by_total_counts"
)
An anglemania_object-class
containing gene
expression data and associated metadata.
Numeric value specifying the threshold
for the mean z-score. Default is 2.5
.
Numeric value specifying the threshold for the
signal-to-noise z-score. Default is 2.5
.
Integer specifying the maximum number of genes to select.
Character string specifying the method to use for calculating
the relationship between gene pairs. Default is "cosine"
.
Other options include "diem"
(see https://bytez.com/docs/arxiv/2407.08623/paper).
Character "row" or "column", whether permutations
should be executed row-wise or column wise. Default is "column"
Character "sample" or "permute_nonzero". If
sample,then sample is used for constructing background distributions. If
permute_nonzero, then only non-zero values are permuted. Default is
"sample"
Numeric value specifying the threshold prefiltering genes. Speeds up gene selection.
Character "divide_by_total_counts" or
"scale_by_total_counts". Default is "divide_by_total_counts"
An updated anglemania_object-class
with computed
statistics and selected genes based on the specified thresholds.
This function performs the following steps:
Computes angles between genes for each sample in the
angl
using the specified method
, via
factorise
.
Transforms the angles to z-scores.
Computes statistical measures (mean z-score, signal-to-noise ratio)
across samples using get_list_stats
.
Selects genes based on specified z-score thresholds using
select_genes
.
The computed statistics and selected genes are added to the
angl
, which is returned.
# Set seed for reproducibility (optional)
sce <- sce_example()
angl <- create_anglemania_object(sce, batch_key = "batch")
#> No dataset_key specified.
#> Assuming that all samples belong to the same dataset and are separated by batch_key: batch
#> Using the intersection of filtered genes from all batches...
#> Number of genes in intersected set: 300
#> Extracting count matrices...
#> Filtering each batch to at least 1 cells per gene...
angl <- anglemania(
angl,
method = "cosine",
zscore_mean_threshold = 2,
zscore_sn_threshold = 2,
max_n_genes = 2000
)
#> Computing angles and transforming to z-scores...
#>
| | 0 % elapsed=00s
#> Creating directory "/tmp/Rtmpt97azZ/file1d433e87b06f" which didn't exist..
#>
|========================= | 50% elapsed=01s, remaining~01s
#> Creating directory "/tmp/Rtmpt97azZ/file1d4373886fa0" which didn't exist..
#>
|==================================================| 100% elapsed=01s, remaining~00s
#> Computing statistics...
#> Weighting matrix_list...
#> Calculating mean...
#> Calculating sds...
#> Filtering features...
#> Selecting features...
#> [1] "Selected 194 genes for integration."
# Access the selected genes
selected_genes <- get_anglemania_genes(angl)
selected_genes[1:10]
#> [1] "gene43" "gene207" "gene119" "gene130" "gene25" "gene209" "gene82"
#> [8] "gene114" "gene53" "gene113"