Last updated: 2020-06-09

workflowr checks: (Click a bullet for more information)
  • R Markdown file: up-to-date

    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.

  • Environment: empty

    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.

  • Seed: set.seed(20190721)

    The command set.seed(20190721) 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.

  • Session information: recorded

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

  • Repository version: 62d8724

    Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility. The version displayed above was the version of the Git repository at the time these results were generated.

    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:    docs/.DS_Store
        Ignored:    docs/figure/.DS_Store
        Ignored:    docs/figure/pLI_shet_robospan_probospan.Rmd/.DS_Store
        Ignored:    draft/
        Ignored:    output/
    
    Untracked files:
        Untracked:  Robocov_submit/
        Untracked:  analysis/covid19_genes_robocov.Rmd
        Untracked:  code/gtex_process_robocov_input.R
        Untracked:  data/ACE2_expression.rda
        Untracked:  data/GTEx_Analysis_2017-06-05_v8_RNASeQCv1.1.9_gene_tpm.gct
        Untracked:  data/GTEx_Analysis_v8_Annotations_SampleAttributesDD.xlsx
        Untracked:  data/GTEx_data_process.R
        Untracked:  data/TMPRSS2_expression.rda
        Untracked:  docs/figure/covid19_genes_robocov.Rmd/
    
    
    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.
Expand here to see past versions:
    File Version Author Date Message
    Rmd c6c31f2 Kushal K Dey 2020-03-08 workflow project
    html c6c31f2 Kushal K Dey 2020-03-08 workflow project


library(glasso)
library(corpcor)
library(Matrix)
library(psych)
library(CVXR)
library(Robocov)
library(CorShrink)
library(corrplot)
library(ggplot2)

Hub network matrix simulation.

hub_sim = function(n, p, block){
  mat <- 0.3*diag(1,block) + 0.7*rep(1,block) %*% t(rep(1, block))
  Sigma <-   bdiag(mat, mat, mat, mat, mat, mat, mat, mat, mat, mat)
  corSigma <- cov2cor(Sigma)
  data <- MASS::mvrnorm(n,rep(0,p),corSigma)
  ll = list("dat" = data, "cor" = corSigma, "Sigma" = Sigma)
  return(ll)
}


nloglik = function(data, cormat){
  llik = 0
  for(m in 1:nrow(data)){
    idx = which(!is.na(data[m,]))
    if(length(idx) > 2){
      llik = llik + emdbook::dmvnorm(data[m, idx], rep(0, length(idx)), cormat[idx, idx], log = T)
    }
  }
  return(-llik)
}

angle_norm = function(S, Sigma){
  dist = 1 - (tr(as.matrix(cov2cor(S)%*%cov2cor(Sigma))))/(norm(cov2cor(S), type = "F")* norm(Sigma, type = "F"))
  return(dist)
}

Data Generation

N=500
P=50
prop_missing = 0.25

ll = hub_sim(N, P, 5)
corSigma = as.matrix(ll$cor)
Sig = as.matrix(ll$Sigma)


data = hub_sim(N, P, 5)$dat

  #######################   Turn some of the entries to NA   ###################################

data_missing = t(apply(data, 1, function(x){
  if(prop_missing > 0){
    rand = sample(1:length(x), floor(prop_missing*length(x)), replace = F)
    y = x
    y[rand] = NA
    return(y)
  }else{
    return(x)
  }}))

Pop

corrplot(corSigma,  diag = TRUE,
         col = colorRampPalette(c("lightblue4", "lightblue2", "white", "indianred1", "indianred3"))(200),
         tl.pos = "n", tl.col = "black",
         rect.col = "white",na.label.col = "white",
         method = "color", type = "lower", tl.srt=45)

Expand here to see past versions of unnamed-chunk-4-1.png:
Version Author Date
c6c31f2 Kushal K Dey 2020-03-08

p-Pop

pcorSigma = -cov2cor(as.matrix(solve(corSigma)))
diag(pcorSigma) = 1
corrplot(pcorSigma,  diag = TRUE,
         col = colorRampPalette(c("lightblue4", "lightblue2", "white", "indianred1", "indianred3"))(200),
         tl.pos = "n", tl.cex = 1.5, tl.col = "black",
         rect.col = "white",na.label.col = "white",
         method = "color", type = "lower", tl.srt=45)

Expand here to see past versions of unnamed-chunk-5-1.png:
Version Author Date
c6c31f2 Kushal K Dey 2020-03-08

Standard

standard_cor = cor(data_missing, use = "pairwise.complete.obs")
corrplot(standard_cor,  diag = TRUE,
         col = colorRampPalette(c("lightblue4", "lightblue2", "white", "indianred1", "indianred3"))(200),
         tl.pos = "n", tl.cex = 1.5, tl.col = "black",
         rect.col = "white",na.label.col = "white",
         method = "color", type = "lower", tl.srt=45)

Expand here to see past versions of unnamed-chunk-6-1.png:
Version Author Date
c6c31f2 Kushal K Dey 2020-03-08

Robocov-box

robocov_box_cor = Robocov_cor(data_with_missing = data_missing, loss = "lasso")
corrplot(robocov_box_cor,  diag = TRUE,
         col = colorRampPalette(c("lightblue4", "lightblue2", "white", "indianred1", "indianred3"))(200),
         tl.pos = "n", tl.cex = 1.5, tl.col = "black",
         rect.col = "white",na.label.col = "white",
         method = "color", type = "lower", tl.srt=45)

Expand here to see past versions of unnamed-chunk-7-1.png:
Version Author Date
c6c31f2 Kushal K Dey 2020-03-08

p-Robocov

robo_prec = Robocov_precision(data_with_missing = data_missing, alpha = 0.1, lambda=1)
corrplot(robo_prec,  diag = TRUE,
         col = colorRampPalette(c("lightblue4", "lightblue2", "white", "indianred1", "indianred3"))(200),
         tl.pos = "n", tl.cex = 1.5, tl.col = "black",
         rect.col = "white",na.label.col = "white",
         method = "color", type = "lower", tl.srt=45)

Expand here to see past versions of unnamed-chunk-8-1.png:
Version Author Date
c6c31f2 Kushal K Dey 2020-03-08

CorShrink

cov_sample_ML <-  CorShrinkData(data_missing, sd_boot = FALSE,
                                  ash.control = list())
corshrink_cor = cov2cor(cov_sample_ML$cor)
corrplot(corshrink_cor,  diag = TRUE,
         col = colorRampPalette(c("lightblue4", "lightblue2", "white", "indianred1", "indianred3"))(200),
         tl.pos = "n", tl.cex = 1.5, tl.col = "black",
         rect.col = "white",na.label.col = "white",
         method = "color", type = "lower", tl.srt=45)

Expand here to see past versions of unnamed-chunk-9-1.png:
Version Author Date
c6c31f2 Kushal K Dey 2020-03-08

Session information

sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.6

Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.5/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.0   corrplot_0.84   CorShrink_0.1-6 Robocov_0.1-6  
[5] CVXR_0.99-2     psych_1.8.12    Matrix_1.2-14   corpcor_1.6.9  
[9] glasso_1.10    

loaded via a namespace (and not attached):
 [1] tidyselect_0.2.5  purrr_0.3.2       ashr_2.2-38      
 [4] reshape2_1.4.3    lattice_0.20-35   colorspace_1.4-1 
 [7] htmltools_0.3.6   yaml_2.2.0        gmp_0.5-13.2     
[10] rlang_0.4.2       pillar_1.3.1      R.oo_1.22.0      
[13] mixsqp_0.1-97     withr_2.1.2       glue_1.3.1       
[16] foreign_0.8-70    Rmpfr_0.7-1       R.utils_2.7.0    
[19] bit64_0.9-7       scs_1.1-1         foreach_1.4.4    
[22] plyr_1.8.4        stringr_1.4.0     munsell_0.5.0    
[25] gtable_0.3.0      workflowr_1.1.1   R.methodsS3_1.7.1
[28] codetools_0.2-15  evaluate_0.12     labeling_0.3     
[31] knitr_1.20        doParallel_1.0.14 pscl_1.5.2       
[34] parallel_3.5.1    Rcpp_1.0.1        backports_1.1.4  
[37] scales_1.0.0      truncnorm_1.0-8   bit_1.1-14       
[40] gridExtra_2.3     mnormt_1.5-5      digest_0.6.19    
[43] stringi_1.4.3     dplyr_0.8.0.1     grid_3.5.1       
[46] rprojroot_1.3-2   ECOSolveR_0.4     tools_3.5.1      
[49] magrittr_1.5      tibble_2.1.1      glmnet_2.0-18    
[52] pkgconfig_2.0.2   crayon_1.3.4      whisker_0.3-2    
[55] MASS_7.3-50       SQUAREM_2017.10-1 assertthat_0.2.1 
[58] rmarkdown_1.10    iterators_1.0.10  R6_2.4.0         
[61] nlme_3.1-137      git2r_0.23.0      compiler_3.5.1   

This reproducible R Markdown analysis was created with workflowr 1.1.1