Skip to content

Commit

Permalink
updated Readme and vignettes link
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeyuan-Chen committed Jan 11, 2024
1 parent bdb4b36 commit b4fd939
Show file tree
Hide file tree
Showing 21 changed files with 238 additions and 59 deletions.
Binary file removed .DS_Store
Binary file not shown.
3 changes: 3 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ LICENSE
^pkgdown$
^cran-comments\.md$
^\.github$
^vignettes/pbmc\.rds$
^vignettes/liu\.rds$
^vignettes/hannum\.rds$
48 changes: 48 additions & 0 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
release:
types: [published]
workflow_dispatch:

name: pkgdown

jobs:
pkgdown:
runs-on: ubuntu-latest
# Only restrict concurrency for non-PR jobs
concurrency:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::pkgdown, local::.
needs: website

- name: Build site
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
shell: Rscript {0}

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/[email protected]
with:
clean: false
branch: gh-pages
folder: docs
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
**/.DS_Store
.Rproj.user
.Rhistory
.RData
Expand Down
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,4 @@ Config/testthat/edition: 3
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.2.3
URL: https://cozygene.github.io/Unico/
Binary file removed R/.DS_Store
Binary file not shown.
10 changes: 5 additions & 5 deletions R/Unico.r
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
#' \item{sigmas_hat_list}{A list tracking, for each feature, the computed estimates of the variance-covariance matrix at each iteration of the variance-covariance optimization (activated only if \code{debug == TRUE}).}
#'
#' @examples
#' data = simulate_data(n = 100, m = 2, k = 3, p1 = 1, p2 = 1, taus_std = 0)
#' data = simulate_data(n = 100, m = 2, k = 3, p1 = 1, p2 = 1, taus_std = 0, log_file = NULL)
#' res = list()
#' res$params.hat = Unico(data$X, data$W, data$C1, data$C2, parallel=FALSE, log_file=NULL)
#'
Expand Down Expand Up @@ -256,7 +256,7 @@ Unico = function(X, W, C1, C2, fit_tau = FALSE,
#' @return A \code{k} by \code{m} by \code{n} array with the estimated source-specific values. The first axis/dimension in the array corresponds to the different sources.
#'
#' @examples
#' data = simulate_data(n = 100, m = 2, k = 3, p1 = 1, p2 = 1, taus_std = 0)
#' data = simulate_data(n = 100, m = 2, k = 3, p1 = 1, p2 = 1, taus_std = 0, log_file = NULL)
#' res = list()
#' res$params.hat = Unico(data$X, data$W, data$C1, data$C2, parallel=FALSE, log_file=NULL)
#' res$Z = tensor(data$X, data$W, data$C1, data$C2, res$params.hat, parallel=FALSE, log_file=NULL)
Expand Down Expand Up @@ -370,7 +370,7 @@ tensor = function(X, W, C1, C2, Unico.mdl, parallel = TRUE, num_cores = NULL,
#' \item{phi_hat_pvals}{An \code{m} by \code{k+p1*k+p2} matrix containing the p-values associated with \code{phi_hat} for each feature (activated only if \code{debug == TRUE}).}
#'
#' @examples
#' data = simulate_data(n = 100, m = 2, k = 3, p1 = 1, p2 = 1, taus_std = 0)
#' data = simulate_data(n = 100, m = 2, k = 3, p1 = 1, p2 = 1, taus_std = 0, log_file = NULL)
#' res = list()
#' res$params.hat = Unico(data$X, data$W, data$C1, data$C2, parallel=FALSE, log_file=NULL)
#' res$params.hat = association_parametric(data$X, res$params.hat, parallel=FALSE, log_file=NULL)
Expand Down Expand Up @@ -608,7 +608,7 @@ association_parametric = function(X, Unico.mdl, slot_name = "parametric",
#' \item{phi_hat_pvals}{An \code{m} by \code{k+p1*k+p2} matrix containing the p-values associated with \code{phi_hat} for each feature (activated only if \code{debug == TRUE}).}
#'
#' @examples
#' data = simulate_data(n = 100, m = 2, k = 3, p1 = 1, p2 = 1, taus_std = 0)
#' data = simulate_data(n = 100, m = 2, k = 3, p1 = 1, p2 = 1, taus_std = 0, log_file = NULL)
#' res = list()
#' res$params.hat = Unico(data$X, data$W, data$C1, data$C2, parallel=FALSE, log_file=NULL)
#' res$params.hat = association_asymptotic(data$X, res$params.hat, parallel=FALSE, log_file=NULL)
Expand Down Expand Up @@ -840,7 +840,7 @@ association_asymptotic = function(X, Unico.mdl, slot_name = "asymptotic",

#'
#' @examples
#' sim.data = simulate_data(n = 100, m = 5, k = 5, p1 = 1, p2 = 2)
#' sim.data = simulate_data(n = 100, m = 5, k = 5, p1 = 1, p2 = 2, log_file = NULL)
#'
#' @export simulate_data

Expand Down
51 changes: 7 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,63 +2,26 @@
<!-- badges: start -->
[![R-CMD-check](https://github.com/cozygene/Unico/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/cozygene/Unico/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->

We present Unico, a unified cross-omics method designed to deconvolve standard 2-dimensional bulk matrices of samples by features into a 3-dimensional tensors representing samples by features by cell types. Unico stands out as the first principled model-based deconvolution method that is theoretically justified for any heterogeneous genomic data.

All necessary scripts used for the analyses reported in the manuscript can be found under ./Rscripts

Unico will be available soon on CRAN as an R package

### Installation Instructions
Please install the following packages in R, which should finish within an hour.
### Installation from github
```
install.packages("pbapply")
install.packages("config")
install.packages("data.table")
install.packages("matrixStats")
install.packages("matrixcalc")
install.packages("mgcv")
install.packages("nloptr")
install.packages("testit")
install.packages("compositions")
install.packages("MASS")
install.packages("pracma")
if (!require("devtools", quietly = TRUE))
install.packages("devtools")
devtools::install_github("https://github.com/cozygene/Unico")
```

### Version info
Our algorithm is tested on both R 3.6.1 and R 4.1.0, on both Linux and MacOS based machines.
The entirety of the system environment is also included at the end of the tutorial notebook.


### Running Unico
```
Please provide (1) Bulk matrix of normalized counts or methylation beta values as input: X (features by samples),
(2) The (estimated) sample specific cell-type proportions matrix: W (samples by cell types).
This matrix should be normalized such that proportions on each row/individual sum up to 1
(3) Optionally, the model can also model cell-type level covariates: C1 (samples by number of cell-type-level covariates)
(4) Optionally, the model can also model tissue-level covariates: C2 (samples by number of tissue-level covariates)
We encourage users to provide all matrices with explicit and meaningful row and column names when possible to avoid confusion regarding the dimension of the output object.
```
##### First step is always to perform parameter estimation.
```
#Unico will learn cell-type specific means, variances and covariances along with cell-type-level and tissue-level effect sizes under a generalized method of moment (GMM) framework
unico.mdl = list()
unico.mdl$params.hat <- Unico(X, W, C1, C2, parallel = TRUE)
```
##### Once parameters are estimated we can further estimate cell-type level profiles: cell types by features by samples (denoted as Z.hat)
```
unico.mdl$Z.hat = tensor(X, W = W, C1, C2, unico.mdl$params.hat)
```
##### Alternatively, we can perform association study
```
#parametric version (under normality assumption) without explicitly deriving the underlying cell-type levels:
Unico.mdl$params.hat = add_C1_C2_pvals_parametric(X = X, Unico.mdl = Unico.mdl$params.hat, slot_name = "parametric")
```
```
#Non-parametric version (p-values are derived based on asymptotics):
Unico.mdl$params.hat = add_C1_C2_pvals_asymptotic(X = X, Unico.mdl = Unico.mdl$params.hat, slot_name = "asymptotic")
```
### Tutorial
Please head to "vignettes" folder for a more involved step by step tutorial on deconvolving a simulated PBMC pseudo-bulk expression dataset and association testing on methylation data.
Please head to "vignettes" folder for a more involved step by step tutorial on deconvolving a simulated PBMC pseudo-bulk expression dataset and association testing on subsets of publicly available methylation data.

### Author

Expand Down
Binary file removed Rscripts/.DS_Store
Binary file not shown.
Binary file removed man/.DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion man/Unico.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/association_asymptotic.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/association_parametric.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/simulate_data.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/tensor.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file removed tests/.DS_Store
Binary file not shown.
Binary file removed tests/testthat/.DS_Store
Binary file not shown.
Binary file removed vignettes/.DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion vignettes/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
*.html
*.R

8 changes: 4 additions & 4 deletions vignettes/Unico-Tutorial.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ knitr::opts_chunk$set(
```{r eval=F, setup}
library(Unico)
library(matrixStats)
source("vignetts.utils.r")
source("https://github.com/cozygene/Unico/raw/main/vignettes/vignetts.utils.r")
```


Expand All @@ -27,7 +27,7 @@ Let's first load a small simulated pseudo-bulk PBMC expression profiles using da
```{r eval=F}
data_path <- "./"
if(!file.exists(file.path(data_path, "pbmc.rds"))){
download.file("github.com/cozygene/Unico/blob/master/vignettes/pbmc.rds?raw=true", file.path(data_path,"pbmc.rds"))
download.file("https://github.com/cozygene/Unico/raw/main/vignettes/pbmc.rds", file.path(data_path,"pbmc.rds"))
}
sim.data = readRDS(file.path(data_path,"pbmc.rds"))
```
Expand Down Expand Up @@ -74,10 +74,10 @@ Unico also offers association testing at cell-type resolution. Let's look at two
```{r eval=F, echo = T, results = 'hide'}
data_path <- "./"
if(!file.exists(file.path(data_path, "liu.rds"))){
download.file("github.com/cozygene/Unico/blob/master/vignettes/liu.rds?raw=true", file.path(data_path,"liu.rds"))
download.file("https://github.com/cozygene/Unico/raw/main/vignettes/liu.rds", file.path(data_path,"liu.rds"))
}
if(!file.exists(file.path(data_path, "hannum.rds"))){
download.file("github.com/cozygene/Unico/blob/master/vignettes/hannum.rds?raw=true", file.path(data_path,"hannum.rds"))
download.file("https://github.com/cozygene/Unico/raw/main/vignettes/hannum.rds", file.path(data_path,"hannum.rds"))
}
liu = readRDS(file.path(data_path,"liu.rds"))
hannum = readRDS(file.path(data_path,"hannum.rds"))
Expand Down
Loading

0 comments on commit b4fd939

Please sign in to comment.