csaw::combineTests: Error: length(ids) == nrow(tab) is not TRUE
1
0
Entering edit mode
endrebak85 ▴ 40
@endrebak85-10660
Last seen 5.3 years ago
github.com/endrebak/

csaw version: csaw_1.10.0

The call to combineTests below fails:

> tabcom <- combineTests(merged$id, results$table)
Error: length(ids) == nrow(tab) is not TRUE

> length(merged$id)
[1] 14051634
> nrow(results$table)
[1] 120695

When I get this error, what might the possible causes be?

My code is the following (and it works on many datasets, but fails on one particular for some reason):

data = readRDS(snakemake@input[["data"]])

design = read.table(snakemake@input[["design"]])
normfacs = unlist(read.table(snakemake@input[["normfacs"]]))
y = readRDS(snakemake@input[["estimate_disp"]])

library(csaw)
library(edgeR)
library(IRanges)

contrast = as.numeric(makeContrasts(snakemake@wildcards[["contrast"]], levels=colnames(design)))
fit <-  glmQLFit(y, design, contrast=contrast, robust=TRUE)
results <- glmQLFTest(fit, contrast=contrast)

# correct for multiple testing

print("correct for multiple testing")

merged <- mergeWindows(rowRanges(data), tol=1000L)
tabcom <- combineTests(merged$id, results$table)

print("writing output file")

df = as.data.frame(merged$region)
row.names = with(df, paste0(seqnames, "_", start, "_", end))

rownames(tabcom) = row.names

write.table(tabcom, snakemake@output[[1]])

 

Many thanks for your help!

If having the data available for running the code yourself might help debugging I can upload it to dropbox.

csaw • 1.3k views
ADD COMMENT
2
Entering edit mode
Aaron Lun ★ 28k
@alun
Last seen 2 hours ago
The city by the bay

As the error message suggests, the lengths of the inputs don't match up. You have 14051634 elements in your rowRanges output but only 120695 rows in your results$table. This is most probably caused by the fact that you filtered on abundance at some point in your analysis, but then you kept the unfiltered object in in data. You need to recover the filtering vector and use it to subset data before applying combineTests, so that the genomic intervals in rowRanges correspond to the statistics in results$table.

ADD COMMENT
0
Entering edit mode

Brilliant, I'll wager this is it. Thanks.

ADD REPLY

Login before adding your answer.

Traffic: 662 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6