I have a dataframe of celltype percentages within two group of patients, like in this example:
df <- structure(list(group1 = c(1.7, 1.8, 1, 8.2, 0), group2 = c(3.4,
8.3, 0, 7.1, 0)), row.names = c("B.cells.naive", "B.cells.memory",
"Plasma.cells", "T.cells.CD8", "T.cells.CD4.naive"), class = "data.frame")
Each row represents a cell type and the columns indicate the percentage of that cell type per group1 and group2:
> df2
group1 group2
B.cells.naive 1.7 3.4
B.cells.memory 1.8 8.3
Plasma.cells 1.0 0.0
T.cells.CD8 8.2 7.1
T.cells.CD4.naive 0.0 0.0
I was wondering how to check whether there are significant differences in the proportions of the cell types between the two groups. My original dataframe has 20 different cell types, so I was hoping to also adjust for multiple comparisons. I tried the following approach, which doesn't seem to work:
library(rstatix)
fisher_df <- row_wise_fisher_test(df, p.adjust.method = "BH")
fisher_df
> fisher_df
# A tibble: 5 × 5
group n p p.adj p.adj.signif
* <chr> <dbl> <dbl> <dbl> <chr>
1 B.cells.naive 0.314 1 1 ns
2 B.cells.memory 0.314 1 1 ns
3 Plasma.cells 0.314 1 1 ns
4 T.cells.CD8 0.314 1 1 ns
5 T.cells.CD4.naive 0.314 1 1 ns
Is this the correct way to compare percentages, or are there better ways? I am also wondering about the n=0.314 in the result, I would have expected to have n=2 based on the two groups?
Thanks so much for any help!