1

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!

yakumo
  • 27
  • 4
  • You already have adjusted p values in the columm `p.adj` of table `fisher_df` – danlooo Dec 09 '21 at 12:12
  • Fisher test is to decide whether two nominal properties are depended on each other. Here: Cell type grouping (B, plasma, T) depends on experimental grouping (1 or 2). This is, however, not the question you asked. You might want to use 1-sample proportions test without continuity correction e.g. `prop.test(1.7, 3.4)` – danlooo Dec 09 '21 at 12:18
  • I think to perform the fisher test you have to multiply your percentage of a group with the number of all individuals in your data, because: "row_wise_fisher_test: performs row-wise Fisher's exact test of count data" (s. https://www.rdocumentation.org/packages/rstatix/versions/0.7.0/topics/fisher_test). – JKupzig Dec 09 '21 at 12:21
  • 1
    Exactly, your data only has percentages. To perfrom significance tests you at least need to know the sample size per group. Then you could probably use existing functions are simply calculating the critical z values for the difference of the two proportions on your own. – deschen Dec 09 '21 at 12:26
  • Thanks you for your swift replies! Following @danloo's suggestion, I have tried this: prop_df <- row_wise_prop_test(df, p.adjust.method = "BH") > prop_df group n statistic df p p.adj p.adj.signif * 1 B.cells.naive 0.314 5.55e-34 1 1 1 "ns" 2 B.cells.memory 0.314 1.49e-33 1 1 1 "ns" 3 Plasma.cells 0.314 1.79e-33 1 1 1 "ns" 4 T.cells.CD8 0.314 2.11e-33 1 1 1 "ns" Is this reasonable? – yakumo Dec 09 '21 at 12:28
  • Your confidence interval changes using differet sample sizes e.g. `prop.test(170, 340)` vs `prop.test(1.7, 3.4)` So you definitely need to know how many samples were of each group e.g. T cell group 1 = 458 counts. Otherwise, your stats will not be reasonable – danlooo Dec 09 '21 at 12:33

0 Answers0