EnhancedVolcano plot error: Log2foldchange is not numeric!
0
2
Entering edit mode
5.0 years ago

I'm trying to make a volcano plot with the differential expression file generated from cellranger for single cell analysis.

I uploaded the file into RStudio and ran the following code...

EnhancedVolcano(res, lab = rownames(results), x = 'Log2foldchange', y = 'pvalue', xlim = c(-8,8), title = 'Macrophage', pCutoff = 10e-16, FCcutoff = 1.5, pointSize = 3.0, labSize = 3.0)

and received the following error...

Error in EnhancedVolcano(x, lab = rownames(x), x = "Log2foldchange", y = "pvalue",  : 
  Log2foldchange is not numeric!

I then ran: is.numeric(results$gene.Log2foldchange.pvalue) and got TRUE.

Any guidance as to what to do?

Thanks!

R EnhancedVolcano • 7.5k views
ADD COMMENT
1
Entering edit mode

Output of colnames(res)? Probably your colnames do not match what you've given as xand y.

ADD REPLY
0
Entering edit mode

colnames(results) [1] "gene.Log2foldchange.pvalue"

ADD REPLY
1
Entering edit mode

Provide example data or paste the output of str(res).

ADD REPLY
0
Entering edit mode
'data.frame':   31328 obs. of  62 variables:
 $ Feature.ID                 : Factor w/ 31328 levels "ENSG00000000003.14",..: 22057 20888 27958 22670 22625 30594 19475 21679 21805 19878 ...
 $ Feature.Name               : Factor w/ 31096 levels "1-Dec","1-Mar",..: 20867 4796 20866 20865 20868 8794 2191 24343 24342 24626 ...
 $ Cluster.1.Mean.Counts      : num  0.000961 0.00032 0.001281 0.00032 0.00032 ...
 $ Cluster.1.Log2.fold.change : num  0.292 1.955 -2.009 -2.482 3.54 ...
 $ Cluster.1.Adjusted.p.value : num  1 0.9102 0.0467 0.0809 0.6103 ...
 $ Cluster.2.Mean.Counts      : num  0.000902 0.001805 0.006316 0.004511 0 ...
 $ Cluster.2.Log2.fold.change : num  0.793 4.77 0.352 0.839 3.185 ...
 $ Cluster.2.Adjusted.p.value : num  1 0.154 1 0.738 1 ...
 $ Cluster.3.Mean.Counts      : num  0.00181 0 0.01905 0.00726 0 ...
 $ Cluster.3.Log2.fold.change : num  1.46 2.19 2.01 1.5 3.19 ...
 $ Cluster.3.Adjusted.p.value : num  0.7578 1 0.0326 0.3332 1 ...
 $ Cluster.4.Mean.Counts      : num  0.000642 0 0.002568 0.004493 0 ...
 $ Cluster.4.Log2.fold.change : num  0.269 1.662 -0.887 0.779 2.662 ...
 $ Cluster.4.Adjusted.p.value : num  1 1 1 1 1 1 1 1 1 1 ...
 $ Cluster.5.Mean.Counts      : num  0 0 0.02408 0.00219 0 ...
 $ Cluster.5.Log2.fold.change : num  1.048 3.508 2.311 0.485 4.508 ...
 $ Cluster.5.Adjusted.p.value : num  1 1 0.21 1 1 ...
 $ Cluster.6.Mean.Counts      : num  0 0 0.00833 0.00238 0 ...
 $ Cluster.6.Log2.fold.change : num  0.143 2.602 0.769 0.187 3.602 ...
 $ Cluster.6.Adjusted.p.value : num  1 1 1 1 1 ...
 $ Cluster.7.Mean.Counts      : num  0 0 0 0 0 ...
 $ Cluster.7.Log2.fold.change : num  1.6494 4.1088 -0.8101 0.0644 5.1088 ...
 $ Cluster.7.Adjusted.p.value : num  1 1 1 1 1 ...
 $ Cluster.8.Mean.Counts      : num  0.00079 0 0 0.00079 0 ...
 $ Cluster.8.Log2.fold.change : num  0.59 1.98 -2.94 -1.04 2.98 ...
 $ Cluster.8.Adjusted.p.value : num  1 1 0.967 1 1 ...
 $ Cluster.9.Mean.Counts      : num  0.000565 0 0.014123 0.006214 0 ...
 $ Cluster.9.Log2.fold.change : num  0.0694 1.4617 1.5772 1.2653 2.4617 ...
 $ Cluster.9.Adjusted.p.value : num  1 1 0.0436 0.4054 1 ...
 $ Cluster.10.Mean.Counts     : num  0.00224 0 0.01119 0.00895 0 ...
 $ Cluster.10.Log2.fold.change: num  1.77 2.51 1.18 1.82 3.51 ...
 $ Cluster.10.Adjusted.p.value: num  1 1 1 0.966 1 ...
 $ Cluster.11.Mean.Counts     : num  0.00137 0 0.00137 0.00137 0 ...
 $ Cluster.11.Log2.fold.change: num  0.802 0.65 -1.899 -0.983 1.65 ...
 $ Cluster.11.Adjusted.p.value: num  1 1 0.066 0.613 1 ...
 $ Cluster.12.Mean.Counts     : num  0.00303 0 0.00606 0.00454 0 ...
 $ Cluster.12.Log2.fold.change: num  2.226 2.963 0.415 0.986 3.963 ...
 $ Cluster.12.Adjusted.p.value: num  1 1 1 1 1 1 1 1 1 1 ...
 $ Cluster.13.Mean.Counts     : num  0 0 0.00557 0.00223 0 ...
 $ Cluster.13.Log2.fold.change: num  0.0439 2.5034 0.2303 0.0883 3.5034 ...
 $ Cluster.13.Adjusted.p.value: num  1 1 1 1 1 1 1 1 1 1 ...
 $ Cluster.14.Mean.Counts     : num  0 0 0.0048 0.0096 0 ...
 $ Cluster.14.Log2.fold.change: num  1.183 3.643 0.333 2.011 4.643 ...
 $ Cluster.14.Adjusted.p.value: num  1 1 1 1 1 1 1 1 1 1 ...
 $ Cluster.15.Mean.Counts     : num  0 0 0 0 0 ...
 $ Cluster.15.Log2.fold.change: num  2.5366 4.996 0.0772 0.9516 5.996 ...
 $ Cluster.15.Adjusted.p.value: num  1 1 1 1 1 1 1 1 1 1 ...
 $ Cluster.16.Mean.Counts     : num  0 0 0.005783 0.000826 0 ...
 $ Cluster.16.Log2.fold.change: num  -0.409 2.051 0.218 -0.972 3.051 ...
 $ Cluster.16.Adjusted.p.value: num  1 1 1 1 1 ...
 $ Cluster.17.Mean.Counts     : num  0.00228 0 0.00342 0.00456 0 ...
 $ Cluster.17.Log2.fold.change: num  1.802 2.539 -0.344 0.906 3.539 ...
 $ Cluster.17.Adjusted.p.value: num  1 1 1 1 1 1 1 1 1 1 ...
 $ Cluster.18.Mean.Counts     : num  0 0 0 0.00695 0 ...
 $ Cluster.18.Log2.fold.change: num  1.725 4.184 -0.735 1.769 5.184 ...
 $ Cluster.18.Adjusted.p.value: num  1 1 1 1 1 1 1 1 1 1 ...
 $ Cluster.19.Mean.Counts     : num  0.001786 0 0.003572 0.000893 0 ...
 $ Cluster.19.Log2.fold.change: num  1.432 2.169 -0.379 -0.853 3.169 ...
 $ Cluster.19.Adjusted.p.value: num  1 1 1 1 1 1 1 1 1 1 ...
 $ Cluster.20.Mean.Counts     : num  0 0 0.00658 0 0 ...
 $ Cluster.20.Log2.fold.change: num  1.6449 4.1043 0.7945 0.0599 5.1043 ...
 $ Cluster.20.Adjusted.p.value: num  1 1 1 1 1 1 1 1 1 1 ...
ADD REPLY
0
Entering edit mode

So where are the "Log2foldchange" and "pvalue"columns?

ADD REPLY
0
Entering edit mode

I started again from the beginning.

I loaded my data with:

gene_list <- read.table("differential_expression_macrophage.csv", header = T, sep = ",")
31328 obs of 62 variable.

Then tried the volcano plot code and I'm still getting the same error.

is.numeric(res$Cluster.1.Log2.fold.change) [1] TRUE 
Error in EnhancedVolcano(x, lab = rownames(x), x = "Cluster 1 Log2 fold change", y = "Cluster 1 Adjusted pvalue", : Cluster.1.Log2>fold.change is not numeric!
ADD REPLY
0
Entering edit mode

Please check your column names:

res$Cluster.1.Log2.fold.change

vs how you supplying to the function:

x = "Cluster 1 Log2 fold change"
ADD REPLY
0
Entering edit mode

Indeed, for your data, this should work:

EnhancedVolcano(
  res2,
  lab = as.character(res2$Feature.Name),
  x = 'Cluster.1.Log2.fold.change',
  y = 'Cluster.1.Adjusted.p.value')

Thanks to everyone who has been providing feedback here...

ADD REPLY
0
Entering edit mode

Why are you checking with is.numeric(res$gene.Log2foldchange.pvalue) ? Instead, you should be checking is.numeric(res$Log2foldchange)!!

ADD REPLY
0
Entering edit mode
 is.numeric(results$Log2foldchange)
[1] FALSE

It is indeed FALSE, how do I change it?

ADD REPLY
0
Entering edit mode

It is also FALSE when then column does not exist. Are you sure your columns that store p and FC are named Log2foldchange and pvalue?

ADD REPLY
0
Entering edit mode

Yes, they are stored the way they are named.

ADD REPLY
0
Entering edit mode

Try: res$Log2foldchange <- as.numeric(res$Log2foldchange)

ADD REPLY
0
Entering edit mode

I did and ran the same code as before and get the same error.

ADD REPLY
0
Entering edit mode

I upload a new data set and and now I get TRUE still get the same error.

 is.numeric(res$Cluster.1.Log2.fold.change)
[1] TRUE
Error in EnhancedVolcano(x, lab = rownames(x), x = "Cluster 1 Log2 fold change", y = "Cluster 1 Adjusted pvalue",  : 
  Log2foldchange is not numeric!
ADD REPLY
0
Entering edit mode

Are you sure the table is in "x" ??

Because earlier you stored it in res!!

EnhancedVolcano(x, lab = rownames(x), x = "Cluster 1 Log2 fold change", y = "Cluster 1 Adjusted pvalue",

It should be

EnhancedVolcano(res, lab = rownames(x), x = "Cluster.1.Log2.fold.change", y = "Cluster.1.Adjusted.pvalue"`,

right??

Check the x and y names if they are matching to the res table!!

ADD REPLY
0
Entering edit mode

I ran this code and it works but doesn't show the gene names.

EnhancedVolcano(gene_list, lab = rownames(gene_list), x = 'Cluster.1.Log2.fold.change', y = 'Cluster.1.Adjusted.p.value', xlim = c(-5,8), aes(label = Feature.Name))

Any suggestions?

ADD REPLY
1
Entering edit mode

That is because the rownames of your data-frame, called gene_list, are not set. I can see this via the output of

str(gene_list)

Also, if you type rownames(gene_list) and press return / enter, you will not see any gene names.

You need to use:

EnhancedVolcano(
  res2,
  lab = as.character(res2$Feature.Name),
  x = 'Cluster.1.Log2.fold.change',
  y = 'Cluster.1.Adjusted.p.value',
  xlim = c(-5,8))

Why have you included the aes() function, by the way? - that will not do anything.

---------------------------

Can you please go through the entire vignette for EnhancedVolcano so that you can begin to understand how to use the package. I developed the package and wrote the vignette myself: http://bioconductor.org/packages/release/bioc/vignettes/EnhancedVolcano/inst/doc/EnhancedVolcano.html

ADD REPLY

Login before adding your answer.

Traffic: 2324 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