Victorian-Bioinformatics-Consortium / degust

Deprecated : Use https://github.com/drpowell/degust
GNU General Public License v3.0
44 stars 15 forks source link

csv import error on beta website #47

Closed avilella closed 7 years ago

avilella commented 7 years ago

This is still with the space after comma input:


Error
Error Message:
Error in `[.data.frame`(x, , count_cols) : undefined columns selected
Calls: apply -> [ -> [.data.frame
Execution halted
Input:

.libPaths('/bio/sw/R')
library(limma)
library(edgeR)
library(jsonlite)

count_cols <- c(' CEG53-46-1a',' CEG53-46-1b',' CEG53-46-1c',' CEG53-46-4a',' CEG53-46-4b',' CEG53-46-4c')
x<-read.delim('uploads/6c7adb1eb2e3eca27dc67780a97ad083',skip=0, sep=",", check.names=FALSE, colClasses='character', na.strings=c())
x[,count_cols] <- apply(x[,count_cols], 2, function(v) as.numeric(v))     # Force numeric count columns
counts <- x[, count_cols]
keepMin <- apply(counts, 1, max) >= 0
keepCpm <- rowSums(cpm(counts)>0) >= 0                  # Keep only genes with cpm above x in at least y samples
keep <- keepMin & keepCpm
x <- x[keep,]
counts <- counts[keep,]
design <- matrix(c(c(1,1,1,0,0,0),c(0,0,0,1,1,1)), ncol=2, dimnames=list(c(' CEG53-46-1a',' CEG53-46-1b',' CEG53-46-1c',' CEG53-46-4a',' CEG53-46-4b',' CEG53-46-4c'),c(' CEG53-46-1',' CEG53-46-')))

nf <- calcNormFactors(counts)
y<-voom(counts, design, plot=FALSE,lib.size=colSums(counts)*nf)

cont.matrix <- matrix(c(c(-1,1)), ncol=1, dimnames=list(c(' CEG53-46-1',' CEG53-46-'),c(' CEG53-46-')))

fit <- lmFit(y,design)
fit2 <- contrasts.fit(fit, cont.matrix)
fit2 <- eBayes(fit2)

out <- topTable(fit2, n=Inf, sort.by='none')

out2 <- cbind(fit2$coef,
              out[, c('P.Value','adj.P.Val','AveExpr')],
              x[, c(c('Gene ID',' name',' CEG53-46-1a',' CEG53-46-1b',' CEG53-46-1c',' CEG53-46-4a',' CEG53-46-4b',' CEG53-46-4c'))] )

write.csv(out2, file="/tmp/tmp-36622AjRFk35Rz9DD/output.txt", row.names=FALSE,na='')

cat(
   toJSON(list(rank=fit2$rank, df_prior=fit2$df.prior,
               design=data.frame(fit2$design), contrasts=data.frame(fit2$contrasts),
               cov_coefficients=data.frame(fit2$cov.coefficients))),
   file="/tmp/tmp-36622AjRFk35Rz9DD/extra.json"
)
avilella commented 7 years ago

Without the space after comma redone csv, on the live website:

http://vicbioinformatics.com/degust/compare.html?code=5a55082acd3e3cd28d9175ba9f62024d

I got empty results

avilella commented 7 years ago

Without the space after comma redone cvs, on the beta website, same error:

Error Message:
Error in calcNormFactors.default(counts) : NA counts not permitted
Calls: calcNormFactors -> calcNormFactors.default
Execution halted
Input:

.libPaths('/bio/sw/R')
library(limma)
library(edgeR)
library(jsonlite)

count_cols <- c('CEG53-46-1a','CEG53-46-1b','CEG53-46-1c','CEG53-46-4a','CEG53-46-4b','CEG53-46-4c')
x<-read.delim('uploads/56b640cc0d3e6fd79bf57831848c31af',skip=0, sep=",", check.names=FALSE, colClasses='character', na.strings=c())
x[,count_cols] <- apply(x[,count_cols], 2, function(v) as.numeric(v))     # Force numeric count columns
counts <- x[, count_cols]
keepMin <- apply(counts, 1, max) >= 0
keepCpm <- rowSums(cpm(counts)>0) >= 0                  # Keep only genes with cpm above x in at least y samples
keep <- keepMin & keepCpm
x <- x[keep,]
counts <- counts[keep,]
design <- matrix(c(c(1,1,1,0,0,0),c(0,0,0,1,1,1)), ncol=2, dimnames=list(c('CEG53-46-1a','CEG53-46-1b','CEG53-46-1c','CEG53-46-4a','CEG53-46-4b','CEG53-46-4c'),c('CEG53-46-1','CEG53-46-4')))

nf <- calcNormFactors(counts)
y<-voom(counts, design, plot=FALSE,lib.size=colSums(counts)*nf)

cont.matrix <- matrix(c(c(-1,1)), ncol=1, dimnames=list(c('CEG53-46-1','CEG53-46-4'),c('CEG53-46-4')))

fit <- lmFit(y,design)
fit2 <- contrasts.fit(fit, cont.matrix)
fit2 <- eBayes(fit2)

out <- topTable(fit2, n=Inf, sort.by='none')

out2 <- cbind(fit2$coef,
              out[, c('P.Value','adj.P.Val','AveExpr')],
              x[, c(c('Gene ID','name','CEG53-46-1a','CEG53-46-1b','CEG53-46-1c','CEG53-46-4a','CEG53-46-4b','CEG53-46-4c'))] )

write.csv(out2, file="/tmp/tmp-36622jju0PFtAXVZL/output.txt", row.names=FALSE,na='')

cat(
   toJSON(list(rank=fit2$rank, df_prior=fit2$df.prior,
               design=data.frame(fit2$design), contrasts=data.frame(fit2$contrasts),
               cov_coefficients=data.frame(fit2$cov.coefficients))),
   file="/tmp/tmp-36622jju0PFtAXVZL/extra.json"
)

I am inclined to think that the issue is with the values of the file... Can I send it to you privately on an email?

avilella commented 7 years ago

Ah! I got it working. I took out the EC number column and all the spaces after comma, and now it loads properly.