rr1859 / R.4Cker

MIT License
16 stars 15 forks source link

Something odd in differentialAnalysis #41

Closed Rseq closed 6 years ago

Rseq commented 6 years ago

Hi,

Thank you for this package. It is working quite fine. But, I wonder if you can help me out with the differentialAnalysis. All my samples were able to pass the QC filter and the analysis ran smoothly until that part. When I call the function differentialAnalysis with the option (region="nearbait"), I have no output and the following message:

converting counts to integer mode
gene-wise dispersion estimates
mean-dispersion relationship
final dispersion estimates

> Error in rowMeans(norm_counts[, cols_conditions[condition1_row, 1]:cols_conditions[condition1_row,  : 
>   'x' must be an array of at least two dimensions 

In addition: Warning message:
In checkForExperimentalReplicates(object, modelMatrix) :
  same number of samples and coefficients to fit,
  estimating dispersion by treating samples as replicates.
  read the ?DESeq section on 'Experiments without replicates'

When I call the function differentialAnalysis without the option (region="nearbait"), I have no output other than a .bed file showing the regions of interaction - but no quantitative data.

I have changed the source code replacing data.frame for array, as.array, and as.matrix without success. It seems that the issue is in this region of the source code:

if(region == "nearbait"){
    plot_df = as.matrix.data.frame(c(coord=c(rowMeans(windows[,2:3]),rowMeans(windows[,2:3])),
                         counts=c(rowMeans(norm_counts[,cols_conditions[condition1_row,1]:cols_conditions[condition1_row,2]]),
                                  rowMeans(norm_counts[,cols_conditions[condition2_row,1]:cols_conditions[condition2_row,2]])),
                         conditions=c(rep(conditions[1], nrow(windows)), rep(conditions[2], nrow(windows))),
                         sig=c(sig_rows, sig_rows)))

Do you know what is happening?

Best regards

rr1859 commented 6 years ago

How many replicates do you have per sample? Also does your dataset have more than 2 samples?

Rseq commented 6 years ago

Hi, Thanks for getting back to me. My dataset has 2 samples and one replicate per sample only. Please let me know if you need more info

rr1859 commented 6 years ago

I would advice against trying to do differential analysis using just one replicate.

Rseq commented 6 years ago

Hi, I'm aware that is not the ideal. However, is the issue due to the use of one replicate?

rr1859 commented 6 years ago

Yes - the plot is based on the average of the replicates. You will have to remove the rowMeans() function and just plot the norm_counts for each replicate

Rseq commented 6 years ago

Yes.. it makes sense and it was so obvious. Thank you very much!