Skip to contents

Aligns ATAC cells to an scRNA-seq reference via CCA, transferring reference cell-type labels and (optionally) imputing a per-cell gene expression matrix.

Usage

add_gene_integration_matrix(proj, ...)

# S3 method for class 'MarchRProject'
add_gene_integration_matrix(
  proj,
  reference_dataset_name,
  method = c("marchr", "seurat"),
  atac_dataset_names = character(0),
  use_matrix = "GeneScoreMatrix",
  rna_assay_name = "RNA",
  reduced_dims = "IterativeLSI",
  reduction = "cca",
  group_rna,
  matrix_name = "GeneIntegrationMatrix",
  group_atac = NULL,
  group_rna_constraint = NULL,
  group_list = NULL,
  sample_cells_atac = 10000L,
  sample_cells_rna = 10000L,
  embedding_atac = NULL,
  embedding_rna = NULL,
  dims_to_use = 1:30,
  corr_cutoff = 0.75,
  scale_dims = NULL,
  n_genes = 2000L,
  knn_method = knn_hnsw,
  use_imputation = TRUE,
  transfer_params = list(),
  add_matrix_to_project = TRUE,
  scale_to = 10000,
  name_cell = "predictedCell",
  name_group = "predictedGroup",
  name_score = "predictedScore",
  genes_use = NULL,
  threads = 1L,
  seed = 1L,
  verbose = getOption("MarchR.verbose", FALSE),
  overwrite = FALSE,
  ...
)

Arguments

proj

(MarchRProject) Project holding both the ATAC datasets and the scRNA reference dataset.

...

Passed to methods.

reference_dataset_name

(character) Name of the dataset carrying the scRNA reference assay and cell-type labels.

method

(character) "marchr" (default, native BPCells anchor transfer) or "seurat" (requires Seurat). Default "marchr".

atac_dataset_names

(character) ATAC datasets to integrate. Defaults to every non-reference dataset that carries use_matrix.

use_matrix

(character) ATAC gene activity assay name. Default "GeneScoreMatrix".

rna_assay_name

(character) Reference expression assay name. Default "RNA".

reduced_dims

(character) Reduced-dimension embedding used to weight label transfer and imputation. Default "IterativeLSI".

reduction

(character) Anchor reduction. Only "cca" is available under method = "marchr". Default "cca".

group_rna

(character) Reference metadata column holding the labels to transfer.

matrix_name

(character) Output assay name. Default "GeneIntegrationMatrix".

group_atac, group_rna_constraint, group_list

(character/list; optional) Constraints pairing ATAC groups to reference groups.

sample_cells_atac, sample_cells_rna

(integer) Block / sampling caps for ATAC and RNA cells. Default 10000 each. sample_cells_atac applies to method = "seurat" only.

embedding_atac, embedding_rna

(matrix; optional) Embeddings used for density-aware blocking and sampling. embedding_atac applies to method = "seurat" only.

dims_to_use

(integer) Embedding dimensions to use. Default 1:30.

corr_cutoff

(numeric) Drop dimensions correlated with sequencing depth above this value. Default 0.75.

scale_dims

(logical; optional) Whether to z-score embedding dimensions.

n_genes

(integer) Variable features for anchor finding. Default 2000.

knn_method

(function) KNN backend for anchor finding and weighting. Default knn_hnsw. Pass knn_annoy(n_trees = 50) to match Seurat's backend. Applies to method = "marchr" only.

use_imputation

(logical) Smooth gene scores via MAGIC before integration. Default TRUE.

transfer_params

(list) Extra arguments forwarded to label transfer. method = "marchr" accepts k.weight and sd.weight only.

add_matrix_to_project

(logical) Build the imputed GeneIntegrationMatrix expression assay and attach it to each ATAC dataset. When FALSE, only the predicted-label metadata columns are written. Default TRUE.

scale_to

(numeric) Column sum target for the output matrix. Default 10000.

name_cell, name_group, name_score

(character) Output metadata column names for the matched reference cell, transferred label, and label score.

genes_use

(character; optional) Override the shared gene set.

threads

(integer) Threads for the normalization and matrix_stats() passes. Default 1L; not read from set_threads().

seed

(integer) Random seed. Default 1.

verbose

(logical) Print progress messages. Default getOption("MarchR.verbose", FALSE).

overwrite

(logical) Overwrite existing columns / assay. Default FALSE.

Value

The MarchRProject with predicted-label metadata columns and, when add_matrix_to_project = TRUE, the integrated expression assay added to each ATAC dataset.

Details

ArchR correspondence: corresponds to ArchR's addGeneIntegrationMatrix(). ArchR wraps Seurat::FindTransferAnchors() / TransferData(); method = "seurat" reproduces that path, and method = "marchr" reimplements it on BPCells primitives.

The native path differs from Seurat in three documented ways. Anchors are found once per constrained group over all cells rather than per sampled block, because the block loop existed only to bound Seurat's dense cell-by-cell cross-product. When every anchor receives an identical support score, all scores are set to 1 rather than propagating the NaN that Seurat's percentile rescaling produces. Only reduction = "cca" is implemented; "pcaproject" and "rpca" require method = "seurat".

sample_cells_atac and embedding_atac are ignored when method = "marchr".