Question: distGPS in chroGPS package
0
gravatar for Haiying.Kong
17 months ago by
Haiying.Kong110
Germany
Haiying.Kong110 wrote:

On the example code:

 x <- rbind(c(rep(0,15),rep(1,5)),c(rep(0,15),rep(1,5)),c(rep(0,19),1),c(rep(1,5),rep(0,15)))
rownames(x) <- letters[1:4]
 d <- distGPS(x,metric='tanimoto')
 

 

If I have non 0 or 1 values in the matrix, distGPS gives error message. Why do we have this restriction?

> sessionInfo()
R version 3.3.3 (2017-03-06)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: openSUSE 13.1 (Bottle) (x86_64)

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

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

other attached packages:
 [1] cluster_2.0.6        chroGPS_1.22.0       changepoint_2.2.2
 [4] zoo_1.8-1            Biobase_2.34.0       GenomicRanges_1.26.4
 [7] GenomeInfoDb_1.10.3  IRanges_2.8.2        S4Vectors_0.12.2
[10] BiocGenerics_0.20.0  BiocInstaller_1.24.0 MASS_7.3-49
[13] smacof_1.9-6         plotrix_3.7          xlsx_0.5.7
[16] xlsxjars_0.6.1       rJava_0.9-9          rpart_4.1-13
[19] survivalsvm_0.0.5    survival_2.41-3      e1071_1.6-8

loaded via a namespace (and not attached):
 [1] splines_3.3.3       ellipse_0.4.1       gtools_3.5.0
 [4] ICSNP_1.1-0         Formula_1.2-2       latticeExtra_0.6-28
 [7] slam_0.1-40         backports_1.1.2     lattice_0.20-35
[10] quantreg_5.35       quadprog_1.5-5      heplots_1.3-4
[13] digest_0.6.15       XVector_0.14.1      RColorBrewer_1.1-2
[16] checkmate_1.8.5     minqa_1.2.4         colorspace_1.3-2
[19] survey_3.33         htmltools_0.3.6     Matrix_1.2-12
[22] plyr_1.8.4          weights_0.85        SparseM_1.77
[25] zlibbioc_1.20.0     mvtnorm_1.0-7       scales_0.5.0
[28] gdata_2.18.0        DPpackage_1.1-7.4   lme4_1.1-15
[31] pracma_2.1.4        MatrixModels_0.4-1  htmlTable_1.11.2
[34] tibble_1.4.2        mgcv_1.8-23         car_2.1-6
[37] ggplot2_2.2.1       nnet_7.3-12         lazyeval_0.2.1
[40] pbkrtest_0.4-7      magrittr_1.5        mice_2.46.0
[43] nlme_3.1-131.1      foreign_0.8-69      class_7.3-14
[46] tools_3.3.3         data.table_1.10.4-3 stringr_1.3.0
[49] munsell_0.4.3       rlang_0.2.0         RCurl_1.95-4.10
[52] candisc_0.8-0       grid_3.3.3          nloptr_1.0.4
[55] htmlwidgets_1.0     bitops_1.0-6        base64enc_0.1-3
[58] gtable_0.2.0        polynom_1.3-9       gridExtra_2.3
[61] nnls_1.4            knitr_1.20          Hmisc_4.1-1
[64] stringi_1.1.6       Rcpp_0.12.15        ICS_1.3-1
[67] acepack_1.4.1       wordcloud_2.5

chrogps • 259 views
ADD COMMENTlink modified 15 months ago by oscar.reina0 • written 17 months ago by Haiying.Kong110
Answer: distGPS in chroGPS package
0
gravatar for oscar.reina
15 months ago by
oscar.reina0 wrote:

Hi,

Not sure if I totally understand your question, your provided example seems to be working fine on my side, please have a look at the code output and my sessionInfo().

If the question is related on why the 0/1 restriction, have in mind that as stated in the documentation, the matrix and data.frame methods for this function are designed to compute pairwise distances between binary vectors (i.e. Genes x Epigenetic marks or Patients x Drug responses, etc). However, you can still compute a distance matrix using your favorite function and distance and generate a distGPS object with it to use explore it with downstream chroGPS functions.

Best regards,

O.

> x <- rbind(c(rep(0,15),rep(1,5)),c(rep(0,15),rep(1,5)),c(rep(0,19),1),c(rep(1,5),rep(0,15)))
> rownames(x) <- letters[1:4]
> x
  [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14] [,15] [,16] [,17] [,18] [,19] [,20]
a    0    0    0    0    0    0    0    0    0     0     0     0     0     0     0     1     1     1     1     1
b    0    0    0    0    0    0    0    0    0     0     0     0     0     0     0     1     1     1     1     1
c    0    0    0    0    0    0    0    0    0     0     0     0     0     0     0     0     0     0     0     1
d    1    1    1    1    1    0    0    0    0     0     0     0     0     0     0     0     0     0     0     0
> d <- distGPS(x,metric='tanimoto')
> d
Object of class distGPS with tanimoto distances between 4 objects 
> as.matrix(d)
    a   b   c d
a 0.0 0.0 0.8 1
b 0.0 0.0 0.8 1
c 0.8 0.8 0.0 1
d 1.0 1.0 1.0 0
> sessionInfo()
R version 3.4.2 (2017-09-28)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: OS X El Capitan 10.11.6

Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRblas.0.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] parallel  stats4    stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] chroGPS_1.27.3       changepoint_2.2.2    zoo_1.8-0            MASS_7.3-47          Biobase_2.38.0       GenomicRanges_1.30.0 GenomeInfoDb_1.14.0  IRanges_2.12.0       S4Vectors_0.16.0    
[10] BiocGenerics_0.24.0 

loaded via a namespace (and not attached):
 [1] survey_3.32-1           cluster_2.0.6           XVector_0.18.0          ICS_1.3-0               splines_3.4.2           zlibbioc_1.24.0         lattice_0.20-35         tools_3.4.2            
 [9] grid_3.4.2              nlme_3.1-131            ICSNP_1.1-0             survival_2.41-3         Matrix_1.2-12           GenomeInfoDbData_0.99.1 bitops_1.0-6            RCurl_1.95-4.8         
[17] compiler_3.4.2          DPpackage_1.1-7.2       mvtnorm_1.0-6        

ADD COMMENTlink modified 15 months ago • written 15 months ago by oscar.reina0
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 291 users visited in the last hour