That change makes no sense - you cannot move a line so a variable it needs (gene_list in your case) is calculated after the line. Are you saying you moved all 3 lines outside the function?
R plot error after subset DESeq2
I am trying to add a gene list to a MA plot.
I subset my results table res like this:
gene_list <- scan("genelist.txt", what="", sep="\n")
gene_list <- as.vector(gene_list)
genes <-subset(res, row.names(res) %in% gene_list)
As a test, my genelist.txt file contains all the genes in my results table, and the tables appear identical. However I am able to plot the res data
with(res, plot(baseMean, log2FoldChange, pch=20, cex=.5, log="x", ...))
but when I try the subset, I get an error that suggests I am calling NA values
with(genes, plot(baseMean, log2FoldChange, pch=20, cex=.5, log="x", ...))
Error in plot.window(...) : need finite 'xlim' values
In addition: Warning messages:
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf
3: In min(x) : no non-missing arguments to min; returning Inf
4: In max(x) : no non-missing arguments to max; returning -Inf
Any ideas on how I can correct this error? Thanks
• 1,229 views
•
link
2 answers
• 0 views
•
link
I solved the problem!!
I was subsetting within a function.
maplot <- function (res, thresh=0.001, labelsig=TRUE, textcx=1, ...) {
gene_list <- scan("genelist.txt", what="", sep="\n")
gene_list <- as.vector(gene_list)
genes <-subset(res, row.names(res) %in% gene_list)
with(genes, plot(baseMean, log2FoldChange, pch=20, cex=.5, log="x", ...))
}
png("diffexpr-maplot.png", 1500, 1000, pointsize=20)
maplot(resdata, main="MA Plot")
dev.off()
I simply moved the subset part above the function and the table is able to be read just fine. Not sure why the first way didn't work!
• 0 views
•
link
• 0 views
•
link
Log in to answer this question.
Your code above does not contain the code you changed in your answer. Also, this looks like a problem with your R programming and not with DESeq2, which means it's not a problem others will run into exactly.
I'll be closing this post unless you clean it up and mention exactly what was wrong and what had to be changed. The post is unintelligible right now.