DEGreport icon indicating copy to clipboard operation
DEGreport copied to clipboard

degCovariates does not shade by r value

Open hwick opened this issue 1 year ago • 5 comments

degCovariates produces a graph and outlines significant results, but does not actually shade graph based on r correlation value. This is despite R values being non-zero. I tried replacing the NA values with 0 to see if that was interfering with the plotting ability, but this did not fix the issue. Not sure if this warning message is related.

> correlates <- degCovariates(vst, metrics_df)
running pca and calculating correlations for:
un-scaled  data in pca;
pve >= 5%;
kendall cor 
Warning messages:
1: In type.convert.default(X[[i]], ...) :
  'as.is' should be specified by the caller; using TRUE
2: In type.convert.default(X[[i]], ...) :
  'as.is' should be specified by the caller; using TRUE
3: In type.convert.default(X[[i]], ...) :
  'as.is' should be specified by the caller; using TRUE
4: In type.convert.default(X[[i]], ...) :
  'as.is' should be specified by the caller; using TRUE
image
> correlates$corMatrix[order(correlates$corMatrix$r),]
   compare                      covar       pvalue          r        fdr effect_size type_variable
21     PC1                       Time 0.0011306473 -0.6735878 0.03165812  1.00000000   categorical
7      PC3                      Batch 0.0018552681 -0.6515838 0.03813398  1.00000000   categorical
26     PC2                 percent_gc 0.0054629850 -0.5968807 0.07648179  1.00000000       numeric
42     PC2            intergenic_rate 0.0022698796  0.6421053 0.03813398  0.01410000       numeric
82     PC2                    n_genes 0.0008772647  0.6842105 0.03165812  0.19056003       numeric
14     PC2            RNA_isol_method 0.0002945642  0.7254763 0.02474339  1.00000000   categorical
1      PC1                        ACV 0.2800257308         NA         NA  1.00000000   categorical
2      PC2                        ACV 0.3566465113         NA         NA  1.00000000   categorical
3      PC3                        ACV 0.4916879365         NA         NA  1.00000000   categorical
4      PC4                        ACV 0.5416311268         NA         NA  1.00000000   categorical
R version 4.3.1 (2023-06-16)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Ventura 13.5.1

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/New_York
tzcode source: internal

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

other attached packages:
 [1] RColorBrewer_1.1-3          pheatmap_1.0.12             ggrepel_0.9.3              
 [4] DEGreport_1.36.0            DESeq2_1.40.2               knitr_1.43                 
 [7] lubridate_1.9.2             forcats_1.0.0               stringr_1.5.0              
[10] dplyr_1.1.2                 purrr_1.0.1                 readr_2.1.4                
[13] tidyr_1.3.0                 tibble_3.2.1                ggplot2_3.4.2              
[16] tidyverse_2.0.0             SummarizedExperiment_1.30.2 Biobase_2.60.0             
[19] GenomicRanges_1.52.0        GenomeInfoDb_1.36.1         IRanges_2.34.1             
[22] S4Vectors_0.38.1            BiocGenerics_0.46.0         MatrixGenerics_1.12.2      
[25] matrixStats_1.0.0          

loaded via a namespace (and not attached):
 [1] mnormt_2.1.1                bitops_1.0-7                rlang_1.1.1                
 [4] magrittr_2.0.3              clue_0.3-64                 GetoptLong_1.0.5           
 [7] compiler_4.3.1              png_0.1-8                   vctrs_0.6.3                
[10] pkgconfig_2.0.3             shape_1.4.6                 crayon_1.5.2               
[13] fastmap_1.1.1               backports_1.4.1             XVector_0.40.0             
[16] labeling_0.4.2              utf8_1.2.3                  rmarkdown_2.23             
[19] tzdb_0.4.0                  xfun_0.39                   zlibbioc_1.46.0            
[22] highr_0.10                  DelayedArray_0.26.6         reshape_0.8.9              
[25] BiocParallel_1.34.2         psych_2.3.6                 broom_1.0.5                
[28] parallel_4.3.1              cluster_2.1.4               R6_2.5.1                   
[31] stringi_1.7.12              limma_3.56.2                Rcpp_1.0.11                
[34] iterators_1.0.14            Matrix_1.6-0                timechange_0.2.0           
[37] tidyselect_1.2.0            rstudioapi_0.15.0           yaml_2.3.7                 
[40] doParallel_1.0.17           codetools_0.2-19            lattice_0.21-8             
[43] plyr_1.8.8                  withr_2.5.0                 evaluate_0.21              
[46] ConsensusClusterPlus_1.64.0 circlize_0.4.15             pillar_1.9.0               
[49] DT_0.28                     foreach_1.5.2               generics_0.1.3             
[52] RCurl_1.98-1.12             hms_1.1.3                   munsell_0.5.0              
[55] scales_1.2.1                glue_1.6.2                  tools_4.3.1                
[58] locfit_1.5-9.8              cowplot_1.1.1               grid_4.3.1                 
[61] edgeR_3.42.4                colorspace_2.1-0            nlme_3.1-162               
[64] GenomeInfoDbData_1.2.10     cli_3.6.1                   fansi_1.0.4                
[67] S4Arrays_1.0.4              ComplexHeatmap_2.16.0       ggdendro_0.1.23            
[70] gtable_0.3.3                logging_0.10-108            digest_0.6.33              
[73] rjson_0.2.21                htmlwidgets_1.6.2           farver_2.1.1               
[76] htmltools_0.5.5             lifecycle_1.0.3             GlobalOptions_0.1.2        
[79] MASS_7.3-60 

hwick avatar Aug 31 '23 18:08 hwick

I think you see if you change the FDR cutoff then you see the color, it could be only color the significant variables and that depend on the FDR cutoff option.

lpantano avatar Oct 13 '23 15:10 lpantano

The default FDR cutoff in degCovariates is 0.1 and all of the non-NA FDR values shown here are significant by that cutoff. DegCovariates says it will highlight and shade significant results based on r value, but it is only highlighting and not shading. That is why I submitted this issue.

hwick avatar Oct 13 '23 21:10 hwick

I understand, I wanted just to check that. I see some weird warnings there, maybe is related to that, some update of some package that is messing with older code. I need to update to 4.3 and check if the test code runs properly or not. Is the test code generating colored areas?

lpantano avatar Oct 14 '23 17:10 lpantano

I think the problem is that is only colored when the variables are significant by the linear model that is used after testing individual correlations. We decided to put this to reduce the variables that correlate between them, but maybe in your case is not finding significant any variable in the linear model. If you can share the Robjects, I could try to see what is going on and maybe add some option to make that step optional.

lpantano avatar Oct 14 '23 17:10 lpantano

Thank you for looking into this. I will have to check about sending an Robject later as I am not working on this data at the moment, but I can confirm that the test code example in the degCovariates produces the same warnings, though it does shade 2 areas.

I think I misunderstood that the linear model p value is separate from p and fdr values generated from the cor.test. Looking at the example data, it looks as though there are 3 correlations with significant fdr values, but only 2 are shaded/in $significants. All significant areas have thick grey strokes though, no black strokes.

As a side note, the Description, Usage, and Details mention different significance cutoffs and rules for black vs grey strokes: in the Description it mentions an fdr of 0.05 is used; in the description it says it is a p value of 0.05. The default in Usage is an fdr of 0.1 (no option for p value). The description says black strokes appear if the correlation significance is fdr < 0.05, but the details says black strokes appear if the linear p < 0.05.

When I get the chance I will take another look at my data and see if the difference is the linear model. Thank you again for taking a look.

hwick avatar Oct 17 '23 21:10 hwick