zhangyuqing / ComBat-seq

Batch effect adjustment based on negative binomial regression for RNA sequencing count data
154 stars 39 forks source link

the vignette returns a matrix | array, real data returns a list #21

Open AGordonRobertson opened 3 years ago

AGordonRobertson commented 3 years ago

I've resolved the issue, but will post this brief note anyway on the chance that it might be helpful.

In R v4.0.3, with sva v3.36.0, if I run the ComBat_seq example, it outputs a 50 x 8 "matrix" "array" - adjusted_counts <- ComBat_seq(count_matrix, batch=batch, group=NULL, full_mod=FALSE) ... class(adjusted_counts)

"matrix" "array"

dim(adjusted_counts)

50 8

If I run real read-count data consisting of 2103 genes x 270 samples, with two batches (156 and 114 samples), but input a data.frame, I get a list whose length is the product of 2103 * 270.

But if I follow the help docs and make the input data.frame into a matrix, then I get a "matrix" "array" out. system.time( adjusted_counts.old.new <- ComBat_seq( as.matrix(input), batch = batch, group = NULL, full_mod = FALSE # Boolean, if TRUE include condition of interest in model ) )

AleksZakirov commented 1 year ago

Thanks for sharing your observation and solution. I upgraded R from v 4.1.1 to 4.2.3 and encountered the same issue - the function was outputting a list rather a matrix. Explicitly converting the read count table to matrix resolved the issue.