Computes a Wilcoxon rank sum test for each cell type between two groups.

AbundanceTest(cellmeta, celltype.col, sample.col, group.col)

Arguments

cellmeta

A data frame containing metadata information about cells.

celltype.col

The name of the column in cellmeta that contains cell type information.

sample.col

The name of the column in cellmeta that contains sample identifiers.

group.col

The name of the column in cellmeta that specifies the grouping variable.

Value

A data frame containing results of Wilcoxon rank sum tests for each cell type.

Details

This function takes in a data frame cellmeta, a character string celltype.col, a character string sample.col, and a character string group.col as input. It calculates fold change, mean percentage, p-value for each cell type using Wilcoxon rank sum test.

Examples

library(dplyr)
#> 
#> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’:
#> 
#>     filter, lag
#> The following objects are masked from ‘package:base’:
#> 
#>     intersect, setdiff, setequal, union
data(iris)

# Add some metadata to iris data frame
iris$Sample_ID <- rep(paste0("sample", 1:10), each = 15)
iris$Group <- rep(c("A","B"), each = 75)

# Run the AbundanceTest function
AbundanceTest(cellmeta = iris,
celltype.col = "Species",
sample.col = "Sample_ID",
group.col = "Group")
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact p-value with ties
#> Warning: cannot compute exact p-value with ties
#>     celltype fold.change    p.value mean.perc
#> 1     setosa           0 0.02315095 0.3333333
#> 2 versicolor           1 1.00000000 0.3333333
#> 3  virginica         Inf 0.02315095 0.3333333