Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
itsrainingdata committed Nov 29, 2016
2 parents b3183ab + c746fca commit 6837a09
Show file tree
Hide file tree
Showing 21 changed files with 374 additions and 159 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -8,3 +8,5 @@ src/*.dll
#man/*.Rd
*.tar.gz
inst/doc
*.pdf

8 changes: 3 additions & 5 deletions .travis.yml
Expand Up @@ -22,8 +22,6 @@ r:
# BiocInstaller required for 'graph' package from Bioconductor
bioc_required: true

# Install up-to-date dependencies from GitHub
r_github_packages:
- itsrainingdata/sparsebnUtils
- itsrainingdata/ccdrAlgorithm
- gujyjean/discretecdAlgorithm
# Set CXX1X for R-devel, as R-devel does not detect CXX1X support for gcc 4.6.3
before_install:
- if [[ "$TRAVIS_R_VERSION_STRING" = 'devel' ]]; then mkdir ~/.R && echo 'CXX1X=g++ -std=c++0x -g -O2 -fPIC' > ~/.R/Makevars; fi
10 changes: 5 additions & 5 deletions DESCRIPTION
@@ -1,15 +1,15 @@
Package: sparsebn
Title: Learning Sparse Bayesian Networks from High-Dimensional Data
Version: 0.0.1
Date: 2016-08-12
Version: 0.0.2
Date: 2016-11-28
Authors@R: person("Bryon", "Aragam", email = "sparsebn@gmail.com", role = c("aut", "cre"))
Maintainer: Bryon Aragam <sparsebn@gmail.com>
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,
ccdrAlgorithm,
discretecdAlgorithm
sparsebnUtils (>= 0.0.3),
ccdrAlgorithm (>= 0.0.2),
discretecdAlgorithm (>= 0.0.2)
Suggests:
knitr,
rmarkdown,
Expand Down
7 changes: 7 additions & 0 deletions NAMESPACE
@@ -1,8 +1,15 @@
# Generated by roxygen2: do not edit by hand

S3method(plotDAG,edgeList)
S3method(plotDAG,sparsebnFit)
S3method(plotDAG,sparsebnPath)
export(estimate.covariance)
export(estimate.dag)
export(estimate.precision)
export(plotDAG)
import(ccdrAlgorithm)
import(discretecdAlgorithm)
import(sparsebnUtils)
importFrom(grDevices,gray)
importFrom(grDevices,rgb)
importFrom(graphics,plot)
16 changes: 16 additions & 0 deletions NEWS.md
@@ -0,0 +1,16 @@
# sparsebn 0.0.2

## Features
* Added a `NEWS.md` file to track changes to the package
* Added plotDAG to provide convenient default for plotting large graphs
* `estimate.dag` now takes an optional logical argument `adaptive`: If `TRUE`, then an adaptive version of the CD algorithm will be run for discrete data. This argument is ignored for continuous data.
* Vignette updated and re-written

## Bug fixes

* Cytometry data has been fixed to correct some errors in the network structure; now correctly reflects the network learned in Sachs et al. (2005)

# sparsebn 0.0.1

* Initial stable release

9 changes: 6 additions & 3 deletions R/sparsebn-main.R
Expand Up @@ -40,6 +40,7 @@
#' @param weight.scale (CD only) A postitive number to scale weight matrix.
#' @param convLb (CD only) Small positive number used in Hessian approximation.
#' @param upperbound (CD only) A large positive value used to truncate the adaptive weights. A -1 value indicates that there is no truncation.
#' @param adaptive (CD only) \code{TRUE / FALSE}, if \code{TRUE} the adaptive algorithm will be run.
#' @param verbose \code{TRUE / FALSE} whether or not to print out progress and summary reports.
#'
#' @return A \code{\link[sparsebnUtils]{sparsebnPath}} object.
Expand All @@ -49,7 +50,7 @@
#' \dontrun{
#' # Estimate a DAG from the cytometry data
#' data(cytometryContinuous)
#' dat <- sparsebnData(cytometryContinuous$data, type = "d", ivn = cytometryContinuous$ivn)
#' dat <- sparsebnData(cytometryContinuous$data, type = "c", ivn = cytometryContinuous$ivn)
#' estimate.dag(dat)
#' }
#'
Expand All @@ -64,6 +65,7 @@ estimate.dag <- function(data,
weight.scale = 1.0,
convLb = 0.01,
upperbound = 100.0,
adaptive = FALSE,
verbose = FALSE
){
pp <- ncol(data$data)
Expand Down Expand Up @@ -107,7 +109,8 @@ estimate.dag <- function(data,
error.tol = error.tol,
convLb = convLb,
weight.scale = weight.scale,
upperbound = upperbound)
upperbound = upperbound,
adaptive = adaptive)
}
}

Expand All @@ -132,7 +135,7 @@ estimate.dag <- function(data,
#'
#' \dontrun{
#' data(cytometryContinuous)
#' dat <- sparsebnData(cytometryContinuous$data, type = "d", ivn = cytometryContinuous$ivn)
#' dat <- sparsebnData(cytometryContinuous$data, type = "c", ivn = cytometryContinuous$ivn)
#' estimate.covariance(dat) # estimate covariance
#' estimate.precision(dat) # estimate precision
#' }
Expand Down
83 changes: 83 additions & 0 deletions R/sparsebn-plotting.R
@@ -0,0 +1,83 @@
#
# sparsebn-plotting.R
# sparsebn
#
# Created by Bryon Aragam (local) on 10/2/16.
# Copyright (c) 2016 Bryon Aragam. All rights reserved.
#

#
# PACKAGE SPARSEBN: Default methods for plotting DAGs
#
# CONTENTS:
# plotDAG
# plotDAG.edgeList
# plotDAG.sparsebnFit
# plotDAG.sparsebnPath
#

#' Plot a DAG
#'
#' Using some sensible defaults for large graphs, plot a DAG object. Uses \code{\link[igraph]{igraph}}
#' package by default.
#'
#' This method is not intended for customization. For more control over the output, use
#' \code{\link{plot}} and see \code{\link{setPlotPackage}} for plotting only and/or
#' \code{\link{setGraphPackage}} for even more control. These methods grants the user the full
#' feature set of the selected package.
#'
#' @param x An \code{\link{edgeList}}, \code{\link{sparsebnFit}}, or \code{\link{sparsebnPath}} object.
#' @param ... Additional arguments to \code{\link{plot}}.
#'
#' @export
plotDAG <- function(x){
### Must use igraph for the default method
current_plot_pkg <- getPlotPackage()
if(current_plot_pkg != "igraph"){
err_msg <- sprintf("This method requires that the 'igraph' package be set as your plotting package. You are currently set to use the '%s' package instead. Please set this packge to be 'igraph', or use the default plot() method from the %s package instead. See ?setPlotPackage for more details.", current_plot_pkg, current_plot_pkg)
stop(err_msg)
}

UseMethod("plotDAG", x)
}

#' @export
plotDAG.edgeList <- function(x, ...){

#
# Note that the defaults used here are not the same as for sparsebnPath!
#
plot(x,
vertex.size = 4,
vertex.label = NA,
vertex.label.color = gray(0),
vertex.color = rgb(1,0,0),
edge.width = 1,
edge.color = gray(0),
edge.arrow.size = 0.5,
...)
}

#' @export
plotDAG.sparsebnFit <- function(x, ...){
plotDAG(x$edges, ...)
}

#' @export
plotDAG.sparsebnPath <- function(x, ...){

#
# This method does not delegate directly to sparsebnFit because
# plotting a grid of graphs requires a different visual layout.
#

plot(x,
vertex.size = 4,
vertex.label = NA,
vertex.label.color = gray(0),
vertex.color = rgb(1,0,0),
edge.width = 0.5,
edge.color = gray(0),
edge.arrow.size = 0.15,
...)
}
4 changes: 3 additions & 1 deletion R/zzz.R
Expand Up @@ -7,10 +7,12 @@
#

#' @import sparsebnUtils ccdrAlgorithm discretecdAlgorithm
#' @importFrom grDevices gray rgb
#' @importFrom graphics plot

.onAttach <- function(libname, pkgname){
msg <- paste0("\n",
"sparsebn v0.0.1, Copyright (c) 2016\n",
"sparsebn v0.0.2, 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",
Expand Down
2 changes: 2 additions & 0 deletions README.Rmd
Expand Up @@ -15,6 +15,8 @@ knitr::opts_chunk$set(
# sparsebn

[![Travis-CI Build Status](https://travis-ci.org/itsrainingdata/sparsebn.svg?branch=master)](https://travis-ci.org/itsrainingdata/sparsebn)
[![](http://www.r-pkg.org/badges/version/sparsebn)](http://www.r-pkg.org/pkg/sparsebn)
[![CRAN RStudio mirror downloads](http://cranlogs.r-pkg.org/badges/sparsebn)](http://www.r-pkg.org/pkg/sparsebn)

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

Expand Down
2 changes: 1 addition & 1 deletion README.md
@@ -1,7 +1,7 @@
sparsebn
========

[![Travis-CI Build Status](https://travis-ci.org/itsrainingdata/sparsebn.svg?branch=master)](https://travis-ci.org/itsrainingdata/sparsebn)
[![Travis-CI Build Status](https://travis-ci.org/itsrainingdata/sparsebn.svg?branch=master)](https://travis-ci.org/itsrainingdata/sparsebn) [![](http://www.r-pkg.org/badges/version/sparsebn)](http://www.r-pkg.org/pkg/sparsebn) [![CRAN RStudio mirror downloads](http://cranlogs.r-pkg.org/badges/sparsebn)](http://www.r-pkg.org/pkg/sparsebn)

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

Expand Down
26 changes: 6 additions & 20 deletions cran-comments.md
@@ -1,33 +1,19 @@
## Test environments
* local OS X install, R 3.3.1
* ubuntu 12.04 (travis-ci), R 3.3.1
* local OS X install, R 3.3.2
* ubuntu 12.04.5 (travis-ci), R 3.3.2 (oldrel, devel, and release)
* win-builder (devel and release)

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

There was 1 NOTE:
## CRAN notes

* 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.
The current warnings listed for v0.0.1 at https://cran.rstudio.com/web/checks/check_results_sparsebn.html are a result of recent updates to the dependencies for this submission. The current submission remedies all of these issues.

## Dependencies

CHECK has been run on all dependencies and passed.

## Reverse dependencies

This is a new release, so there are no reverse dependencies.
There are no reverse dependencies.
Binary file modified 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.
2 changes: 1 addition & 1 deletion man/estimate.covariance.Rd

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

7 changes: 5 additions & 2 deletions man/estimate.dag.Rd

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

24 changes: 24 additions & 0 deletions man/plotDAG.Rd

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

0 comments on commit 6837a09

Please sign in to comment.