R/anglemanise_utils.R
select_genes.Rd
Selects genes from an anglemania_object-class
based on specified
thresholds for the absolute mean z-score and signal-to-noise ratio
(SNR) z-score. It updates the integration_genes
slot of the
anglemania_object
with the selected genes and associated
information.
select_genes(
angl,
zscore_mean_threshold = 2,
zscore_sn_threshold = 2,
max_n_genes = NULL
)
An anglemania_object
containing statistical
matrices such as mean z-scores and SNR z-scores.
Numeric value specifying the threshold for the absolute mean z-score. Default is 2.
Numeric value specifying the threshold for the SNR z-score. Default is 2.
Integer specifying the maximum number of genes to select.
If NULL
, all genes that pass the thresholds are used. Default is
NULL
.
The input anglemania_object
with the
integration_genes
slot updated to include the selected genes and
their statistical information.
The function performs the following steps:
Checks if the input object is of class anglemania_object-class
.
If max_n_genes
is not specified, it uses all genes that pass
the thresholds.
Identifies gene pairs where both the mean z-score and SNR z-score exceed the specified thresholds.
If no gene pairs meet the criteria, it adjusts the thresholds to the 99th percentile values of the corresponding statistics and re-selects.
Extracts unique genes from the selected gene pairs using
extract_rows_for_unique_genes
.
Updates the integration_genes
slot of the
anglemania_object
with the selected genes and their statistics.
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
#> Extracting count matrices...
#> Filtering each batch to at least 1 cells per gene...
#> Using the intersection of filtered genes from all batches...
#> Number of genes in intersected set: 300
#>
| | 0 % elapsed=00s
|==================================================| 100% elapsed=00s, remaining~00s
angl <- anglemania(angl)
#> Computing angles and transforming to z-scores...
#>
| | 0 % elapsed=00s
|========================= | 50% elapsed=00s, remaining~00s
|==================================================| 100% elapsed=00s, remaining~00s
#> Computing statistics...
#> Weighting matrix_list...
#> Calculating mean...
#> Calculating sds...
#> Filtering features...
#> [1] "Selected 36 genes for integration."
angl <- select_genes(angl,
zscore_mean_threshold = 2.5,
zscore_sn_threshold = 2.5,
max_n_genes = 2000)
#> [1] "Selected 36 genes for integration."
anglemania_genes <- get_anglemania_genes(angl)
# View the selected genes and use for integration