Constructs an anglemania_object-class
from a given
Seurat
object. This includes extracting and processing
count matrices, filtering genes based on expression in a minimum number of
cells, and storing results along with dataset and batch information. It also
calculates weights for each dataset or batch based on the number of samples.
Usage
create_anglemania_object(
seurat_object,
dataset_key = NA_character_,
batch_key,
min_cells_per_gene = 1
)
Arguments
- seurat_object
A
Seurat
object containing single-cell RNA-seq data.- dataset_key
A character string indicating the column name in the Seurat object metadata that identifies the dataset to which each cell belongs. If
NA
, all cells are assumed to belong to the same dataset.- batch_key
A character string indicating the column name(s) in the Seurat object metadata that identify the batch to which each cell belongs.
- min_cells_per_gene
A numeric value indicating the minimum number of cells in which a gene must be expressed to be included in the analysis. Default is
1
.
Value
An anglemania_object-class
containing:
matrix_list
A list of filtered count matrices for each unique batch.
dataset_key
The dataset key used for splitting the Seurat object.
batch_key
The batch key used for splitting the Seurat object.
data_info
A data frame summarizing the number of samples per dataset and their weights.
weights
A numeric vector of weights for each dataset or batch based on the number of samples.
intersect_genes
A character vector of genes expressed in at least the specified number of cells across all batches.
min_cells_per_gene
The minimum number of cells per gene threshold used for filtering.
Details
The function performs the following steps:
Adds a unique batch key to the Seurat object's metadata using
add_unique_batch_key
.Extracts count matrices for each batch.
Filters genes based on the
min_cells_per_gene
threshold.Identifies intersected genes present across all batches.
Converts count matrices to
FBM
objects.Computes weights for each batch or dataset.
Examples
se <- SeuratObject::pbmc_small
angl <- create_anglemania_object(
se,
batch_key = "groups",
min_cells_per_gene = 1
)
#> No dataset_key specified.
#> Assuming that all samples belong to the same dataset and are separated by batch_key: groups
#> 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: 228
#>
| | 0 % elapsed=00s
|==================================================| 100% elapsed=00s, remaining~00s
angl
#> anglemania_object
#> --------------
#> Dataset key: NA
#> Batch key: groups
#> Number of datasets: 1
#> Total number of batches: 2
#> Batches (showing first 5):
#> g2, g1
#> Number of intersected genes: 228
#> Intersected genes (showing first 10):
#> MS4A1, CD79B, CD79A, HLA-DRA, TCL1A, HLA-DQB1, HVCN1, HLA-DMB, LTB, LINC00926 , ...
#> Min cells per gene: 1