Last updated: 2021-11-02

Checks: 7 0

Knit directory: SMF/

This reproducible R Markdown analysis was created with workflowr (version 1.6.2). 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(20190719) 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 acdaf69. 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:    .Rhistory
    Ignored:    .Rproj.user/
    Ignored:    analysis/.DS_Store
    Ignored:    analysis/figure/
    Ignored:    data/.DS_Store
    Ignored:    data/external_data/
    Ignored:    output/.DS_Store

Untracked files:
    Untracked:  analysis/sparse_smoothing.Rmd
    Untracked:  code/proposal.R
    Untracked:  data/luis/
    Untracked:  output/flash_on_cmc2_reduced.rds
    Untracked:  output/flash_on_cmc2_reduced_2000kb.rds
    Untracked:  output/luis/
    Untracked:  output/wave_flash_on_cmc2_reduced_2000kb.rds

Unstaged changes:
    Modified:   analysis/index.Rmd
    Modified:   analysis/luis_data.Rmd
    Modified:   analysis/smooth_flash.Rmd
    Modified:   code/wave_ebmf.R

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/joint_fa_more.Rmd) and HTML (docs/joint_fa_more.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
Rmd acdaf69 Dongyue Xie 2021-11-02 wflow_publish(“analysis/joint_fa_more.Rmd”)
html 56752d9 Dongyue Xie 2021-11-02 Build site.
Rmd 6b20bef Dongyue Xie 2021-11-02 wflow_publish(“analysis/joint_fa_more.Rmd”)

ploter2 = function(EF1,EF2=NULL,main1=NULL,main2=NULL){
  if(!is.null(EF2)){
    
    p = nrow(EF1)
    temp = max(ncol(EF1),ncol(EF2))
    if(temp!=0){
      
      par(mfrow=c(2,temp))
    if(ncol(EF1)>0){
      
      for(k in 1:ncol(EF1)){
      plot(EF1[1:(p/2),k],type='l',ylim = range(EF1[,k]),ylab=paste('f',k,sep=''),xlab='',main=main1)
      lines(EF1[(p/2+1):(p),k],type='l',col=4)
      }
      
    }
    if(ncol(EF2)>0){
      for(k in 1:ncol(EF2)){
      plot(EF2[1:(p/2),k],type='l',ylim = range(EF2[,k]),ylab=paste('f',k,sep=''),xlab='',main=main2)
      lines(EF2[(p/2+1):(p),k],type='l',col=4)
    }
    }
    
      
    }
    
  
  }else{
    p = nrow(EF1)
    par(mfrow=c(ncol(EF1),1))
    for(k in 1:ncol(EF1)){
      plot(EF1[1:(p/2),k],type='l',ylim = range(EF1[,k]),ylab=paste('f',k,sep=''),xlab='',main=main1)
      lines(EF1[(p/2+1):(p),k],type='l',col=4)
    }
  }
  
}

source('code/smooth_flash.R')
Loading required package: usethis
Loading flashr

Attaching package: 'testthat'
The following object is masked from 'package:devtools':

    test_file
Loading required package: MASS
WaveThresh: R wavelet software, release 4.6.8, installed
Copyright Guy Nason and others 1993-2016
Note: nlevels has been renamed to nlevelsWT

Attaching package: 'wavethresh'
The following object is masked from 'package:devtools':

    wd
source('code/wave_ebmf.R')
Loading flashr

Introduction

Here we look at how smoothness plays a role in the revealing of the structure.

Start from Gaussian case.

n = 45
p = 256
K= 3

FF = matrix(0, nrow=p, ncol=K)
f1 = 3
f2 = 1
FF[(p/8*1):(p/8*2),1] = f1
FF[(p/8*3):(p/8*4),2] = f2
FF[(p/8*5):(p/8*7),3] = f1

FF2 = matrix(0, nrow=p, ncol=K)
FF2[(p/8*1):(p/8*2),1] = f2
FF2[(p/8*3+10):(p/8*4-10),2] = f1
FF2[(p/8*5):(p/8*7),3] = f2

FFF = cbind(c(FF[,1],FF2[,3]),c(FF[,2],FF2[,2]),c(FF[,3],FF2[,1]))

par(mfrow=c(3,1))
for(k in 1:K){
  plot(FFF[1:p,k],type='l',ylim = range(FFF),xlab='',ylab=paste('f',k,sep=''))
  lines(FFF[(p+1):(2*p),k],type='l',col=4)
}

Version Author Date
56752d9 Dongyue Xie 2021-11-02
l0 = 0
l1 = 3
L = cbind(c(rep(l1,n/3),rep(l0,n/3*2)),
          c(rep(l0,n/3),rep(l1,n/3),rep(l0,n/3)),
          c(rep(l0,n/3*2),rep(l1,n/3)))


library(reshape2)
library(ggplot2)
LL=  melt(L)
ggplot(LL, aes(x = Var2, y = Var1)) + geom_raster(aes(fill=value)) + 
  scale_fill_gradient(low="grey90", high="red") +
  labs(x="column", y="row", title="L")

Version Author Date
56752d9 Dongyue Xie 2021-11-02

For each level of \(\sigma^2\), the variance of random noise, we plot the recovered structure from multiple runs.

apply(tcrossprod(L,FFF),1,sd)
 [1] 2.334636 2.334636 2.334636 2.334636 2.334636 2.334636 2.334636 2.334636
 [9] 2.334636 2.334636 2.334636 2.334636 2.334636 2.334636 2.334636 1.569571
[17] 1.569571 1.569571 1.569571 1.569571 1.569571 1.569571 1.569571 1.569571
[25] 1.569571 1.569571 1.569571 1.569571 1.569571 1.569571 3.016010 3.016010
[33] 3.016010 3.016010 3.016010 3.016010 3.016010 3.016010 3.016010 3.016010
[41] 3.016010 3.016010 3.016010 3.016010 3.016010
s_list = c(1,2,3,5,10,15,20)
#s_list = c(1)
niter = 10
seed=0
for(s in s_list){
  for(iter in 1:niter){
    seed=seed+1
    set.seed(seed)
   y = tcrossprod(L,FFF) + matrix(rnorm(n*p*2,0,s),nrow=n,ncol=p*2)
   fit.flash = flash(y,var_type = 'by_row',verbose = FALSE)
   fit.dwt = wave_ebmf(y,verbose = FALSE)
   ploter2(fit.dwt$ldf$f,fit.flash$ldf$f,main1=paste('wave_flash, s=',s,', iter=',iter,sep=''),main2=paste('flash, s=',s,', iter=',iter,sep='')) 
  }
}

Version Author Date
56752d9 Dongyue Xie 2021-11-02

Version Author Date
56752d9 Dongyue Xie 2021-11-02

Version Author Date
56752d9 Dongyue Xie 2021-11-02

Version Author Date
56752d9 Dongyue Xie 2021-11-02

Version Author Date
56752d9 Dongyue Xie 2021-11-02

Version Author Date
56752d9 Dongyue Xie 2021-11-02

Version Author Date
56752d9 Dongyue Xie 2021-11-02

Version Author Date
56752d9 Dongyue Xie 2021-11-02

Version Author Date
56752d9 Dongyue Xie 2021-11-02

Version Author Date
56752d9 Dongyue Xie 2021-11-02

Version Author Date
56752d9 Dongyue Xie 2021-11-02

Version Author Date
56752d9 Dongyue Xie 2021-11-02

Version Author Date
56752d9 Dongyue Xie 2021-11-02

Version Author Date
56752d9 Dongyue Xie 2021-11-02

Version Author Date
56752d9 Dongyue Xie 2021-11-02

Version Author Date
56752d9 Dongyue Xie 2021-11-02

Version Author Date
56752d9 Dongyue Xie 2021-11-02

Version Author Date
56752d9 Dongyue Xie 2021-11-02

Version Author Date
56752d9 Dongyue Xie 2021-11-02

Version Author Date
56752d9 Dongyue Xie 2021-11-02

Version Author Date
56752d9 Dongyue Xie 2021-11-02

Version Author Date
56752d9 Dongyue Xie 2021-11-02

Version Author Date
56752d9 Dongyue Xie 2021-11-02

Version Author Date
56752d9 Dongyue Xie 2021-11-02

Version Author Date
56752d9 Dongyue Xie 2021-11-02

Version Author Date
56752d9 Dongyue Xie 2021-11-02

Version Author Date
56752d9 Dongyue Xie 2021-11-02

Version Author Date
56752d9 Dongyue Xie 2021-11-02

Version Author Date
56752d9 Dongyue Xie 2021-11-02

Version Author Date
56752d9 Dongyue Xie 2021-11-02

Version Author Date
56752d9 Dongyue Xie 2021-11-02

Version Author Date
56752d9 Dongyue Xie 2021-11-02

Version Author Date
56752d9 Dongyue Xie 2021-11-02

Version Author Date
56752d9 Dongyue Xie 2021-11-02

Version Author Date
56752d9 Dongyue Xie 2021-11-02


sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur 10.16

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

other attached packages:
[1] ggplot2_3.3.2    reshape2_1.4.4   flashr_0.6-7     wavethresh_4.6.8
[5] MASS_7.3-53      testthat_3.0.0   devtools_2.3.2   usethis_1.6.3   
[9] workflowr_1.6.2 

loaded via a namespace (and not attached):
 [1] pkgload_1.1.0     splines_4.0.3     assertthat_0.2.1  horseshoe_0.2.0  
 [5] mixsqp_0.3-43     highr_0.8         deconvolveR_1.2-1 yaml_2.2.1       
 [9] remotes_2.2.0     sessioninfo_1.1.1 ebnm_0.1-50       pillar_1.4.6     
[13] backports_1.1.10  lattice_0.20-41   glue_1.4.2        digest_0.6.27    
[17] promises_1.1.1    colorspace_1.4-1  htmltools_0.5.1.1 httpuv_1.5.4     
[21] Matrix_1.2-18     plyr_1.8.6        pkgconfig_2.0.3   invgamma_1.1     
[25] purrr_0.3.4       scales_1.1.1      processx_3.5.1    whisker_0.4      
[29] later_1.1.0.1     git2r_0.27.1      tibble_3.0.4      generics_0.1.0   
[33] farver_2.0.3      ellipsis_0.3.1    withr_2.3.0       ashr_2.2-47      
[37] cli_2.4.0         magrittr_2.0.1    crayon_1.3.4      memoise_1.1.0    
[41] evaluate_0.14     ps_1.4.0          fs_1.5.0          truncnorm_1.0-8  
[45] pkgbuild_1.1.0    tools_4.0.3       prettyunits_1.1.1 softImpute_1.4   
[49] REBayes_2.2       lifecycle_1.0.0   stringr_1.4.0     trust_0.1-8      
[53] munsell_0.5.0     irlba_2.3.3       callr_3.6.0       compiler_4.0.3   
[57] rlang_0.4.10      grid_4.0.3        rstudioapi_0.11   labeling_0.4.2   
[61] rmarkdown_2.5     gtable_0.3.0      DBI_1.1.0         R6_2.4.1         
[65] knitr_1.36        dplyr_1.0.5       rprojroot_1.3-2   desc_1.2.0       
[69] stringi_1.5.3     SQUAREM_2020.5    Rcpp_1.0.5        vctrs_0.3.7      
[73] tidyselect_1.1.0  xfun_0.26