Computes a Wilcoxon rank sum test for each cell type between two groups.
AbundanceTest(cellmeta, celltype.col, sample.col, group.col)A data frame containing metadata information about cells.
The name of the column in cellmeta that contains cell type information.
The name of the column in cellmeta that contains sample identifiers.
The name of the column in cellmeta that specifies the grouping variable.
A data frame containing results of Wilcoxon rank sum tests for each cell type.
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.
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