lgatto / pRolocGUI

Interactive visualisation and exploration of spatial proteomics data
http://lgatto.github.io/pRolocGUI
7 stars 5 forks source link

pRolocVis: use externally computed coordinates instead of MSnSet #92

Closed kbarylyuk closed 6 years ago

kbarylyuk commented 6 years ago

I would like to have an option to provide a matrix of coordinates computed externally as an input object to the pRolocVis function, similar to how it is done with the plot2D function:

pRolocVis(object = data_matrix,
          method = "none",
          methargs = list(My_MSnSet))

Currently, if I do this the following errors are returned:

Error in pRolocVis_pca(object, fcol, ...) : 
  The input must be of class MSnSet
Error in pRolocVis_pca(object, fcol, ...) : object 'idDT' not found

Here is my session info:

> sessionInfo()
R version 3.4.2 (2017-09-28)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.3

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

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

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

other attached packages:
 [1] pRolocGUI_1.11.2     RColorBrewer_1.1-2   ggplot2_2.2.1        dbscan_1.1-1         pRoloc_1.19.1       
 [6] MLInterfaces_1.56.0  cluster_2.0.6        annotate_1.54.0      XML_3.98-1.10        AnnotationDbi_1.38.2
[11] IRanges_2.10.5       S4Vectors_0.14.7     MSnbase_2.2.0        ProtGenerics_1.8.0   BiocParallel_1.10.1 
[16] mzR_2.10.0           Rcpp_0.12.15         Biobase_2.36.2       BiocGenerics_0.22.1 

loaded via a namespace (and not attached):
  [1] plyr_1.8.4            igraph_1.1.2          lazyeval_0.2.1        splines_3.4.2        
  [5] ggvis_0.4.3           crosstalk_1.0.0       digest_0.6.15         foreach_1.4.4        
  [9] BiocInstaller_1.26.1  htmltools_0.3.6       viridis_0.5.0         gdata_2.18.0         
 [13] magrittr_1.5          memoise_1.1.0         doParallel_1.0.11     sfsmisc_1.1-1        
 [17] limma_3.32.10         recipes_0.1.2         gower_0.1.2           rda_1.0.2-2          
 [21] dimRed_0.1.0          lpSolve_5.6.13        colorspace_1.3-2      blob_1.1.0           
 [25] dplyr_0.7.4           RCurl_1.95-4.10       hexbin_1.27.2         genefilter_1.58.1    
 [29] bindr_0.1             impute_1.50.1         survival_2.41-3       iterators_1.0.9      
 [33] glue_1.2.0            DRR_0.0.3             gtable_0.2.0          ipred_0.9-6          
 [37] zlibbioc_1.22.0       kernlab_0.9-25        ddalpha_1.3.1.1       prabclus_2.2-6       
 [41] DEoptimR_1.0-8        scales_0.5.0          vsn_3.44.0            mvtnorm_1.0-7        
 [45] DBI_0.7               viridisLite_0.3.0     xtable_1.8-2          foreign_0.8-69       
 [49] bit_1.1-12            proxy_0.4-21          mclust_5.4            preprocessCore_1.38.1
 [53] DT_0.4                lava_1.6              prodlim_1.6.1         htmlwidgets_1.0      
 [57] sampling_2.8          threejs_0.3.1         FNN_1.1               fpc_2.1-11           
 [61] modeltools_0.2-21     pkgconfig_2.0.1       flexmix_2.3-14        nnet_7.3-12          
 [65] caret_6.0-78          labeling_0.3          tidyselect_0.2.3      rlang_0.2.0          
 [69] reshape2_1.4.3        munsell_0.4.3         mlbench_2.1-1         tools_3.4.2          
 [73] RSQLite_2.0           pls_2.6-0             broom_0.4.3           stringr_1.3.0        
 [77] yaml_2.1.16           mzID_1.14.0           ModelMetrics_1.1.0    knitr_1.20           
 [81] bit64_0.9-7           robustbase_0.92-8     randomForest_4.6-12   purrr_0.2.4          
 [85] dendextend_1.7.0      bindrcpp_0.2          nlme_3.1-131.1        whisker_0.3-2        
 [89] mime_0.5              RcppRoll_0.2.2        biomaRt_2.32.1        compiler_3.4.2       
 [93] e1071_1.6-8           affyio_1.46.0         tibble_1.4.2          stringi_1.1.6        
 [97] lattice_0.20-35       trimcluster_0.1-2     Matrix_1.2-12         psych_1.7.8          
[101] gbm_2.1.3             pillar_1.1.0          MALDIquant_1.17       bitops_1.0-6         
[105] httpuv_1.3.5          R6_2.2.2              pcaMethods_1.68.0     affy_1.54.0          
[109] hwriter_1.3.2         gridExtra_2.3         codetools_0.2-15      MASS_7.3-48          
[113] gtools_3.5.0          assertthat_0.2.0      CVST_0.2-1            withr_2.1.1          
[117] mnormt_1.5-5          diptest_0.75-7        grid_3.4.2            rpart_4.1-12         
[121] timeDate_3043.102     tidyr_0.8.0           class_7.3-14          Rtsne_0.13           
[125] shiny_1.0.5           lubridate_1.7.2       base64enc_0.1-3 

Thank you.

lgatto commented 6 years ago

Thank you for your feature request. This is actually currently possible, using the little hack described below, using the dunkley2006 dataset as example:

> library("pRolocdata")
> data(dunkley2006)

I also assume that the variable x contains your pre-calculated coordinates; here, I'll generate random data:

 > set.seed(123)
> x <- matrix(rnorm(2 * nrow(dunkley2006)), ncol = 2)
> rownames(x) <- featureNames(dunkley2006)
> colnames(x) <- c("X1", "X2")
> head(x)
                   X1          X2
AT1G09210 -0.56047565 -2.07848927
AT1G21750 -0.23017749 -0.09143428
AT1G51760  1.55870831  1.18718681
AT1G56340  0.07050839  1.19160127
AT2G32920  0.12928774 -0.78896322
AT2G47470  1.71506499 -1.54777654

I now create a new MSnSet based on dunkley2006 that I populate with my pre-computed coordinates:

> dunk2 <- dunkley2006[, 1:2]
> sampleNames(dunk2) <- colnames(x)
> exprs(dunk2) <- x

Finally, I call pRolocVis to visualise that new data without any dimensionality reduction:


> library("pRolocGUI")
> pRolocVis(dunk2, method = "none")

Listening on http://127.0.0.1:6015

2018-03-16-120535_1008x625_scrot

Let me know how this works.

kbarylyuk commented 6 years ago

Hi @lgatto ,

thank you very much for this useful suggestion. I have tried it - works as described.