Correlation plot error
1
0
Entering edit mode
7.9 years ago
1769mkc ★ 1.2k

I m trying to make a correlation plot but Im getting error Error in eval(expr, envir, enclos) : object 'Var1' not found

My data frame is called S5

Below is my R code which I'm using to make the plot

corr <- round(cor(S5), 1)
ggcorrplot(corr)

` Please let me know what is going wrong if try to head the corr object I see nothing called Var1 object .So let me know what is going wrong ,since I can see the corr computed matrix .

My data frame is as such I mean its just a subset of my data set

Gene     `7256_Mono` `7653_Mono` `6792_Mono` `6792_HSC` 

SMARCA4   24.30380    53.72460    30.44740   23.52570   
SMARCA2   16.30570    20.33060    23.92220   55.04900
R • 4.4k views
ADD COMMENT
0
Entering edit mode

Have you tried cor.matrix() rather than cor()?

ADD REPLY
0
Entering edit mode

no i haven't ,i will try your suggestion

ADD REPLY
0
Entering edit mode

Uh? Don't know cor.matrix().

ADD REPLY
0
Entering edit mode

Neither do I, but it's made reference to in the help for ggcorrplot, so my presumption is that it produces some sort of S4 object that's needed for the plotting.

ADD REPLY
0
Entering edit mode

I see! I imagined there was a method in ggcorrplot before asking but couldn't find it. There is however a cor_pmat() function. Maybe you checked an older documentation? I have ggcorrplot version 0.1.1 installed. Probably it was cor.matrix() first and they changed it because it may confuse the S3 dispatch method (again, just guessing).

ADD REPLY
0
Entering edit mode

Cannot replicate this (please, try to include an example that we can run and obtain the same error as you do. aka. a minimum reproducible example). However, in my try I assigned the column "Gene" as row names. If you data is a data.frame like the one you included you cannot use cor() since that will give a Error in cor(d) : 'x' must be numeric error.

ADD REPLY
0
Entering edit mode

well too much technical details I would be really glad if you guys can give me help , with my error , even if I removing the first column that corresponds to my gene name I still get the error when i'm trying to plot.

"cor() since that will give a Error in cor(d) : 'x' must be numeric error."
ADD REPLY
1
Entering edit mode

This works for me:

d <- read.table(header = TRUE, row.names = 1, text = 
"Gene     `7256_Mono` `7653_Mono` `6792_Mono` `6792_HSC` 
SMARCA4   24.30380    53.72460    30.44740   23.52570   
SMARCA2   16.30570    20.33060    23.92220   55.04900")

ggcorrplot::ggcorrplot(cor(d))
ADD REPLY
0
Entering edit mode

Im still getting the same error Error in eval(expr, envir, enclos) : object 'Var1' not found I just copy and paste your code but I do get that error I posted

ADD REPLY
1
Entering edit mode

You'll need to post a complete reproducible example, including the output of sessionInfo().

ADD REPLY
0
Entering edit mode
R version 3.2.3 (2015-12-10)

Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 16.04.1 LTS

locale: [1] LC_CTYPE=en_IN.UTF-8 LC_NUMERIC=C LC_TIME=en_IN.UTF-8 LC_COLLATE=en_IN.UTF-8
[5] LC_MONETARY=en_IN.UTF-8 LC_MESSAGES=en_IN.UTF-8 LC_PAPER=en_IN.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_IN.UTF-8 LC_IDENTIFICATION=C

attached base packages: [1] parallel stats graphics grDevices utils datasets methods base

other attached packages: [1] ggcorrplot_0.1.1 gplots_3.0.1 pheatmap_1.0.8 readr_1.0.0 tidyr_0.6.1 reshape2_1.4.2
[7] ggplot2_2.2.1 reshape_0.8.6 Biobase_2.30.0 BiocGenerics_0.16.1 RISmed_2.1.6

loaded via a namespace (and not attached): [1] splines_3.2.3 gtools_3.5.0 Formula_1.2-1 assertthat_0.1
[5] stats4_3.2.3 latticeExtra_0.6-28 BSgenome_1.38.0 coin_1.1-3
[9] Rsamtools_1.22.0 corrplot_0.77 RSQLite_1.1-2 backports_1.0.5
[13] lattice_0.20-34 biovizBase_1.18.0 digest_0.6.12 GenomicRanges_1.22.4
[17] RColorBrewer_1.1-2 XVector_0.10.0 checkmate_1.8.2 colorspace_1.3-2
[21] sandwich_2.3-4 htmltools_0.3.5 Matrix_1.2-8 R.oo_1.21.0
[25] plyr_1.8.4 XML_3.98-1.5 biomaRt_2.26.1 zlibbioc_1.16.0
[29] mvtnorm_1.0-5 scales_0.4.1 gdata_2.17.0 BiocParallel_1.4.3
[33] htmlTable_1.9 tibble_1.2 cummeRbund_2.12.1 IRanges_2.4.8
[37] party_1.1-2 TH.data_1.0-8 SummarizedExperiment_1.0.2 GenomicFeatures_1.22.13
[41] nnet_7.3-12 Gviz_1.14.7 lazyeval_0.2.0 strucchange_1.5-1
[45] survival_2.40-1 magrittr_1.5 memoise_1.0.0 R.methodsS3_1.7.1
[49] MASS_7.3-45 foreign_0.8-67 tools_3.2.3 data.table_1.10.0
[53] matrixStats_0.51.0 multcomp_1.4-6 stringr_1.1.0 S4Vectors_0.8.11
[57] munsell_0.4.3 cluster_2.0.5 AnnotationDbi_1.32.3 lambda.r_1.1.9
[61] Biostrings_2.38.4 GenomeInfoDb_1.6.3 caTools_1.17.1 futile.logger_1.4.3
[65] grid_3.2.3 RCurl_1.95-4.8 dichromat_2.0-0 VariantAnnotation_1.16.4
[69] htmlwidgets_0.8 labeling_0.3 bitops_1.0-6 base64enc_0.1-3
[73] codetools_0.2-15 gtable_0.2.0 DBI_0.5-1 R6_2.2.0
[77] GenomicAlignments_1.6.3 gridExtra_2.2.1 zoo_1.7-14 dplyr_0.5.0
[81] knitr_1.15.1 rtracklayer_1.30.4 Hmisc_4.0-2 futile.options_1.0.0
[85] KernSmooth_2.23-15 modeltools_0.2-21 stringi_1.1.2 Rcpp_0.12.9
[89] rpart_4.1-10 acepack_1.4.1

ADD REPLY
0
Entering edit mode

OK, your relevant packages seem up-to-date. Only difference with my system is that your R version is more than one year old, but probably that is not the problem. Did you try R --vanilla? Do you still get the same error then?

ADD REPLY
0
Entering edit mode

OK, then I am going to suggest a few options.

  1. Make sure you have your packages up-to-date. ggplot2 was heavily update some months ago and the problem might be related to that.
  2. Make sure there are not name masking errors. Try running R in vanilla (i.e. in the terminal type R --vanilla). Load just ggcorrplot and try the code above.
  3. After you get the error type traceback() and report the output here.
  4. Type sessionInfo() and report the output.
ADD REPLY
0
Entering edit mode
0: eval(expr, envir, enclos)
9: FUN(X[[i]], ...)
8: lapply(aesthetics, eval, envir = data, enclos = plot$plot_env)
7: f(..., self = self)
6: l$compute_aesthetics(d, plot)
5: f(l = layers[[i]], d = data[[i]])
4: by_layer(function(l, d) l$compute_aesthetics(d, plot))
3: ggplot_build(x)
2: print.ggplot(x)
1: function (x, ...) 


UseMethod("print")(x)
ADD REPLY
0
Entering edit mode
6.8 years ago
agnkwi06 • 0

In my case loading library 'reshape' before running the code was creating this problem.

ADD COMMENT

Login before adding your answer.

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