IMB-Computational-Genomics-Lab / ascend

R package - Analysis of Single Cell Expression, Normalisation and Differential expression (ascend)
21 stars 7 forks source link

error when running runDESeq if both condition.a and condition.b contain more than 1 groups #23

Open lixin4306ren opened 5 years ago

lixin4306ren commented 5 years ago

Hi, after running runCORE, I got 4 clusters for the sample. Then I used runDESeq to identify DE genes between cluter1,3 and cluster2,4 with the following command.

cluster1_3_vs_2_4 <- runDESeq(scran_normalised, group = "cluster", condition.a = c("1","3"), condition.b = c("2", "4"), ngenes = 5000, fitType = "local", method = "per-condition")

got error information as

Loading required package: dynamicTreeCut
Loading required package: locfit
locfit 1.5-9.1   2013-03-22
Loading required package: lattice
    Welcome to 'DESeq'. For improved performance, usability and
    functionality, please consider migrating to 'DESeq2'.
[1] "Identifying genes to retain..."
[1] "Running DESeq..."
  |=======                                                               |  10%
Error: BiocParallel errors
  element index: 1, 2, 3, 4, 5, 6, ...
  first error: fewer than one row in the data
library(BiocParallel)
Execution halted

After checked the code of function runDESeq, I found one suspicious part which might be a bug. I think the third line in following in code, the condition.b should be changed to 'condition.a'. Otherwise, it will overwrite the original condition.b, and then make the actual comparison between condition.a itself and cause the error.

    if (length(condition.a) > 1) {
        reformatted <- reformatCondition(condition.a, condition_list = condition_list)
        condition.b <- reformatted$condition
        condition_list <- reformatted$condition_list
    }
    else {
        replace_idx <- which(condition_list %in% condition.a)
        condition.a <- as.character(condition.a)
        condition_list[replace_idx] <- condition.a
    }
    if (length(condition.b > 1)) {
        reformatted <- reformatCondition(condition.b, condition_list = condition_list)
        condition.b <- reformatted$condition
        condition_list <- reformatted$condition_list
    }
    else {
        replace_idx <- which(condition_list %in% condition.b)
        condition.b <- as.character(condition.b)
        condition_list[replace_idx] <- condition.b
    }
asenabouth commented 5 years ago

Hi @lixin4306ren ,

Nice catch! I'll add a fix for the next update.

Thanks, Anne