Last updated: 2022-08-14

Checks: 7 0

Knit directory: workflowr/

This reproducible R Markdown analysis was created with workflowr (version 1.7.0). 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(20190717) 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 061748a. 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/
    Ignored:    analysis/DNase_example_cache/
    Ignored:    analysis/running_mcmc_cache/
    Ignored:    data/DHS_Index_and_Vocabulary_hg38_WM20190703.txt
    Ignored:    data/DNase_chr21/
    Ignored:    data/DNase_chr22/
    Ignored:    data/dat_FDR01_hg38.RData
    Ignored:    output/DNase/

Untracked files:
    Untracked:  data/DHS_Index_and_Vocabulary_hg38_WM20190703.txt.gz
    Untracked:  data/DHS_Index_and_Vocabulary_metadata.xlsx

Unstaged changes:
    Modified:   analysis/.DS_Store
    Modified:   analysis/DNase_example.Rmd
    Modified:   analysis/pairwise_fitting_cache/html/__packages
    Deleted:    analysis/pairwise_fitting_cache/html/unnamed-chunk-3_49e4d860f91e483a671b4b64e8c81934.RData
    Deleted:    analysis/pairwise_fitting_cache/html/unnamed-chunk-3_49e4d860f91e483a671b4b64e8c81934.rdb
    Deleted:    analysis/pairwise_fitting_cache/html/unnamed-chunk-3_49e4d860f91e483a671b4b64e8c81934.rdx
    Deleted:    analysis/pairwise_fitting_cache/html/unnamed-chunk-6_4e13b65e2f248675b580ad2af3613b06.RData
    Deleted:    analysis/pairwise_fitting_cache/html/unnamed-chunk-6_4e13b65e2f248675b580ad2af3613b06.rdb
    Deleted:    analysis/pairwise_fitting_cache/html/unnamed-chunk-6_4e13b65e2f248675b580ad2af3613b06.rdx
    Modified:   analysis/preprocessing_cache/html/__packages
    Deleted:    analysis/preprocessing_cache/html/unnamed-chunk-11_d0dcbf60389f2e00d36edbf7c0da270d.RData
    Deleted:    analysis/preprocessing_cache/html/unnamed-chunk-11_d0dcbf60389f2e00d36edbf7c0da270d.rdb
    Deleted:    analysis/preprocessing_cache/html/unnamed-chunk-11_d0dcbf60389f2e00d36edbf7c0da270d.rdx
    Modified:   data/.DS_Store
    Modified:   data/tpm_zebrafish.tsv.gz
    Modified:   output/.DS_Store
    Deleted:    output/chain.rds
    Deleted:    output/hyperparameters.Rdata
    Modified:   output/red_class.txt
    Deleted:    output/retained_classes.txt

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/candidate_latent_classes.Rmd) and HTML (docs/candidate_latent_classes.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 f1a7b55 Hillary Koch 2022-08-13 add DNase analysis
html f1a7b55 Hillary Koch 2022-08-13 add DNase analysis
Rmd c1e13d0 Hillary Koch 2022-07-30 working with new computer
html c1e13d0 Hillary Koch 2022-07-30 working with new computer

Finding candidate latent classes: the graph enumeration and pruning algorithm

—Special considerations: this portion is likely a high-memory task!—

Now that we have our pairwise fits, we need to figure out what are the remaining candidate latent classes. These can be found using the path enumeration and pruning algorithm. This is a graph-based algorithm which can require a lot of memory (especially when the dimension of the data is large). However, with the memory available, this algorithm runs very quickly – in our experience, in under 5 minutes.

First, load in the previously obtained pairwise fits.

data("fits")

Then, we can obtain a reduced list of candidate latent classes with get_reduced_classes(). This function has 3 arguments:

  1. the pairwise fits

  2. the dimension of the data

  3. the name of an output “LEMON graph format” file (here, called lgf.txt). This is not to be edited by the user, but is produced for underlying C software.

# This finds the dimension of the data directly from the pairwise fits
D <- as.numeric(strsplit(tail(names(fits),1), "_")[[1]][2])

# Get the list of candidate latent classes
red_class <- get_reduced_classes(fits, D, "output/lgf.txt", split_in_two = FALSE)
Writing LGF file...done!
Finding latent classes...done!
# write the output to a text file
readr::write_tsv(data.frame(red_class), file = "output/red_class.txt", col_names = FALSE)

Each row of red_class corresponds to a candidate latent class across the 3 dimensions. The remaining candidate latent classes are as follows:

red_class
      [,1] [,2] [,3]
 [1,]    1    0    1
 [2,]    1    0    0
 [3,]    1    0   -1
 [4,]    0    1   -1
 [5,]    0    0    1
 [6,]    0    0    0
 [7,]    0    0   -1
 [8,]    0   -1    1
 [9,]    0   -1    0
[10,]   -1    0    1
[11,]   -1    0    0
[12,]   -1   -1    1
[13,]   -1   -1    0

which is a subset of the \(3^D=27\) candidate latent classes. Next, we need to determine the hyperparameters on the priors in our Bayesian Gaussian mixture model. Most important is computing the hyperparameters for the prior on the mixing weights. Some classes (especially when the dimension is larger) will have a mixing weight that will result in a degenerate mixing distribution, and so classes with small enough mixing weights can be further pruned from the model. This is discussed in the next step.

Session Information

print(sessionInfo())
R version 4.2.1 (2022-06-23)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Monterey 12.5

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.2-arm64/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] CLIMB_1.0.0 readr_2.1.2

loaded via a namespace (and not attached):
 [1] tidyselect_1.1.2     xfun_0.31            bslib_0.4.0         
 [4] purrr_0.3.4          testthat_3.1.4       vctrs_0.4.1         
 [7] generics_0.1.3       htmltools_0.5.3      yaml_2.3.5          
[10] utf8_1.2.2           rlang_1.0.4          jquerylib_0.1.4     
[13] later_1.3.0          pillar_1.8.0         glue_1.6.2          
[16] DBI_1.1.3            bit64_4.0.5          plyr_1.8.7          
[19] foreach_1.5.2        lifecycle_1.0.1      stringr_1.4.0       
[22] workflowr_1.7.0      mvtnorm_1.1-3        LaplacesDemon_16.1.6
[25] codetools_0.2-18     evaluate_0.15        knitr_1.39          
[28] tzdb_0.3.0           fastmap_1.1.0        doParallel_1.0.17   
[31] httpuv_1.6.5         parallel_4.2.1       fansi_1.0.3         
[34] Rcpp_1.0.9           promises_1.2.0.1     cachem_1.0.6        
[37] vroom_1.5.7          jsonlite_1.8.0       abind_1.4-5         
[40] bit_4.0.4            fs_1.5.2             brio_1.1.3          
[43] hms_1.1.1            digest_0.6.29        stringi_1.7.8       
[46] dplyr_1.0.9          rprojroot_2.0.3      cli_3.3.0           
[49] tools_4.2.1          magrittr_2.0.3       sass_0.4.2          
[52] tibble_3.1.8         crayon_1.5.1         whisker_0.4         
[55] tidyr_1.2.0          pkgconfig_2.0.3      ellipsis_0.3.2      
[58] assertthat_0.2.1     rmarkdown_2.14       rstudioapi_0.13     
[61] iterators_1.0.14     JuliaCall_0.17.4     R6_2.5.1            
[64] git2r_0.30.1         compiler_4.2.1