Errors in Lengths when Sectioning Data

Hello!!

I was wondering if more experienced eyes could help me understand why I am getting an error with the line:

{
    DGEList(counts = C[,c(3:33)], 
            genes = C[, c('GeneID', 'Length')], group = group)
  }

That states:
Error in DGEList(counts = C[, c(3:33)], genes = C[, c("GeneID", "Length")], :
Length of 'group' must equal number of columns in 'counts'

Below is a snippet of my code (I am not including all of it simply because the error is at the beginning).

Where the error occurs, I am trying to section off my data (labeled "C"), which is held in Excel, based on the numbers of columns. I am following what someone I know did, where they only had 22 columns (so the code there would be c(3:22) ) and it worked just fine for them. However, when I tried it, it did not work...

Since another individual did this without problems, I'm just not sure why I'm getting this error.

#edgeR analysis

library(limma)
library(edgeR)
library(readxl)
library(dplyr)
library(GO.db)

#call control, call another treatment
group <- factor(c(rep('HD1', 10), rep('HD2', 10)))
#Here it will not work unless you make C variable first and then do function
#to make DGE
C <- read_excel('R/HD1vsHD2.xlsx')

C <- C%>%
  {
    DGEList(counts = C[,c(3:33)], 
            genes = C[, c('GeneID', 'Length')], group = group)
  }

design <- model.matrix(~group)
counts_keep <- filterByExpr(C,  min.count = 20)
counts_filter <- C[counts_keep, ]
counts_norm <- calcNormFactors(counts_filter)

plotMDS(counts_norm)

counts_filter <- estimateDisp(counts_norm, design)
fit <- glmQLFit(counts_filter,design)

Here is a small snipped of my data:

I would appreciate any advice! And thank you in advance! I am still very new to R.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.