The basic problem is that you have asked
estimateCommonDisp to estimate the negative binomial dispersion from just one gene, by passing just the 2nd row of data
y1[2,] instead of the whole data object. Why would you do that?
y1 has only 2 columns, you are asking
estimateCommonDisp to estimate the negative binomial dispersion from a single row of two numbers. That's a lot to ask.
Even that would usually run ok without any warnings or errors, so I am guessing that the 2nd row of
y1 contains two counts that add up to be less than or equal to 5. By default,
estimateCommonDisp filters out genes with total count less than or equal to 5. So
estimateCommonDisp has filtered out the one row of data that was input, meaning that it has tried to estimate the dispersion from a matrix with zero rows, and that has lead to the warning you see. I have added a check to the function so that this problem will in future generate a more informative error message.
In summary, there are several errors in your code:
- You've subsetted
y1 for no reason, throwing away almost all the data.
- Your filtering with
cpm is not stringent enough, keeping genes for which all the counts are too small to do any reasonable inference with. Please use the edgeR function
estimateCommonDisp function doesn't have arguments
More correct code for what you are trying to do is given here: https://support.bioconductor.org/p/117407/#117418
Please don't cross-post the same question at the same time to multiple lists. I've had to answer your question twice, once here and again on Bioconductor.