ldfDiff {CellMixS} | R Documentation

## ldfDiff

### Description

Determines cell-specific changes in the Local Density Factor before and after data integration.

### Usage

    ldfDiff(
      sce_pre_list,
      sce_combined,
      group,
      k = 75,
      dim_red = "PCA",
      dim_combined = dim_red,
      assay_pre = "logcounts",
      assay_combined = "logcounts",
      n_dim = 20,
      res_name = NULL
    )

### Arguments

`sce_pre_list` | A list of `SingleCellExperiment` objects with single datasets before integration. Names should correspond to levels in `colData(sce_combined)$group`
`sce_combined` | A `SingleCellExperiment` object with the combined data.
`group` | Character. Name of group/batch variable that separates elements of `sce_pre_list`. Needs to be one of `names(colData(sce_combined))`.
`k` | Numeric. Number of k-nearest neighbours (knn) to use.
`dim_red` | Character. Name of embeddings to use as subspace to calculate LDF before integration. Default is "PCA".
`dim_combined` | Character. Name of embeddings to use as subspace to calculate LDF after integration. Default is `dim_red`.
`assay_pre` | Character. Name of the assay to use for PCA. Only relevant if no existing 'dim_red' is provided. Must be one of `names(assays(sce_pre))`. Default is "logcounts".
`assay_combined` | Character. Name of the assay to use for PCA. Only relevant if no existing 'dim_red' is provided. Must be one of `names(assays(sce_combined))`. Default is "logcounts".
`n_dim` | Numeric. Number of PCs to include to define subspaces.
`res_name` | Character. Appendix of the result score's name (e.g. method used to combine batches). Used to specify result name for more than one run on the same input.

### Details

The ldfDiff function calculates differences in LDF for each element in `sce_pre_list` and their corresponding cells in `sce_combined` using `ldfSce`. If 'dim_red' is not defined a PCA will be calculated using `runPCA`. In this case 'assay_pre' need to refer to the data slot that shall define the subspace. Similar refer 'dim-combined' and 'assay_combined' to the integrated subspace or to the resp. "corrected" count data slot. 'k' can be used to define the level of local structure that is tested. The smaller 'k' the more focus is on detailed structures, while a large k will tets overall changes.

### Value

A `SingleCellExperiment` object.

### References

Latecki, Longin Jan and Lazarevic, Aleksandar and Pokrajac, Dragoljub (2007). Outlier Detection with Kernel Density Functions. Mach. Learn. Data Min. Pattern Recognit.. Springer Berlin Heidelberg.

### See Also

`ldfSce`, `.ldfKnn`.

Other ldf functions: `ldfSce()`

### Examples

    library(SingleCellExperiment)
    sim_list <- readRDS(system.file("extdata/sim50.rds", package = "CellMixS"))
    sce <- sim_list[["batch20"]][, c(1:50, 300:350)]
    sce_batch1 <- sce[,colData(sce)$batch == "1"]
    sce_batch2 <- sce[,colData(sce)$batch == "2"]
    sce_pre_list <- list("1" = sce_batch1, "2" = sce_batch2)

    sce_ldf <- ldfDiff(sce_pre_list, sce, k = 10, group = "batch",
    dim_combined = "MNN", n_dim = 2)

[Package CellMixS version 1.2.6 Index]