R plot error after subset DESeq2
2
0
Entering edit mode
3.4 years ago
jmckow1 • 0

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

R • 738 views
ADD COMMENT
0
Entering edit mode

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.

ADD REPLY
0
Entering edit mode
3.4 years ago
jmckow1 • 0

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!

ADD COMMENT
0
Entering edit mode

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?

ADD REPLY

Login before adding your answer.

Traffic: 1327 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6