Skip to contents

Runs differential analysis on Moran's Z polarization scores generated with the Pixelator data processing pipeline.

Usage

RunDPA(object, ...)

# S3 method for data.frame
RunDPA(
  object,
  target,
  reference,
  contrast_column,
  group_vars = NULL,
  alternative = c("two.sided", "less", "greater"),
  conf_int = TRUE,
  p_adjust_method = c("bonferroni", "holm", "hochberg", "hommel", "BH", "BY", "fdr"),
  verbose = TRUE,
  ...
)

# S3 method for Seurat
RunDPA(
  object,
  target,
  reference,
  contrast_column,
  assay = NULL,
  group_vars = NULL,
  alternative = c("two.sided", "less", "greater"),
  conf_int = TRUE,
  p_adjust_method = c("bonferroni", "holm", "hochberg", "hommel", "BH", "BY", "fdr"),
  verbose = TRUE,
  ...
)

Arguments

object

An object containing polarization scores

...

Not yet implemented

target

The name of the target group

reference

The name of the reference group

contrast_column

The name of the column where the group labels are stored. This column must include target and reference.

group_vars

An optional character vector with column names to split the tests by.

alternative

One of 'two.sided', 'less' or 'greater' (see ?wilcox.test for details)

conf_int

Should confidence intervals be computed? (see ?wilcox.test for details)

p_adjust_method

One of "bonferroni", "holm", "hochberg", "hommel", "BH", "BY" or "fdr". (see ?p.adjust for details)

verbose

Print messages

assay

Name of assay to use

Value

A tbl_df object with test results

Details

If you are working with a Seurat object containing a CellGraphAssay, the polarization scores are accessed directly from the CellGraphAssay. A character vector or factor must be selected with contrast_column from the input data (or @meta.data slot from a Seurat object) which holds the groups to run the test for. The target and reference parameters should refer to the names of the two groups used for the comparison and these names should be present in the contrast_column.

Additional groups

The test is always computed between target and reference, but it is possible to add additional grouping variables with group_vars. If group_vars is used, the test will be computed within each combination of groups. For instance, if we have annotated cells into cell type populations across two conditions defined by target and reference, we can pass the name of a cell annotation column with group_vars to run the test for each cell type.

See also

Other DA-methods: RunDCA()

Examples

library(pixelatorR)
library(dplyr)

pxl_file <- system.file("extdata/five_cells",
                        "five_cells.pxl",
                        package = "pixelatorR")

# Load polarization scores
polarization_table1 <- polarization_table2 <- ReadMPX_polarization(pxl_file)
#>  Loading item(s) from: /private/var/folders/gw/bdcqhnvs0m9gs_mq8n51jtbc0000gn/T/RtmpMJapOH/temp_libpatha88241f348a/pixelatorR/extdata/five_cells/five_cells.pxl
#> →   Loading polarization data
#>  Returning a 'tbl_df' object
polarization_table1$sample <- "Sample1"
polarization_table2$sample <- "Sample2"
polarization_table_merged <-  bind_rows(polarization_table1, polarization_table2)

# Run DPA using table as input
dpa_markers <- RunDPA(polarization_table_merged, contrast_column = "sample",
                      target = "Sample1", reference = "Sample2")
#>  Splitting data by: marker
#>  Running 80 tests
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
dpa_markers
#> # A tibble: 80 × 14
#>      estimate data_type target  reference    n1    n2 statistic     p conf.low
#>         <dbl> <chr>     <chr>   <chr>     <int> <int>     <dbl> <dbl>    <dbl>
#>  1  0         morans_z  Sample1 Sample2       4     4       8       1   -0.159
#>  2  0         morans_z  Sample1 Sample2       5     5      12.5     1   -8.12 
#>  3  0         morans_z  Sample1 Sample2       5     5      12.5     1   -0.865
#>  4 -0.0000610 morans_z  Sample1 Sample2       5     5      12.5     1   -2.02 
#>  5  0         morans_z  Sample1 Sample2       4     4       8       1   -5.96 
#>  6  0         morans_z  Sample1 Sample2       5     5      12.5     1   -9.02 
#>  7  0.0000256 morans_z  Sample1 Sample2       5     5      12.5     1   -0.797
#>  8  0         morans_z  Sample1 Sample2       3     3       4.5     1   -0.677
#>  9  0         morans_z  Sample1 Sample2       5     5      12.5     1   -0.174
#> 10  0.0000178 morans_z  Sample1 Sample2       5     5      12.5     1   -0.820
#> # ℹ 70 more rows
#> # ℹ 5 more variables: conf.high <dbl>, method <chr>, alternative <chr>,
#> #   marker <chr>, p_adj <dbl>

# Seurat objects
seur1 <- seur2 <- ReadMPX_Seurat(pxl_file)
#>  Created a 'Seurat' object with 5 cells and 80 targeted surface proteins
seur1$sample <- "Sample1"
seur2$sample <- "Sample2"
seur_merged <- merge(seur1, seur2, add.cell.ids = c("A", "B"))

# Run DPA
dpa_markers <- RunDPA(seur_merged, contrast_column = "sample",
                      target = "Sample1", reference = "Sample2")
#>  Splitting data by: marker
#>  Running 80 tests
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact confidence intervals with ties
dpa_markers
#> # A tibble: 80 × 14
#>      estimate data_type target  reference    n1    n2 statistic     p conf.low
#>         <dbl> <chr>     <chr>   <chr>     <int> <int>     <dbl> <dbl>    <dbl>
#>  1  0         morans_z  Sample1 Sample2       4     4       8       1   -0.159
#>  2  0         morans_z  Sample1 Sample2       5     5      12.5     1   -8.12 
#>  3  0         morans_z  Sample1 Sample2       5     5      12.5     1   -0.865
#>  4 -0.0000610 morans_z  Sample1 Sample2       5     5      12.5     1   -2.02 
#>  5  0         morans_z  Sample1 Sample2       4     4       8       1   -5.96 
#>  6  0         morans_z  Sample1 Sample2       5     5      12.5     1   -9.02 
#>  7  0.0000256 morans_z  Sample1 Sample2       5     5      12.5     1   -0.797
#>  8  0         morans_z  Sample1 Sample2       3     3       4.5     1   -0.677
#>  9  0         morans_z  Sample1 Sample2       5     5      12.5     1   -0.174
#> 10  0.0000178 morans_z  Sample1 Sample2       5     5      12.5     1   -0.820
#> # ℹ 70 more rows
#> # ℹ 5 more variables: conf.high <dbl>, method <chr>, alternative <chr>,
#> #   marker <chr>, p_adj <dbl>