Skip to content

Commit

Permalink
Version 1.3.1 with TravisCI and minor fixes (#42)
Browse files Browse the repository at this point in the history
* Adjust travis Makevars

* Use c++11 as c++14

* Use fpic compiler flag

* Changing R version to release

* Fix bug in examples

* Update retrieve_pars.Rd

* Update convert_signatures.Rd

* Documentation fixes

* Remove ggplot2 import

* Remove 'methods' dependency

* Shrink logo

* Fixed extract_signatures_initialiser

* Re-add methods dependency

* Minor changes to function docs

* Minor changes to function docs

* Prepare release 1.3.1

* Add TravisCI status badge

* Minor change

* Minor change

* Minor change
  • Loading branch information
baezortega authored and kgori committed Mar 29, 2019
1 parent 068b3e2 commit 37c3243
Show file tree
Hide file tree
Showing 17 changed files with 62 additions and 42 deletions.
12 changes: 8 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: r
sudo: false
r: devel
r: release
cache: packages

r_build_args: --no-build-vignettes
Expand All @@ -10,19 +10,23 @@ r_github_packages:
- jimhester/covr

env:
matrix:
matrix:
- CXX_OLEVEL=2 CXX=clang++

before_install:
- mkdir -p ~/.R/
- echo "CXX = `R CMD config CXX`" >> ~/.R/Makevars
- echo "CXXFLAGS = `R CMD config CXXFLAGS` -pedantic -g0" >> ~/.R/Makevars
- echo "CXXFLAGS = `R CMD config CXXFLAGS` -pedantic -g0 -fPIC" >> ~/.R/Makevars
- echo "CXX11FLAGS = `R CMD config CXXFLAGS` -pedantic -g0 -fPIC" >> ~/.R/Makevars
- echo "CXX14FLAGS = `R CMD config CXXFLAGS` -pedantic -g0 -fPIC" >> ~/.R/Makevars
- export CLANG_EXTRA_ARG=""
- if [[ $CXX = "clang++" ]] ; then export CLANG_EXTRA_ARG=" -Qunused-arguments -fcolor-diagnostics " ; fi
- sed -i.bak "s/ g++/ ${CXX}${CLANG_EXTRA_ARG}/" ~/.R/Makevars
- sed -i.bak "s/O[0-3]/O$CXX_OLEVEL/" ~/.R/Makevars
- echo "CXX11=${CXX} -std=c++11" >> ~/.R/Makevars
- echo "CXX14=${CXX} -std=c++11" >> ~/.R/Makevars

script:
script:
- |
travis_wait R CMD build .
travis_wait 60 R CMD check sigfit*tar.gz
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
CHANGE LOG

2019/03/29
Major changes introduced in v1.3.1

* Set up continuous integration with TravisCI (config file .travis.yml).
* Removed ggplot2 dependency.


2019/03/26
Major changes introduced in v1.3.0

Expand Down
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: sigfit
Type: Package
Title: Flexible Bayesian inference of mutational signatures
Version: 1.3.0
Date: 2019-03-26
Version: 1.3.1
Date: 2019-03-29
Authors@R: c(person("Kevin", "Gori", email = "kcg25@cam.ac.uk", role = c("aut", "cre")),
person("Adrian", "Baez-Ortega", email = "ab2324@cam.ac.uk", role = "aut"))
Description: This package implements Bayesian models for fitting and extracting
Expand All @@ -12,7 +12,7 @@ Description: This package implements Bayesian models for fitting and extracting
Monte Carlo sampling is done using Stan.
License: GPL (>=3)
Depends: R (>= 3.0.2), Rcpp (>= 0.12.9), methods
Imports: rstan (>= 2.14.1), coda (>= 0.19.1), ggplot2 (>= 2.2.1), clue (>= 0.3.54)
Imports: rstan (>= 2.14.1), coda (>= 0.19.1), clue (>= 0.3.54)
LinkingTo: StanHeaders (>= 2.14.0.1), rstan (>= 2.14.1), BH (>= 1.62.0.1),
Rcpp (>= 0.12.9), RcppEigen (>= 0.3.2.9.0)
RcppModules: stan_fit4sigfit_mod
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ importFrom("Rcpp",loadModule)
importFrom("clue",solve_LSAP)
importFrom("coda",HPDinterval)
importFrom("coda",as.mcmc)
importFrom("grDevices",cairo_pdf)
importFrom("grDevices",dev.off)
importFrom("grDevices",pdf)
importFrom("grDevices",rgb)
Expand All @@ -37,6 +38,7 @@ importFrom("graphics",par)
importFrom("graphics",plot)
importFrom("graphics",points)
importFrom("graphics",rect)
importFrom("graphics",segments)
importFrom("graphics",text)
importFrom("graphics",title)
importFrom("rstan",extract)
Expand Down
18 changes: 9 additions & 9 deletions R/sigfit_estimation.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#' \item{\code{$result}: object of class stanfit, containing the output MCMC samples,
#' as well as information about the model and sampling process.}}
#' The model parameters (such as signatures and exposures) can be extracted from this
#' object using \code{\link{retrieve_parameters}}.
#' object using \code{\link{retrieve_pars}}.
#' @examples
#' # Load example mutational catalogues and COSMIC signatures
#' data("counts_21breast")
Expand Down Expand Up @@ -126,7 +126,7 @@ fit_signatures <- function(counts, signatures, exp_prior = NULL, model = "nmf",
#' to be used as the Dirichlet priors for the signatures to be extracted. Only used when
#' \code{nsignatures} is a scalar. Default priors are uniform (uninformative).
#' @param chains Integer indicating number of chains to be initialised (default is 1).
#' @param ... Additional arguments to pass to \code{\link{rstan::optimizing}}.
#' @param ... Additional arguments to pass to \code{rstan::optimizing}.
#' @return List of initial values to be passed to \code{\link{extract_signatures}} via the
#' \code{init} argument.
#' @export
Expand All @@ -147,7 +147,7 @@ extract_signatures_initialiser <- function(counts, nsignatures, model = "emu", o
exposures = matrix(opt$par[grepl("exposures", names(opt$par))], nrow = nrow(counts))
)
inits = list()
for (i in 1:chains) inits[[i]] <- p
for (i in 1:chains) inits[[i]] <- params
}
inits
}
Expand Down Expand Up @@ -176,15 +176,15 @@ extract_signatures_initialiser <- function(counts, nsignatures, model = "emu", o
#' \code{"optimizing"} returns the Maximum a Posteriori (MAP) point estimates via numerical
#' optimization, while \code{"vb"} uses Variational Bayes to approximate the full posterior.
#' @param ... Any additional parameters to be passed to the sampling function (by default,
#' \code{\link{rstan::sampling}}). (Note that the number of chains is set to 1 and cannot
#' \code{rstan::sampling}). (Note that the number of chains is set to 1 and cannot
#' be changed, in order to prevent 'label switching' problems.)
#' @return A list with two elements:
#' \itemize{
#' \item{\code{\`data\`}: list containing the input data supplied to the model.}
#' \item{\code{\`result\`}: object of class stanfit, containing the output MCMC samples,
#' \item{\code{$data}: list containing the input data supplied to the model.}
#' \item{\code{$result}: object of class stanfit, containing the output MCMC samples,
#' as well as information about the model and sampling process.}}
#' The model parameters (such as signatures and exposures) can be extracted from this
#' object using \code{\link{retrieve_parameters}}.
#' object using \code{\link{retrieve_pars}}.
#' If a range of numbers of signatures is provided via the \code{nsignatures} argument, a list is returned where
#' the N-th element contains the extraction results for N signatures, as a list with the structure described above.
#' @examples
Expand Down Expand Up @@ -360,15 +360,15 @@ extract_signatures <- function(counts, nsignatures, model = "nmf", opportunities
#' \code{"sampling"}, which corresponds to the full Bayesian MCMC approach. Alternatively,
#' \code{"optimizing"} returns the Maximum a Posteriori (MAP) point estimates via numerical
#' optimization, while \code{"vb"} uses Variational Bayes to approximate the full posterior.
#' @param ... Any additional parameters to pass to the sampling function (by default, \code{\link{rstan::sampling}}).
#' @param ... Any additional parameters to pass to the sampling function (by default, \code{rstan::sampling}).
#' (Note that the number of chains is set to 1 and cannot be changed, to prevent 'label switching' problems.)
#' @return A list with two elements:
#' \itemize{
#' \item{\code{$data}: list containing the input data supplied to the model.}
#' \item{\code{$result}: object of class stanfit, containing the output MCMC samples,
#' as well as information about the model and sampling process.}}
#' The model parameters (such as signatures and exposures) can be extracted from this
#' object using \code{\link{retrieve_parameters}}.
#' object using \code{\link{retrieve_pars}}.
#' @examples
#' # Fetch COSMIC signatures
#' signatures <- fetch_cosmic_data()
Expand Down
10 changes: 7 additions & 3 deletions R/sigfit_plotting.R
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ plot_gof <- function(sample_list, stat = "cosine") {
#' \item{Signature exposures (via \code{\link{plot_exposures}})}
#' \item{All the reconstructed mutational spectra (via \code{\link{plot_reconstruction}})}
#' }
#' @param mcmc_samples List with elements \code{\`data\`} and \code{\`results\`}, produced via either
#' @param mcmc_samples List with elements \code{$data} and \code{$results}, produced via either
#' \code{\link{fit_signatures}}, \code{\link{extract_signatures}} or \code{\link{fit_extract_signatures}}.
#' This is the preferred option for supplying data and results, but can be replaced by the
#' combination of arguments \code{counts}, \code{signatures}, \code{exposures} and \code{opportunities}.
Expand Down Expand Up @@ -263,7 +263,7 @@ plot_all <- function(mcmc_samples = NULL, out_path, prefix = NULL, counts = NULL
#' stanfit object (generated via \code{\link{fit_signatures}} or \code{\link{extract_signatures}}),
#' or as separate signatures and exposures matrices (or lists produced via \code{\link{retrieve_pars}}).
#' Only the former option allows the incorporation of HPD intervals to the reconstructed catalogue.
#' @param mcmc_samples List with elements \code{\`data\`} and \code{\`results\`}, produced via either
#' @param mcmc_samples List with elements \code{$data} and \code{$results}, produced via either
#' \code{\link{fit_signatures}}, \code{\link{extract_signatures}} or \code{\link{fit_extract_signatures}}.
#' This is the preferred option for supplying data and results, but can be replaced by the
#' combination of arguments \code{counts}, \code{signatures}, \code{exposures} and \code{opportunities}.
Expand Down Expand Up @@ -311,6 +311,7 @@ plot_all <- function(mcmc_samples = NULL, out_path, prefix = NULL, counts = NULL
#' opportunities = "human-genome", pdf_path = "Reconstructions_2.pdf")
#' @importFrom "rstan" extract
#' @importFrom "coda" as.mcmc HPDinterval
#' @importFrom "grDevices" cairo_pdf
#' @export
plot_reconstruction <- function(mcmc_samples = NULL, pdf_path = NULL, counts = NULL,
signatures = NULL, exposures = NULL, opportunities = NULL,
Expand Down Expand Up @@ -620,6 +621,7 @@ plot_reconstruction <- function(mcmc_samples = NULL, pdf_path = NULL, counts = N
#'
#' # Plot signatures
#' plot_spectrum(sigs, pdf_path = "Signatures.pdf")
#' @importFrom "grDevices" cairo_pdf
#' @export
plot_spectrum <- function(spectra, pdf_path = NULL, pdf_width = 24,
pdf_height = 8, name = NULL, max_y = NULL) {
Expand Down Expand Up @@ -859,7 +861,7 @@ plot_spectrum <- function(spectra, pdf_path = NULL, pdf_width = 24,
#' Plot signature exposures
#'
#' \code{plot_exposures} plots the distribution of signature exposures across the samples.
#' @param mcmc_samples List with elements \code{\`data\`} and \code{\`results\`}, produced via either
#' @param mcmc_samples List with elements \code{$data} and \code{$results}, produced via either
#' \code{\link{fit_signatures}}, \code{\link{extract_signatures}} or \code{\link{fit_extract_signatures}}.
#' This is the preferred option for supplying data and results, but can be replaced by the
#' combination of arguments \code{counts}, \code{exposures} and \code{signature_names}.
Expand Down Expand Up @@ -908,6 +910,8 @@ plot_spectrum <- function(spectra, pdf_path = NULL, pdf_width = 24,
#' plot_exposures(counts = counts_21breast, exposures = exposures,
#' signature_names = rownames(cosmic_signatures),
#' pdf_path = "Exposures.pdf")
#' @importFrom "grDevices" cairo_pdf
#' @importFrom "graphics" segments
#' @export
plot_exposures <- function(mcmc_samples = NULL, pdf_path = NULL, counts = NULL, exposures = NULL,
signature_names = NULL, thresh = 0.01, hpd_prob = 0.95, pdf_width = 24,
Expand Down
10 changes: 5 additions & 5 deletions R/sigfit_utility.R
Original file line number Diff line number Diff line change
Expand Up @@ -367,17 +367,17 @@ fetch_cosmic_data <- function(reorder = TRUE, remove_zeros = TRUE) {
#' by the opportunities).
#' @return A numeric matrix of transformed signatures with the same dimensions as \code{signatures}.
#' @examples
#' # Fetch COSMIC signatures
#' # Load COSMIC signatures
#' # These are in "NMF" format, i.e. they are relative
#' # to the human genome mutational opportunities
#' signatures <- fetch_cosmic_data()
#' data("cosmic_signatures")
#'
#' # Plot COSMIC signature 1
#' barplot(signatures[1,])
#' barplot(cosmic_signatures[1,])
#'
#' # Convert signatures to the "EMu" format, i.e. make
#' # them not relative to mutational opportunities
#' converted_signatures <- convert_signatures(signatures,
#' converted_signatures <- convert_signatures(cosmic_signatures,
#' ref_opportunities = "human-genome",
#' model_to = "emu")
#'
Expand Down Expand Up @@ -450,7 +450,7 @@ convert_signatures <- function(signatures, ref_opportunities, model_to) {
#' # Plot signatures, reconstructions and mean exposures
#' plot_spectrum(signatures)
#' plot_spectrum(reconstructions)
#' barplot(exposures$mean)
#' barplot(t(exposures$mean))
#' @importFrom "rstan" extract
#' @importFrom "coda" HPDinterval
#' @importFrom "coda" as.mcmc
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<img src="logo.png" alt="drawing" width="480"/>
<p align="center"><img src="logo.png" alt="sigfit" width="700"/></p>

## Flexible Bayesian inference of mutational signatures

[![Build Status](https://travis-ci.org/kgori/sigfit.svg?branch=master)](https://travis-ci.org/kgori/sigfit)

### Flexible Bayesian inference of mutational signatures

sigfit is an R package to estimate signatures of mutational processes and their activities on mutation count data. Starting from a set of single-nucleotide variants (SNVs), it allows both estimation of the exposure of samples to predefined mutational signatures (including whether the signatures are present at all), and identification signatures _de novo_ from the mutation counts. These two procedures are often called, respectively, signature fitting and signature extraction. Furthermore, the signature fitting and extraction methods in sigfit can be seamlessly applied to mutational profiles beyond SNV data, including insertion/deletion (indel) or rearrangement count data. The package provides a range of functions to generate publication-quality graphics of the corresponding mutational catalogues, signatures and exposures.

Expand Down
8 changes: 4 additions & 4 deletions man/convert_signatures.Rd

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

8 changes: 4 additions & 4 deletions man/extract_signatures.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/extract_signatures_initialiser.Rd

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

4 changes: 2 additions & 2 deletions man/fit_extract_signatures.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/fit_signatures.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/plot_all.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/plot_exposures.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/plot_reconstruction.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/retrieve_pars.Rd

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

0 comments on commit 37c3243

Please sign in to comment.