Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
itsrainingdata committed Aug 22, 2016
2 parents c52f5b7 + a47ab37 commit 11ac9e0
Show file tree
Hide file tree
Showing 19 changed files with 383 additions and 42 deletions.
5 changes: 4 additions & 1 deletion .Rbuildignore
@@ -1,3 +1,6 @@
^.*\.Rproj$
### For some reason Hadley's regex's from http://r-pkgs.had.co.nz/package.html are being ignored, so do this manually
^cran-comments\.md$
^README\.Rmd$
^sparsebn\.Rproj$
^\.Rproj\.user$
^\.travis\.yml$
9 changes: 9 additions & 0 deletions .travis.yml
Expand Up @@ -4,6 +4,15 @@ language: R
sudo: false
cache: packages

#r_build_args: --no-build-vignettes --no-manual --no-resave-data
#r_check_args: --no-build-vignettes --no-manual

# Test master and dev branches
branches:
only:
- master
- dev

# Test on release, old, and development versions of R
r:
- oldrel
Expand Down
7 changes: 4 additions & 3 deletions DESCRIPTION
@@ -1,10 +1,10 @@
Package: sparsebn
Title: Learning Sparse Bayesian Networks from High-Dimensional Data
Version: 0.0.0.9000
Date: 2016-04-05
Version: 0.0.1
Date: 2016-08-12
Authors@R: person("Bryon", "Aragam", email = "sparsebn@gmail.com", role = c("aut", "cre"))
Maintainer: Bryon Aragam <sparsebn@gmail.com>
Description: Methods and tools for learning sparse Bayesian networks from high-dimensional data using sparse regularization.
Description: Fast methods for learning sparse Bayesian networks from high-dimensional data using sparse regularization. Designed to incorporate mixed experimental and observational data with thousands of variables with either continuous or discrete observations.
Depends:
R (>= 3.2.3),
sparsebnUtils,
Expand All @@ -15,6 +15,7 @@ Suggests:
rmarkdown,
mvtnorm,
igraph,
graph,
testthat
URL: https://github.com/itsrainingdata/sparsebn
BugReports: https://github.com/itsrainingdata/sparsebn/issues
Expand Down
72 changes: 68 additions & 4 deletions R/data.R
@@ -1,18 +1,49 @@
#' The pathfinder network
#'
#' The pathfinder network from the \href{http://www.bnlearn.com/bnrepository/#pathfinder}{Bayesian network repository}.
#' Pathfinder is an expert system developed in 1992 by Heckerman et. al
#' Simulated data and network for the pathfinder network from the \href{http://www.bnlearn.com/bnrepository/#pathfinder}{Bayesian network repository}.
#' Pathfinder is an expert system developed by Heckerman et. al (1992)
#' to assist with the diagnosis of lymph-node diseases.
#'
#' The data is simulated from a Gaussian SEM assuming unit edge weights and
#' unit variances for all nodes.
#'
#' @format A \code{\link{list}} with four components:
#'
#' \itemize{
#' \item \code{dag} An \code{\link[sparsebnUtils]{edgeList}} containing the pathfinder network (109 nodes, 195 edges).
#' \item \code{data} A \code{\link{data.frame}} with 109 variables and 1000 observations.
#' \item \code{ivn} A \code{\link{list}} specifying which nodes are under intervention in each observation; since this dataset
#' is purely observational, this is just \code{NULL}. Compatible with the input to \code{\link[sparsebnUtils]{sparsebnData}}.
#' \item \code{cov} Covariance matrix used to generate the data.
#' }
#'
#' @format An \code{\link{edgeList}} object with 109 nodes and 195 edges.
#'
#' @usage
#' data(pathfinder)
#'
#' @examples
#' \dontrun{
#' # Create a valid sparsebnData object from the simulated pathfinder data
#' data(pathfinder)
#' dat <- sparsebnData(pathfinder$data, type = "c")
#'
#' # If desired, change the edge weights to be randomly generated
#' coefs <- get.adjacency.matrix(pathfinder$dag)
#' coefs[coefs != 0] <- runif(n = num.edges(pathfinderDAG), min = 0.5, max = 2)
#' vars <- Matrix::Diagonal(n = num.nodes(pathfinderDAG), x = rep(1, num.nodes(pathfinderDAG)))
#' id <- vars
#' covMat <- t(solve(id - coefs)) %*% vars %*% solve(id - coefs)
#' pathfinder.data <- rmvnorm(n = 1000, sigma = as.matrix(covMat))
#' }
#'
"pathfinder"

#' The cytometry network
#' The discrete cytometry network
#'
#' Data and network for analyzing the flow cytometry experiment
#' from \href{http://science.sciencemag.org/content/308/5721/523.long}{Sachs et al. (2005)}.
#' The data is a cleaned and discretized version of the raw data from these experiments.
#' The data is a cleaned and discretized version of the raw data (see \code{\link{cytometryContinuous}}) from these experiments.
#'
#' @format A \code{\link{list}} with three components:
#'
Expand All @@ -23,4 +54,37 @@
#' Compatible with the input to \code{\link[sparsebnUtils]{sparsebnData}}.
#' }
#'
#' @usage
#' data(cytometryDiscrete)
#'
#' @examples
#' # Create a valid sparsebnData object from the cytometry data
#' data(cytometryDiscrete)
#' dat <- sparsebnData(cytometryDiscrete$data, type = "d", ivn = cytometryDiscrete$ivn)
#'
"cytometryDiscrete"

#' The continuous cytometry network
#'
#' Data and network for analyzing the flow cytometry experiment
#' from \href{http://science.sciencemag.org/content/308/5721/523.long}{Sachs et al. (2005)}.
#' This dataset contains the raw measurements from these experiments.
#'
#' @format A \code{\link{list}} with three components:
#'
#' \itemize{
#' \item \code{dag} An \code{\link[sparsebnUtils]{edgeList}} containing the consensus network (11 nodes, 17 edges).
#' \item \code{data} A \code{\link{data.frame}} with 11 variables and 7466 observations.
#' \item \code{ivn} A \code{\link{list}} specifying which nodes are under intervention in each observation.
#' Compatible with the input to \code{\link[sparsebnUtils]{sparsebnData}}.
#' }
#'
#' @usage
#' data(cytometryContinuous)
#'
#' @examples
#' # Create a valid sparsebnData object from the cytometry data
#' data(cytometryContinuous)
#' dat <- sparsebnData(cytometryContinuous$data, type = "c", ivn = cytometryContinuous$ivn)
#'
"cytometryContinuous"
20 changes: 20 additions & 0 deletions R/sparsebn-main.R
Expand Up @@ -11,6 +11,8 @@
#
# CONTENTS:
# estimate.dag
# estimate.covariance
# estimate.precision
#

#' Estimate a DAG from data
Expand Down Expand Up @@ -42,6 +44,15 @@
#'
#' @return A \code{\link[sparsebnUtils]{sparsebnPath}} object.
#'
#' @examples
#'
#' \dontrun{
#' # Estimate a DAG from the cytometry data
#' data(cytometryContinuous)
#' dat <- sparsebnData(cytometryContinuous$data, type = "d", ivn = cytometryContinuous$ivn)
#' estimate.dag(dat)
#' }
#'
#' @export
estimate.dag <- function(data,
lambdas = NULL,
Expand Down Expand Up @@ -117,6 +128,15 @@ estimate.dag <- function(data,
#' corresponding to an estimate of the covariance or precision (inverse covariance) matrix for a
#' given value of lambda.
#'
#' @examples
#'
#' \dontrun{
#' data(cytometryContinuous)
#' dat <- sparsebnData(cytometryContinuous$data, type = "d", ivn = cytometryContinuous$ivn)
#' estimate.covariance(dat) # estimate covariance
#' estimate.precision(dat) # estimate precision
#' }
#'
#' @name estimate.covariance
#' @rdname estimate.covariance
NULL
Expand Down
3 changes: 2 additions & 1 deletion R/zzz.R
Expand Up @@ -10,9 +10,10 @@

.onAttach <- function(libname, pkgname){
msg <- paste0("\n",
"sparsebn v0.1, Copyright (c) 2016\n",
"sparsebn v0.0.1, Copyright (c) 2016\n",
"\tBryon Aragam, University of California, Los Angeles\n",
"\tJiaying Gu, University of California, Los Angeles\n",
"\tDacheng Zhang, University of California, Los Angeles\n",
"\tQing Zhou, University of California, Los Angeles\n",
"\tFei Fu\n",
"\n",
Expand Down
3 changes: 1 addition & 2 deletions README.Rmd
Expand Up @@ -16,8 +16,7 @@ knitr::opts_chunk$set(

[![Travis-CI Build Status](https://travis-ci.org/itsrainingdata/sparsebn.svg?branch=master)](https://travis-ci.org/itsrainingdata/sparsebn)

Methods for learning sparse Bayesian networks and other graphical models from
high-dimensional data via sparse regularization. Designed to handle:
Methods for learning sparse Bayesian networks and other graphical models from high-dimensional data via sparse regularization. Designed to handle:

- Experimental data with interventions
- Mixed observational / experimental data
Expand Down
33 changes: 33 additions & 0 deletions cran-comments.md
@@ -0,0 +1,33 @@
## Test environments
* local OS X install, R 3.3.1
* ubuntu 12.04 (travis-ci), R 3.3.1
* win-builder (devel and release)

## R CMD check results
There were no ERRORs or WARNINGs.

There was 1 NOTE:

* checking CRAN incoming feasibility ... NOTE
Maintainer: ‘Bryon Aragam <sparsebn@gmail.com>

New submission

This is the first version of this package that has been submitted to CRAN.

## Re-submission notes
- I get

Reading CITATION file fails with
$ operator is invalid for atomic vectors
when package is not installed.

Fixed by replacing packageDecription with meta as described in Section 1.9 of R-exts.

## Dependencies

CHECK has been run on all dependencies and passed.

## Reverse dependencies

This is a new release, so there are no reverse dependencies.
Binary file added data/cytometryContinuous.rda
Binary file not shown.
Binary file modified data/cytometryDiscrete.rda
Binary file not shown.
Binary file modified data/pathfinder.rda
Binary file not shown.
18 changes: 18 additions & 0 deletions inst/CITATION
@@ -0,0 +1,18 @@
citHeader("To cite sparsebn in publications use:")

year <- sub(".*(2[[:digit:]]{3})-.*", "\\1", meta$Date, perl = TRUE)
vers <- paste("R package version", meta$Version)

citEntry(entry = "Manual",
title = "sparsebn: Learning Sparse Bayesian Networks from High-Dimensional Data",
author = personList(as.person("Bryon Aragam"), as.person("Jiaying Gu"), as.person("Dacheng Zhang"), as.person("Fei Fu"), as.person("Qing Zhou")),
year = year,
note = vers,
url = "https://github.com/itsrainingdata/sparsebn",
textVersion = paste0("Bryon Aragam, Jiaying Gu, Dacheng Zhang, Fei Fu, and Qing Zhou (", year, "). ",
"sparsebn: Learning Sparse Bayesian Networks from High-Dimensional Data. ",
vers, ".\n",
"https://github.com/itsrainingdata/sparsebn")
)

citFooter("A lot of effort has gone into building and maintaing the sparsebn package. Please cite it in all papers where it is used.")
30 changes: 30 additions & 0 deletions man/cytometryContinuous.Rd

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

12 changes: 9 additions & 3 deletions man/cytometryDiscrete.Rd

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

10 changes: 10 additions & 0 deletions man/estimate.covariance.Rd

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

10 changes: 10 additions & 0 deletions man/estimate.dag.Rd

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

36 changes: 32 additions & 4 deletions man/pathfinder.Rd

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

0 comments on commit 11ac9e0

Please sign in to comment.