match_cells: Match Cells in Reference Data with Those in Simulation Data

View source: R/match_cells.R

match_cellsR Documentation

Match Cells in Reference Data with Those in Simulation Data

Description

This function is used to match cells in reference data with those in simulation data. Each cell in reference data corresponds to only one cell in simulation data and the correlation between them is also calculated and returned.

Usage

match_cells(ref_data, sim_data, t = FALSE, algorithm = "Improved_Hungarian")

Arguments

ref_data, sim_data

A matrix or dynwrap object created by wrap_expression. Note that every row represents a cell and every column represents a gene. Simulation and reference data must have the same size.

t

Whether the data matrix should be transposed when performing the PCA.

algorithm

Optional. Which algorithm used for matching cells in simulated and real data. Improved_Hungarian (default), Hungarian.

Value

A list contains the correlation matrix and a dataframe of the paired cells in reference and simulation data.

Examples

# Generate a reference data
set.seed(1)
ref_data <- matrix(rpois(n = 2500, lambda = 2), nrow = 50)
rownames(ref_data) <- paste0("cell_", 1:ncol(ref_data))
colnames(ref_data) <- paste0("gene_", 1:nrow(ref_data))
# Generate a simulation data
set.seed(1)
sim_data <- matrix(rpois(n = 2500, lambda = 1.5), nrow = 50)
rownames(sim_data) <- paste0("fcell_", 1:ncol(sim_data))
colnames(sim_data) <- paste0("fgene_", 1:nrow(sim_data))
# Match cells
match_result <- match_cells(ref_data = ref_data, sim_data)

duohongrui/simutils documentation built on March 12, 2024, 8:40 p.m.