R/calculateCramerPValue.R
calculateCramerPValue.Rd
This function performs the Cramer test for comparing multivariate empirical cumulative distribution functions (ECDFs) between two samples.
calculateCramerPValue(
reference_data,
query_data = NULL,
ref_cell_type_col,
query_cell_type_col = NULL,
cell_types = NULL,
pc_subset = 1:5,
assay_name = "logcounts"
)
A SingleCellExperiment
object containing numeric expression matrix for the reference cells.
A SingleCellExperiment
object containing numeric expression matrix for the query cells.
If NULL, the PC scores are regressed against the cell types of the reference data.
The column name in the colData
of reference_data
that identifies the cell types.
The column name in the colData
of query_data
that identifies the cell types.
A character vector specifying the cell types to include in the plot. If NULL, all cell types are included.
A numeric vector specifying which principal components to include in the plot. Default is PC1 to PC5.
Name of the assay on which to perform computations. Default is "logcounts".
A named vector of p-values from the Cramer test for each cell type.
The function performs the following steps:
Projects the data into the PCA space.
Subsets the data to the specified cell types and principal components.
Performs the Cramer test for each cell type using the cramer.test
function in the cramer
package.
Baringhaus, L., & Franz, C. (2004). "On a new multivariate two-sample test". Journal of Multivariate Analysis, 88(1), 190-206.
# Load data
data("reference_data")
data("query_data")
# Plot the PC data (with query data)
cramer_test <- calculateCramerPValue(reference_data = reference_data,
query_data = query_data,
ref_cell_type_col = "expert_annotation",
query_cell_type_col = "SingleR_annotation",
cell_types = c("CD4", "CD8", "B_and_plasma", "Myeloid"),
pc_subset = 1:5)
cramer_test
#> CD4 CD8 B_and_plasma Myeloid
#> 0.0000000 0.0000000 0.1418581 0.4375624