R/objects.R
anglemania_object-methods.Rd
This method provides a concise summary of an anglemania_object
, including
dataset and batch information, the number of intersected genes, and other
relevant details.
Retrieves the list of gene expression matrices stored in the anglemania_object
object.
Assigns a new list of gene expression matrices to the anglemania_object
.
Retrieves the dataset key used in the anglemania_object
.
Retrieves the batch key used in the anglemania_object
.
Retrieves the data frame summarizing the selected anglemania gene pairs
anglemania_object
.
Retrieves the weights assigned to each dataset or batch in the anglemania_object
Assigns new weights to the datasets or batches in the anglemania_object
.
Retrieves the list of statistical measures computed across datasets in the
anglemania_object
.
Assigns a new list of statistical measures to the anglemania_object
.
Retrieves the vector of genes that are expressed in at least the specified number of cells across all batches.
Assigns a new vector of intersected genes to the anglemania_object
.
Retrieves the list of genes selected for integration from the anglemania_object
This function adds a unique batch identifier to the metadata of a
Seurat
object by combining specified dataset and batch
keys. This is useful for distinguishing samples during integration or
analysis.
# S4 method for class 'anglemania_object'
show(object)
matrix_list(object)
# S4 method for class 'anglemania_object'
matrix_list(object)
matrix_list(object) <- value
# S4 method for class 'anglemania_object'
matrix_list(object) <- value
dataset_key(object)
# S4 method for class 'anglemania_object'
dataset_key(object)
batch_key(object)
# S4 method for class 'anglemania_object'
batch_key(object)
data_info(object)
# S4 method for class 'anglemania_object'
data_info(object)
angl_weights(object)
# S4 method for class 'anglemania_object'
angl_weights(object)
angl_weights(object) <- value
# S4 method for class 'anglemania_object'
angl_weights(object) <- value
list_stats(object)
# S4 method for class 'anglemania_object'
list_stats(object)
list_stats(object) <- value
# S4 method for class 'anglemania_object'
list_stats(object) <- value
intersect_genes(object)
# S4 method for class 'anglemania_object'
intersect_genes(object)
intersect_genes(object) <- value
# S4 method for class 'anglemania_object'
intersect_genes(object) <- value
get_anglemania_genes(object)
# S4 method for class 'anglemania_object'
get_anglemania_genes(object)
add_unique_batch_key(
object_metadata,
dataset_key = NA_character_,
batch_key,
new_unique_batch_key = "batch"
)
An anglemania_object
.
A character vector of gene names.
Metadata of a Seurat
or SingleCellExperiment object.
A character string specifying the column name in the
metadata that identifies the dataset. If NA
, only the
batch_key
is used.
A character string specifying the column name in the metadata that identifies the batch.
A character string for the new unique batch key
to be added to the metadata. Default is "batch"
.
Prints a summary to the console.
A list of FBM
objects containing gene
expression matrices.
The updated anglemania_object
.
A character string representing the dataset key.
A character string representing the batch key.
A data frame containing dataset and batch information.
A named numeric vector of weights.
The updated anglemania_object
.
A list containing statistical matrices such as mean z-scores and SNR z-scores
The updated anglemania_object
.
A character vector of intersected gene names from multiple Seurat or SingleCellExperiment Objects.
The updated anglemania_object
object.
A character vector of integration gene names.
A Seurat
object with an additional metadata
column containing the unique batch key.
show(anglemania_object)
: show anglemania_object info
matrix_list()
: Access matrix list
matrix_list(object) <- value
: set matrix list in anglemania_object
dataset_key()
: Access dataset key of anglemania_object
batch_key()
: Access batch key of anglemania_object
data_info()
: Access info of selected gene pairs
angl_weights()
: Access weights
angl_weights(object) <- value
: Set weights
list_stats()
: Access statistics of the gene-gene matrices
list_stats(object) <- value
: Set statistics of the gene-gene matrices
intersect_genes()
: Access the intersection of genes of all batches
intersect_genes(object) <- value
: Set the intersection of genes of all batches
get_anglemania_genes()
: Access the genes extracted by anglemania
add_unique_batch_key()
: Temporarily add a unique batch key
to the dataset
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."
show(angl)
#> anglemania_object
#> --------------
#> Dataset key: NA
#> Batch key: batch
#> Number of datasets: 1
#> Total number of batches: 2
#> Batches (showing first 5):
#> batch1, batch2
#> Number of intersected genes: 300
#> Intersected genes (showing first 10):
#> gene1, gene2, gene3, gene4, gene5, gene6, gene7, gene8, gene9, gene10 , ...
#> Min cells per gene: 1
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."
str(matrix_list(angl))
#> List of 2
#> $ batch1:Reference class 'FBM' [package "bigstatsr"] with 15 fields
#> ..$ extptr :<externalptr>
#> ..$ extptr_rw :<externalptr>
#> ..$ nrow : int 300
#> ..$ ncol : int 300
#> ..$ type : Named int 8
#> .. ..- attr(*, "names")= chr "double"
#> ..$ backingfile : chr "/tmp/Rtmp6wGGJH/file2002511a2e92.bk"
#> ..$ is_read_only: logi FALSE
#> ..$ address :<externalptr>
#> ..$ address_rw :<externalptr>
#> ..$ bk : chr "/tmp/Rtmp6wGGJH/file2002511a2e92.bk"
#> ..$ rds : chr "/tmp/Rtmp6wGGJH/file2002511a2e92.rds"
#> ..$ is_saved : logi FALSE
#> ..$ type_chr : chr "double"
#> ..$ type_size : int 8
#> ..$ file_size : num 720000
#> ..and 22 methods, of which 8 are possibly relevant:
#> .. add_columns, bm, bm.desc, check_dimensions, check_write_permissions,
#> .. initialize, save, show#envRefClass
#> $ batch2:Reference class 'FBM' [package "bigstatsr"] with 15 fields
#> ..$ extptr :<externalptr>
#> ..$ extptr_rw :<externalptr>
#> ..$ nrow : int 300
#> ..$ ncol : int 300
#> ..$ type : Named int 8
#> .. ..- attr(*, "names")= chr "double"
#> ..$ backingfile : chr "/tmp/Rtmp6wGGJH/file20027532b8ee.bk"
#> ..$ is_read_only: logi FALSE
#> ..$ address :<externalptr>
#> ..$ address_rw :<externalptr>
#> ..$ bk : chr "/tmp/Rtmp6wGGJH/file20027532b8ee.bk"
#> ..$ rds : chr "/tmp/Rtmp6wGGJH/file20027532b8ee.rds"
#> ..$ is_saved : logi FALSE
#> ..$ type_chr : chr "double"
#> ..$ type_size : int 8
#> ..$ file_size : num 720000
#> ..and 22 methods, of which 8 are possibly relevant:
#> .. add_columns, bm, bm.desc, check_dimensions, check_write_permissions,
#> .. initialize, save, show#envRefClass
sce <- sce_example()
angl <- create_anglemania_object(
sce,
dataset_key = "dataset",
batch_key = "batch",
min_cells_per_gene = 1
)
#> Using dataset_key: dataset
#> 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
|========================= | 50% elapsed=00s, remaining~00s
|==================================================| 100% elapsed=00s, remaining~00s
dataset_key(angl)
#> [1] "dataset"
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
batch_key(angl)
#> [1] "batch"
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
batch_key(angl)
#> [1] "batch"
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
batch_key(angl)
#> [1] "batch"
angl_weights(angl)
#> batch1 batch2
#> 0.5 0.5
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."
stats <- list_stats(angl)
str(stats)
#> List of 3
#> $ mean_zscore: num [1:300, 1:300] NA -1.474 -0.674 0.792 0.206 ...
#> $ sds_zscore : num [1:300, 1:300] NA 0.302 0.152 0.356 0.625 ...
#> $ sn_zscore : num [1:300, 1:300] NA 4.88 4.444 2.228 0.329 ...
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
intersect_genes(angl)
#> [1] "gene1" "gene2" "gene3" "gene4" "gene5" "gene6" "gene7"
#> [8] "gene8" "gene9" "gene10" "gene11" "gene12" "gene13" "gene14"
#> [15] "gene15" "gene16" "gene17" "gene18" "gene19" "gene20" "gene21"
#> [22] "gene22" "gene23" "gene24" "gene25" "gene26" "gene27" "gene28"
#> [29] "gene29" "gene30" "gene31" "gene32" "gene33" "gene34" "gene35"
#> [36] "gene36" "gene37" "gene38" "gene39" "gene40" "gene41" "gene42"
#> [43] "gene43" "gene44" "gene45" "gene46" "gene47" "gene48" "gene49"
#> [50] "gene50" "gene51" "gene52" "gene53" "gene54" "gene55" "gene56"
#> [57] "gene57" "gene58" "gene59" "gene60" "gene61" "gene62" "gene63"
#> [64] "gene64" "gene65" "gene66" "gene67" "gene68" "gene69" "gene70"
#> [71] "gene71" "gene72" "gene73" "gene74" "gene75" "gene76" "gene77"
#> [78] "gene78" "gene79" "gene80" "gene81" "gene82" "gene83" "gene84"
#> [85] "gene85" "gene86" "gene87" "gene88" "gene89" "gene90" "gene91"
#> [92] "gene92" "gene93" "gene94" "gene95" "gene96" "gene97" "gene98"
#> [99] "gene99" "gene100" "gene101" "gene102" "gene103" "gene104" "gene105"
#> [106] "gene106" "gene107" "gene108" "gene109" "gene110" "gene111" "gene112"
#> [113] "gene113" "gene114" "gene115" "gene116" "gene117" "gene118" "gene119"
#> [120] "gene120" "gene121" "gene122" "gene123" "gene124" "gene125" "gene126"
#> [127] "gene127" "gene128" "gene129" "gene130" "gene131" "gene132" "gene133"
#> [134] "gene134" "gene135" "gene136" "gene137" "gene138" "gene139" "gene140"
#> [141] "gene141" "gene142" "gene143" "gene144" "gene145" "gene146" "gene147"
#> [148] "gene148" "gene149" "gene150" "gene151" "gene152" "gene153" "gene154"
#> [155] "gene155" "gene156" "gene157" "gene158" "gene159" "gene160" "gene161"
#> [162] "gene162" "gene163" "gene164" "gene165" "gene166" "gene167" "gene168"
#> [169] "gene169" "gene170" "gene171" "gene172" "gene173" "gene174" "gene175"
#> [176] "gene176" "gene177" "gene178" "gene179" "gene180" "gene181" "gene182"
#> [183] "gene183" "gene184" "gene185" "gene186" "gene187" "gene188" "gene189"
#> [190] "gene190" "gene191" "gene192" "gene193" "gene194" "gene195" "gene196"
#> [197] "gene197" "gene198" "gene199" "gene200" "gene201" "gene202" "gene203"
#> [204] "gene204" "gene205" "gene206" "gene207" "gene208" "gene209" "gene210"
#> [211] "gene211" "gene212" "gene213" "gene214" "gene215" "gene216" "gene217"
#> [218] "gene218" "gene219" "gene220" "gene221" "gene222" "gene223" "gene224"
#> [225] "gene225" "gene226" "gene227" "gene228" "gene229" "gene230" "gene231"
#> [232] "gene232" "gene233" "gene234" "gene235" "gene236" "gene237" "gene238"
#> [239] "gene239" "gene240" "gene241" "gene242" "gene243" "gene244" "gene245"
#> [246] "gene246" "gene247" "gene248" "gene249" "gene250" "gene251" "gene252"
#> [253] "gene253" "gene254" "gene255" "gene256" "gene257" "gene258" "gene259"
#> [260] "gene260" "gene261" "gene262" "gene263" "gene264" "gene265" "gene266"
#> [267] "gene267" "gene268" "gene269" "gene270" "gene271" "gene272" "gene273"
#> [274] "gene274" "gene275" "gene276" "gene277" "gene278" "gene279" "gene280"
#> [281] "gene281" "gene282" "gene283" "gene284" "gene285" "gene286" "gene287"
#> [288] "gene288" "gene289" "gene290" "gene291" "gene292" "gene293" "gene294"
#> [295] "gene295" "gene296" "gene297" "gene298" "gene299" "gene300"
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."
# extract the genes identified by anglemania()
anglemania_genes <- get_anglemania_genes(angl)
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 <- create_anglemania_object(
sce,
dataset_key = "dataset",
batch_key = "batch",
min_cells_per_gene = 1
)
#> Using dataset_key: dataset
#> 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
|========================= | 50% elapsed=00s, remaining~00s
|==================================================| 100% elapsed=00s, remaining~00s
head(SingleCellExperiment::colData(sce))
#> DataFrame with 6 rows and 2 columns
#> batch dataset
#> <character> <character>
#> cell1 batch1 dataset1
#> cell2 batch1 dataset1
#> cell3 batch1 dataset1
#> cell4 batch1 dataset1
#> cell5 batch1 dataset1
#> cell6 batch1 dataset1