Skip to content

Commit

Permalink
Add TIGER (#283)
Browse files Browse the repository at this point in the history
* Create TIGER.R

add TIGER.R

* Add TIGER

* compile TIGER

1. change the TIGER example to fit LazyData=F mode
2. document all the functions and required packages

* DESCRIPTION depends

Add cmdstanr to DESCRIPTION depends

* onLoad install cmdstan

* Update puma.Rd

* Add data document

---------

Co-authored-by: Marouen <marouenbg@users.noreply.github.com>
  • Loading branch information
cchen22 and marouenbg committed May 31, 2023
1 parent e6c9280 commit 8312861
Show file tree
Hide file tree
Showing 8 changed files with 120 additions and 37 deletions.
71 changes: 39 additions & 32 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ Depends: R (>= 4.2.0),
pandaR,
yarn,
matrixcalc
Remotes:
stan-dev/cmdstanr
biocViews:
NetworkInference,
Network,
Expand All @@ -35,45 +37,50 @@ biocViews:
Transcription,
Microarray,
GraphAndNetwork
Imports: RCy3,
viridisLite,
STRINGdb,
Biobase,
GOstats,
AnnotationDbi,
matrixStats,
GO.db,
org.Hs.eg.db,
Matrix,
gplots,
nnet,
data.table,
vegan,
stats,
utils,
reshape,
reshape2,
penalized,
parallel,
doParallel,
foreach,
ggplot2,
ggdendro,
grid,
MASS,
assertthat,
tidyr,
methods,
dplyr,
graphics
Imports:
RCy3,
viridisLite,
STRINGdb,
Biobase,
GOstats,
AnnotationDbi,
matrixStats,
GO.db,
org.Hs.eg.db,
Matrix,
gplots,
nnet,
data.table,
vegan,
stats,
utils,
reshape,
reshape2,
penalized,
parallel,
doParallel,
foreach,
ggplot2,
ggdendro,
grid,
MASS,
assertthat,
tidyr,
methods,
dplyr,
graphics,
cmdstanr,
GeneNet,
loo
License: GPL-3
Encoding: UTF-8
LazyData: false
Suggests:
testthat (>= 2.1.0),
knitr,
rmarkdown,
pkgdown
pkgdown,
dorothea
VignetteEngine: knitr
VignetteBuilder: knitr
RoxygenNote: 7.2.3
Expand Down
32 changes: 27 additions & 5 deletions R/TIGER.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
#' @export
#'
#' @examples
#' data(TIGER_expr)
#' data(TIGER_prior)
#' TIGER(TIGER_expr,TIGER_prior)
TIGER = function(expr,prior,method="VB",
signed=TRUE,baseline=TRUE,psis_loo = FALSE,
seed=123,out_path=NULL,out_size = 300,
Expand All @@ -67,6 +70,8 @@ TIGER = function(expr,prior,method="VB",
if (signed){
prior = prior.pp(prior[TF.name,TG.name],expr)
P = prior
TF.name = rownames(P)
TG.name = colnames(P)
}else{
P = prior[TF.name,TG.name]
}
Expand Down Expand Up @@ -173,7 +178,6 @@ TIGER = function(expr,prior,method="VB",
#' @return An adjacency matrix with rows as TFs and columns as genes.
#' @export
#'
#' @examples
el2adj = function(el){
el = as.data.frame(el)
all.A = unique(el[,1])
Expand All @@ -194,7 +198,6 @@ el2adj = function(el){
#' second column is gene name, and third column is edge weight.
#' @export
#'
#' @examples
adj2el = function(adj){
el = matrix(NA,nrow(adj)*ncol(adj),3)
el[,1]=rep(row.names(adj), ncol(adj))
Expand All @@ -216,7 +219,6 @@ adj2el = function(adj){
#' @return A VIPER required regulon object
#' @export
#'
#' @examples
el2regulon = function(el) {
regulon_list = split(el, el$from)
viper_regulons = lapply(regulon_list, function(regulon) {
Expand All @@ -234,7 +236,6 @@ el2regulon = function(el) {
#' @return A VIPER required regulon object.
#' @export
#'
#' @examples
adj2regulon = function(adj){
el = adj2el(adj)
el = el[el[,3]!=0,]
Expand All @@ -251,7 +252,6 @@ adj2regulon = function(adj){
#' @return A filtered prior network (adjacency matrix).
#' @export
#'
#' @examples
prior.pp = function(prior,expr){

# filter tfs and tgs
Expand Down Expand Up @@ -284,6 +284,28 @@ prior.pp = function(prior,expr){
}


#' TIGER example prior network
#'
#' @format ## `TIGER_prior`
#' A prior network matrix with 14 rows (TFs) and 1772 columns (genes)
#'
#' @source <https://zenodo.org/record/7425777>
#' @name TIGER_prior
#' @usage data(TIGER_prior)
"TIGER_prior"

#' TIGER example expression matrix
#'
#' @format ## `TIGER_expr`
#' A gene expression matrix with 1780 rows (genes) and 16 columns (samples)
#'
#' @source <https://zenodo.org/record/7425777>
#' @name TIGER_expr
#' @usage data(TIGER_expr)
"TIGER_expr"




# stan model, conditional likelihood
TIGER_C <-
Expand Down
9 changes: 9 additions & 0 deletions R/zzz.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

.onLoad <- function(...) {
cmdstan_version <- cmdstanr::cmdstan_version(error_on_NA = FALSE)
if (is.null(cmdstan_version)) {
#stop("No CmdStan installation found. Run cmdstanr::install_cmdstan() to install.", call. = FALSE)
cmdstanr::check_cmdstan_toolchain(fix = TRUE)
cmdstanr::install_cmdstan()
}
}
Binary file added data/TIGER_expr.rda
Binary file not shown.
Binary file added data/TIGER_prior.rda
Binary file not shown.
5 changes: 5 additions & 0 deletions man/TIGER.Rd

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

20 changes: 20 additions & 0 deletions man/TIGER_expr.Rd

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

20 changes: 20 additions & 0 deletions man/TIGER_prior.Rd

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

0 comments on commit 8312861

Please sign in to comment.