Last updated: 2024-06-18

Checks: 7 0

Knit directory: KODAMA-Analysis/

This reproducible R Markdown analysis was created with workflowr (version 1.7.1). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20240618) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.

The results in this page were generated with repository version 5266e01. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Ignored files:
    Ignored:    .DS_Store
    Ignored:    .Rproj.user/

Untracked files:
    Untracked:  code/Prostate_download.sh
    Untracked:  code/Prostate_preprocessing.R
    Untracked:  data/Prostate_data.RData

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


These are the previous versions of the repository in which changes were made to the R Markdown (analysis/simulation.Rmd) and HTML (docs/simulation.html) files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view the files as they were in that past version.

File Version Author Date Message
html 113adea Stefano Cacciatore 2024-06-18 Build site.
html 70e6ab3 Stefano Cacciatore 2024-06-18 Build site.
html ced1946 Stefano Cacciatore 2024-06-18 Build site.
html f8e2e50 Stefano Cacciatore 2024-06-18 Build site.
html a5875ac Stefano Cacciatore 2024-06-18 Build site.
html 82ff50a Stefano Cacciatore 2024-06-18 Build site.
Rmd 271a59b Stefano Cacciatore 2024-06-18 Start my new project
html 4eae145 Stefano Cacciatore 2024-06-18 Build site.
Rmd 344c155 Stefano Cacciatore 2024-06-18 Start my new project
html fe6339e Stefano Cacciatore 2024-06-18 Build site.
Rmd ebfdbaa Stefano Cacciatore 2024-06-18 Start my new project
html 163e950 Stefano Cacciatore 2024-06-18 Build site.
Rmd c366cb9 Stefano Cacciatore 2024-06-18 Start my new project
html 8831c43 Stefano Cacciatore 2024-06-18 Build site.
Rmd 14b5b49 Stefano Cacciatore 2024-06-18 Start my new project
html c8016a9 Stefano Cacciatore 2024-06-18 Build site.
Rmd 97d7e23 Stefano Cacciatore 2024-06-18 Start my new project
html 299901b Stefano Cacciatore 2024-06-18 Build site.
Rmd e18f393 Stefano Cacciatore 2024-06-18 Start my new project
html 4d57ea9 Stefano Cacciatore 2024-06-18 Build site.
Rmd 5e860e0 Stefano Cacciatore 2024-06-18 Start my new project
html a94ae9e Stefano Cacciatore 2024-06-18 Build site.
Rmd c4fa7dc Stefano Cacciatore 2024-06-18 Start my new project
html f1649ac Stefano Cacciatore 2024-06-18 Build site.
Rmd 5559d36 Stefano Cacciatore 2024-06-18 Start my new project
html 5a83969 Stefano Cacciatore 2024-06-18 Build site.
Rmd 20d7f78 Stefano Cacciatore 2024-06-18 Start my new project

Introduction

Describe your project.

Main simulation study

Scenario 1

Bla bla.

library("KODAMA")
Loading required package: minerva
Loading required package: Rtsne
Loading required package: umap

Attaching package: 'KODAMA'
The following object is masked from 'package:umap':

    umap.defaults
library("KODAMAextra")
Loading required package: parallel
Loading required package: doParallel
Loading required package: foreach
Loading required package: iterators
Loading required package: e1071
x1=runif(100,min=-1,max=0)
x2=runif(100,min=0,max=1)
y1=runif(100)
y2=runif(100)
x=c(x1,x2)
y=c(y1,y2)
xy=cbind(x,y)

labels=rep(c(TRUE,FALSE),each=100)
ss=sample(100,5)
labels[ss]=!labels[ss]
labels=labels
region=rep(1:0,each=100)

data=cbind(rnorm(200,mean=labels,sd=0.1),
           rnorm(200,mean=labels,sd=0.1))

color.code=c("#1d79d0aa","#53ca3eaa")



kk <- KODAMA.matrix.parallel(data,spatial=xy,spatial.resolution=0.1,M=100,
                      FUN="PLS",
                      landmarks = 100000,
                      splitting = 100,
                      f.par.pls =  2,
                      n.cores=4)
socket cluster with 4 nodes on host 'localhost'
================================================================================[1] "Finished parallel computation"

[1] "Calculation of dissimilarity matrix..."
================================================================================
vis=RunKODAMAvisualization(kk,method="UMAP")

u=umap(data)$layout

par(mfrow=c(1,3))

plot(x,y,bg=color.code[region+1],pch=21+2*!labels,cex=1+1.5*region,axes=FALSE,main="Position")
axis(1)
axis(2,las=2)
box()

plot(vis,type="n",axes=FALSE,main="KODAMA")
axis(1)
axis(2,las=2)
box()
points(vis[!labels,],bg=color.code[region+1][!labels],pch=21+2,cex=1+1.5*region[!labels])
points(vis[labels,],bg=color.code[region+1][labels],pch=21+2*0,cex=1+1.5*region[labels])

plot(u,type="n",axes=FALSE,xlab="Dimension 1",ylab="Dimension 2",main="UMAP")
axis(1)
axis(2,las=2)
box()
points(u[!labels,],bg=color.code[region+1][!labels],pch=21+2,cex=1+1.5*region[!labels])
points(u[labels,],bg=color.code[region+1][labels],pch=21+2*0,cex=1+1.5*region[labels])

Version Author Date
4eae145 Stefano Cacciatore 2024-06-18
f1649ac Stefano Cacciatore 2024-06-18

Scenario 2

Bla bla.

x1=runif(100,min=-1,max=0)
x2=runif(100,min=0,max=1)
y1=runif(100)
y2=runif(100)
x=c(x1,x2)
y=c(y1,y2)
xy=cbind(x,y)


labels=rep(c(TRUE,FALSE),each=100)

region=rep(1:0,each=100)

data=cbind(rnorm(200,mean=1+labels,sd=0.1),
           rnorm(200,mean=1+labels,sd=0.1),
           rnorm(200,mean=1+labels,sd=0.1),
           rnorm(200,mean=1+labels,sd=0.1))

ll=length(data)
ss=sample(ll,ll*0.5)
data[ss]=0
color.code=c("#1d79d0aa","#53ca3eaa")

sel=apply(data,1,function(x) sum(x>0))>2
data=data[sel,]
region=region[sel]
labels=labels[sel]
xy=xy[sel,]


labels=data>0
labels=labels[,1]+
  labels[,2]*2+
  labels[,3]*4+
  labels[,4]*8
labels=as.numeric(as.factor(labels))+1

pca=prcomp(scale(data))$x

kk <- KODAMA.matrix.parallel(pca,spatial=xy,spatial.resolution=0.1,M=100,
                             FUN="PLS",
                             landmarks = 100000,
                             splitting = 100,
                             f.par.pls =  10,
                             n.cores=4)
The number of components selected for PLS-DA is too high and it will be automatically reduced to 4
socket cluster with 4 nodes on host 'localhost'
================================================================================[1] "Finished parallel computation"

[1] "Calculation of dissimilarity matrix..."
================================================================================
config=umap.defaults
config$n_neighbors=15
vis=RunKODAMAvisualization(kk,method="UMAP",config=config)

u=umap(pca)$layout
old.par = par(mfrow=c(1,3))



plot(xy,bg=labels,pch=21+2*(region),cex=2+1*region,axes=FALSE,main="Position")
axis(1)
axis(2,las=2)
box()

plot(vis,bg=labels,pch=21+2*(region),cex=1+1.5*region,axes=FALSE,main="KODAMA")
axis(1)
axis(2,las=2)
box()

plot(u,bg=labels,pch=21+2*(region),cex=1+1.5*region,axes=FALSE,main="UMAP")
axis(1)
axis(2,las=2)
box()

Version Author Date
fe6339e Stefano Cacciatore 2024-06-18
299901b Stefano Cacciatore 2024-06-18
4d57ea9 Stefano Cacciatore 2024-06-18
a94ae9e Stefano Cacciatore 2024-06-18
f1649ac Stefano Cacciatore 2024-06-18
par(old.par)

sessionInfo()
R version 4.3.3 (2024-02-29)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Sonoma 14.5

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRblas.0.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/Sao_Paulo
tzcode source: internal

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

other attached packages:
 [1] KODAMAextra_1.0   e1071_1.7-14      doParallel_1.0.17 iterators_1.0.14 
 [5] foreach_1.5.2     KODAMA_3.0        umap_0.2.10.0     Rtsne_0.17       
 [9] minerva_1.5.10    workflowr_1.7.1  

loaded via a namespace (and not attached):
 [1] sass_0.4.9        utf8_1.2.4        class_7.3-22      stringi_1.8.3    
 [5] lattice_0.22-6    digest_0.6.35     magrittr_2.0.3    evaluate_0.23    
 [9] grid_4.3.3        fastmap_1.1.1     rprojroot_2.0.4   jsonlite_1.8.8   
[13] Matrix_1.6-5      processx_3.8.4    whisker_0.4.1     RSpectra_0.16-1  
[17] doSNOW_1.0.20     ps_1.7.6          promises_1.3.0    httr_1.4.7       
[21] fansi_1.0.6       codetools_0.2-20  jquerylib_0.1.4   cli_3.6.2        
[25] rlang_1.1.3       cachem_1.0.8      yaml_2.3.8        tools_4.3.3      
[29] httpuv_1.6.15     reticulate_1.36.0 vctrs_0.6.5       R6_2.5.1         
[33] png_0.1-8         proxy_0.4-27      lifecycle_1.0.4   git2r_0.33.0     
[37] stringr_1.5.1     fs_1.6.3          pkgconfig_2.0.3   callr_3.7.6      
[41] pillar_1.9.0      bslib_0.7.0       later_1.3.2       glue_1.7.0       
[45] Rcpp_1.0.12       highr_0.10        xfun_0.43         tibble_3.2.1     
[49] rstudioapi_0.16.0 knitr_1.45        snow_0.4-4        htmltools_0.5.8.1
[53] rmarkdown_2.26    compiler_4.3.3    getPass_0.2-4     askpass_1.2.0    
[57] openssl_2.1.1