Dear Gordon Smyth, thanks a lot for your help, I have tried to follow the steps for both edgeR and limma, and for limma I get his error, I have followed a voom-limma approach. Maybe I am misunderstanding something very obvious
### STEPS TO RUN VOOM-LIMMA APPROACH
gse <- summarizeToGene(se, countsFromAbundance="lengthScaledTPM")
dge <- DGEList(assays(gse)[["counts"]])
# design for limma
Treat <- factor(paste(summarydata$respuesta,summarydata$tissue,sep="."))
design <- model.matrix(~0+Treat)
colnames(design) <- levels(Treat)
## Apply voom normalization
dge <- calcNormFactors(dge)
# filtering steps
keep <- filterByExpr(dge, design)
dge <- dge[keep,,keep.lib.sizes=FALSE]
# apply voom
v <- voom(dge, design, plot=TRUE)
# apply duplicateCorrelation
corfit <- duplicateCorrelation(v, design, block=summarydata$sample)
# apply voom again (with the block and correlation parameters this time)
v <- voom(dge, design, block = summarydata$sample, correlation = corfit$consensus)
# apply lmFit
fit <- lmFit(v,design,block=summarydata$sample,correlation=corfit$consensus)
cm <- makeContrasts(
RecidivavsRespuestaForNormal = RECIDIVA.N-RESPUESTA.N,
RecidivavsRespuestaForTumor = RECIDIVA.T-RESPUESTA.T,
TumorvsNormalForRespuesta = RESPUESTA.T-RESPUESTA.N,
TumorvsNormalForRecidiva = RECIDIVA.T-RECIDIVA.N,
levels=design)
fit2 <- contrasts.fit(fit, contrasts)
The error that I got is this: Error in contrasts.fit(fit, contrasts) :
anyNA() applied to non-(list or vector) of type 'closure'
In case you need the summarydata file, you can find it here summarydata.txt
In addition, I have also tried the edgeR approach but still got the same error of matrix not of full rank. Here are the steps I am doing
# For we define the experimental factors:
Patient <- factor(summarydata$sample)
Disease <- factor(summarydata$tissue, levels=c("N","T"))
Treatment <- factor(summarydata$respuesta, levels=c("RESPUESTA", "RECIDIVA"))
# We need to adjust for baseline differences between the patients,
# so the first step is to initialize the design matrix with patient effects:
design <- model.matrix(~Patient)
# Then we define disease-specific treatment effects and append them to the design matrix:
Respuesta.Tumor <- Disease== "T" & Treatment=="RESPUESTA"
Respuesta.Normal <- Disease=="N" & Treatment=="RESPUESTA"
design <- cbind(design, Respuesta.Tumor, Respuesta.Normal)
#Filterout low count genes
keep <-filterByExpr(y, group = Treatment)
y <- y[keep,keep.lib.size=FALSE]
y <- estimateDisp(y,design, robust=TRUE)