Winnie09 / Lamian

48 stars 11 forks source link

Ordering samples before running branchPropTest() function #23

Open ismailelshimy opened 10 months ago

ismailelshimy commented 10 months ago

Dear @Winnie09 ,

I hope my message finds you fine. First, I would like to thank you very much for developing this extremely useful tool which addresses a very important aspect of single cell transcriptomics data sets i.e. the multi-sample multi-group study design. Your work and effort are greatly appreciated :) Second, I would like to draw your attention to an issue with branchPropTest() function which tests the difference in the branch cell proportions between 2 groups (e.g. between males and females in the exemplary bone marrow dataset). I believe it is important to arrange the samples in the branch cell proportions matrix such that they have the same order as the order of samples in the design data frame specifically when running a t-test. This is illustrated in the following code:

design = data.frame(sample = paste0('BM', 1:8), sex = c(0, rep(1, 4), rep(0, 3))) # btw there is a typo in this line in the user manual; it is written paste0('BM', 1, 8), I corrected it here to 1:8

branchPropTest(data = data[,design[,1]], design = design)

For convenience, you could fix this in line 18 of the source code for the branchPropTest() function as follows: res <- apply(data[,design[,1]], 1, function(i) t.test(i[id1], i[id2])$p.value)

In this way the user can apply the function directly without doing the reordering beforehand.