Skip to content

Commit

Permalink
version 2.13.5 (2023-09-20)
Browse files Browse the repository at this point in the history
- Minor update in no-spikes code to avoid re-calculating a constant quantity.
Does not affect output.
  • Loading branch information
catavallejos committed Sep 20, 2023
1 parent 70ab48a commit 1c8eab5
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 42 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: BASiCS
Type: Package
Title: Bayesian Analysis of Single-Cell Sequencing data
Version: 2.13.4
Date: 2023-06-26
Version: 2.13.5
Date: 2023-09-20
Authors@R: c(person("Catalina", "Vallejos", role=c("aut", "cre"),
email="[email protected]",
comment=c(ORCID = "0000-0003-3638-1960")),
Expand Down
6 changes: 5 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -1678,4 +1678,8 @@ version 2.13.2 (2023-06-16)
- Changes `LazyData` to `true` to avoid errors

version 2.13.3 (2023-06-16)
- Reverts `LazyData` to `false` based on BiocCheck feedback
- Reverts `LazyData` to `false` based on BiocCheck feedback

version 2.13.5 (2023-09-20)
- Minor update in no-spikes code to avoid re-calculating a constant quantity.
Does not affect output.
2 changes: 1 addition & 1 deletion R/BASiCS_MCMC.R
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ BASiCS_MCMC <- function(

NoSpikeArgs <- list(
sumByCellAll = sum.bycell.all,
Constrain = ArgsDef$Constrain,
SizeTimesConstrain = length(ArgsDef$ConstrainGene) * ArgsDef$Constrain,
Index = ArgsDef$Index,
RefGene = ArgsDef$RefGene,
RefGenes = ArgsDef$RefGenes,
Expand Down
16 changes: 8 additions & 8 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
.Call('_BASiCS_BASiCS_MCMCcpp', PACKAGE = 'BASiCS', N, Thin, Burn, Counts, BatchDesign, muSpikes, mu0, delta0, phi0, s0, nu0, theta0, mu_mu, s2mu, adelta, bdelta, s2delta, prior_delta, aphi, as, bs, atheta, btheta, ar, LSmu0, LSdelta0, LSphi0, LSnu0, LStheta0, sumByCellBio, sumByGeneAll, sumByGeneBio, StoreAdapt, EndAdapt, PrintProgress, mintol_mu, mintol_delta, mintol_nu, mintol_theta, geneExponent, cellExponent, threads)
}

.BASiCS_MCMCcppNoSpikes <- function(N, Thin, Burn, Counts, BatchDesign, mu0, delta0, s0, nu0, theta0, mu_mu, s2mu, adelta, bdelta, s2delta, prior_delta, as, bs, atheta, btheta, Constrain, Index, RefGene, RefGenes, ConstrainGene, NotConstrainGene, StochasticRef, ar, LSmu0, LSdelta0, LSnu0, LStheta0, sumByCellAll, sumByGeneAll, StoreAdapt, EndAdapt, PrintProgress, mintol_mu, mintol_delta, mintol_nu, mintol_theta, geneExponent, cellExponent, fixNu, threads = 1L) {
.Call('_BASiCS_BASiCS_MCMCcppNoSpikes', PACKAGE = 'BASiCS', N, Thin, Burn, Counts, BatchDesign, mu0, delta0, s0, nu0, theta0, mu_mu, s2mu, adelta, bdelta, s2delta, prior_delta, as, bs, atheta, btheta, Constrain, Index, RefGene, RefGenes, ConstrainGene, NotConstrainGene, StochasticRef, ar, LSmu0, LSdelta0, LSnu0, LStheta0, sumByCellAll, sumByGeneAll, StoreAdapt, EndAdapt, PrintProgress, mintol_mu, mintol_delta, mintol_nu, mintol_theta, geneExponent, cellExponent, fixNu, threads)
.BASiCS_MCMCcppNoSpikes <- function(N, Thin, Burn, Counts, BatchDesign, mu0, delta0, s0, nu0, theta0, mu_mu, s2mu, adelta, bdelta, s2delta, prior_delta, as, bs, atheta, btheta, SizeTimesConstrain, Index, RefGene, RefGenes, ConstrainGene, NotConstrainGene, StochasticRef, ar, LSmu0, LSdelta0, LSnu0, LStheta0, sumByCellAll, sumByGeneAll, StoreAdapt, EndAdapt, PrintProgress, mintol_mu, mintol_delta, mintol_nu, mintol_theta, geneExponent, cellExponent, fixNu, threads = 1L) {
.Call('_BASiCS_BASiCS_MCMCcppNoSpikes', PACKAGE = 'BASiCS', N, Thin, Burn, Counts, BatchDesign, mu0, delta0, s0, nu0, theta0, mu_mu, s2mu, adelta, bdelta, s2delta, prior_delta, as, bs, atheta, btheta, SizeTimesConstrain, Index, RefGene, RefGenes, ConstrainGene, NotConstrainGene, StochasticRef, ar, LSmu0, LSdelta0, LSnu0, LStheta0, sumByCellAll, sumByGeneAll, StoreAdapt, EndAdapt, PrintProgress, mintol_mu, mintol_delta, mintol_nu, mintol_theta, geneExponent, cellExponent, fixNu, threads)
}

.BASiCS_MCMCcppReg <- function(N, Thin, Burn, Counts, BatchDesign, muSpikes, mu0, delta0, phi0, s0, nu0, theta0, mu_mu, s2mu, aphi, as, bs, atheta, btheta, k, m0, V0, sigma2_a0, sigma2_b0, beta0, sigma20, eta0, lambda0, variance, ar, LSmu0, LSdelta0, LSphi0, LSnu0, LStheta0, sumByCellBio, sumByGeneAll, sumByGeneBio, StoreAdapt, EndAdapt, PrintProgress, FixLocations, RBFMinMax, RBFLocations, mintol_mu, mintol_delta, mintol_nu, mintol_theta, geneExponent, cellExponent, threads = 1L) {
.Call('_BASiCS_BASiCS_MCMCcppReg', PACKAGE = 'BASiCS', N, Thin, Burn, Counts, BatchDesign, muSpikes, mu0, delta0, phi0, s0, nu0, theta0, mu_mu, s2mu, aphi, as, bs, atheta, btheta, k, m0, V0, sigma2_a0, sigma2_b0, beta0, sigma20, eta0, lambda0, variance, ar, LSmu0, LSdelta0, LSphi0, LSnu0, LStheta0, sumByCellBio, sumByGeneAll, sumByGeneBio, StoreAdapt, EndAdapt, PrintProgress, FixLocations, RBFMinMax, RBFLocations, mintol_mu, mintol_delta, mintol_nu, mintol_theta, geneExponent, cellExponent, threads)
}

.BASiCS_MCMCcppRegNoSpikes <- function(N, Thin, Burn, Counts, BatchDesign, mu0, delta0, s0, nu0, theta0, mu_mu, s2mu, as, bs, atheta, btheta, k, m0, V0, sigma2_a0, sigma2_b0, beta0, sigma20, eta0, lambda0, variance, Constrain, Index, RefGene, RefGenes, ConstrainGene, NotConstrainGene, StochasticRef, ar, LSmu0, LSdelta0, LSnu0, LStheta0, sumByCellAll, sumByGeneAll, StoreAdapt, EndAdapt, PrintProgress, RBFMinMax, FixLocations, RBFLocations, mintol_mu, mintol_delta, mintol_nu, mintol_theta, geneExponent, cellExponent, fixNu, threads = 1L) {
.Call('_BASiCS_BASiCS_MCMCcppRegNoSpikes', PACKAGE = 'BASiCS', N, Thin, Burn, Counts, BatchDesign, mu0, delta0, s0, nu0, theta0, mu_mu, s2mu, as, bs, atheta, btheta, k, m0, V0, sigma2_a0, sigma2_b0, beta0, sigma20, eta0, lambda0, variance, Constrain, Index, RefGene, RefGenes, ConstrainGene, NotConstrainGene, StochasticRef, ar, LSmu0, LSdelta0, LSnu0, LStheta0, sumByCellAll, sumByGeneAll, StoreAdapt, EndAdapt, PrintProgress, RBFMinMax, FixLocations, RBFLocations, mintol_mu, mintol_delta, mintol_nu, mintol_theta, geneExponent, cellExponent, fixNu, threads)
.BASiCS_MCMCcppRegNoSpikes <- function(N, Thin, Burn, Counts, BatchDesign, mu0, delta0, s0, nu0, theta0, mu_mu, s2mu, as, bs, atheta, btheta, k, m0, V0, sigma2_a0, sigma2_b0, beta0, sigma20, eta0, lambda0, variance, SizeTimesConstrain, Index, RefGene, RefGenes, ConstrainGene, NotConstrainGene, StochasticRef, ar, LSmu0, LSdelta0, LSnu0, LStheta0, sumByCellAll, sumByGeneAll, StoreAdapt, EndAdapt, PrintProgress, RBFMinMax, FixLocations, RBFLocations, mintol_mu, mintol_delta, mintol_nu, mintol_theta, geneExponent, cellExponent, fixNu, threads = 1L) {
.Call('_BASiCS_BASiCS_MCMCcppRegNoSpikes', PACKAGE = 'BASiCS', N, Thin, Burn, Counts, BatchDesign, mu0, delta0, s0, nu0, theta0, mu_mu, s2mu, as, bs, atheta, btheta, k, m0, V0, sigma2_a0, sigma2_b0, beta0, sigma20, eta0, lambda0, variance, SizeTimesConstrain, Index, RefGene, RefGenes, ConstrainGene, NotConstrainGene, StochasticRef, ar, LSmu0, LSdelta0, LSnu0, LStheta0, sumByCellAll, sumByGeneAll, StoreAdapt, EndAdapt, PrintProgress, RBFMinMax, FixLocations, RBFLocations, mintol_mu, mintol_delta, mintol_nu, mintol_theta, geneExponent, cellExponent, fixNu, threads)
}

.muUpdate <- function(mu0, prop_var, Counts, invdelta, phinu, sum_bycell_bio, mu_mu, s2_mu, q0, n, mu1, u, ind, exponent, mintol) {
Expand All @@ -45,8 +45,8 @@
.Call('_BASiCS_thetaUpdateBatch', PACKAGE = 'BASiCS', theta0, prop_var, BatchDesign, BatchSizes, s, nu, a_theta, b_theta, n, nBatch, exponent, mintol)
}

.muUpdateNoSpikes <- function(mu0, prop_var, Counts, invdelta, nu, sum_bycell_all, mu_mu, s2_mu, q0, n, mu1, u, ind, Constrain, RefGene, ConstrainGene, NotConstrainGene, exponent, mintol) {
.Call('_BASiCS_muUpdateNoSpikes', PACKAGE = 'BASiCS', mu0, prop_var, Counts, invdelta, nu, sum_bycell_all, mu_mu, s2_mu, q0, n, mu1, u, ind, Constrain, RefGene, ConstrainGene, NotConstrainGene, exponent, mintol)
.muUpdateNoSpikes <- function(mu0, prop_var, Counts, invdelta, nu, sum_bycell_all, mu_mu, s2_mu, q0, n, mu1, u, ind, SizeTimesConstrain, RefGene, ConstrainGene, NotConstrainGene, exponent, mintol) {
.Call('_BASiCS_muUpdateNoSpikes', PACKAGE = 'BASiCS', mu0, prop_var, Counts, invdelta, nu, sum_bycell_all, mu_mu, s2_mu, q0, n, mu1, u, ind, SizeTimesConstrain, RefGene, ConstrainGene, NotConstrainGene, exponent, mintol)
}

.nuUpdateBatchNoSpikes <- function(nu0, prop_var, Counts, BatchDesign, mu, invdelta, s, thetaBatch, sum_bygene_all, q0, n, nu1, u, ind, exponent, mintol) {
Expand Down Expand Up @@ -81,8 +81,8 @@
.Call('_BASiCS_lambdaUpdateReg', PACKAGE = 'BASiCS', delta, X, beta, sigma2, eta, q0, lambda1, exponent)
}

.muUpdateRegNoSpikes <- function(mu0, prop_var, Counts, delta, invdelta, nu, sum_bycell_all, mu_mu, s2_mu, q0, n, mu1, u, ind, Constrain, RefGene, ConstrainGene, NotConstrainGene, k, lambda, beta, X, sigma2, variance, FixLocations, RBFMinMax, RBFLocations, exponent, mintol) {
.Call('_BASiCS_muUpdateRegNoSpikes', PACKAGE = 'BASiCS', mu0, prop_var, Counts, delta, invdelta, nu, sum_bycell_all, mu_mu, s2_mu, q0, n, mu1, u, ind, Constrain, RefGene, ConstrainGene, NotConstrainGene, k, lambda, beta, X, sigma2, variance, FixLocations, RBFMinMax, RBFLocations, exponent, mintol)
.muUpdateRegNoSpikes <- function(mu0, prop_var, Counts, delta, invdelta, nu, sum_bycell_all, mu_mu, s2_mu, q0, n, mu1, u, ind, SizeTimesConstrain, RefGene, ConstrainGene, NotConstrainGene, k, lambda, beta, X, sigma2, variance, FixLocations, RBFMinMax, RBFLocations, exponent, mintol) {
.Call('_BASiCS_muUpdateRegNoSpikes', PACKAGE = 'BASiCS', mu0, prop_var, Counts, delta, invdelta, nu, sum_bycell_all, mu_mu, s2_mu, q0, n, mu1, u, ind, SizeTimesConstrain, RefGene, ConstrainGene, NotConstrainGene, k, lambda, beta, X, sigma2, variance, FixLocations, RBFMinMax, RBFLocations, exponent, mintol)
}

.deltaUpdateRegNoSpikes <- function(delta0, prop_var, Counts, mu, nu, q0, n, delta1, u, ind, lambda, X, sigma2, beta, exponent, mintol) {
Expand Down
9 changes: 7 additions & 2 deletions src/MCMCNoSpikes.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Rcpp::List BASiCS_MCMCcppNoSpikes(
double bs,
double atheta,
double btheta,
double Constrain,
double SizeTimesConstrain,
arma::vec Index,
int RefGene,
arma::vec RefGenes,
Expand Down Expand Up @@ -244,8 +244,11 @@ Rcpp::List BASiCS_MCMCcppNoSpikes(
arma::randi(1, arma::distr_param(0, RefGenes.size() - 1))
);
RefGene = RefGenes(RefAux);
Rcpp::Rcout << "RefGene: " << RefGene << std::endl;

if (i >= Burn) RefFreq(RefGene) += 1;
}

muAux = muUpdateNoSpikes(
muAux.col(0),
exp(LSmuAux),
Expand All @@ -260,7 +263,7 @@ Rcpp::List BASiCS_MCMCcppNoSpikes(
y_q0,
u_q0,
ind_q0,
Constrain,
SizeTimesConstrain,
RefGene,
ConstrainGene_uvec,
NotConstrainGene_uvec,
Expand All @@ -270,6 +273,7 @@ Rcpp::List BASiCS_MCMCcppNoSpikes(
PmuAux += muAux.col(1);
if(i>=Burn) {muAccept += muAux.col(1);}


// UPDATE OF DELTA:
// 1st COLUMN IS THE UPDATE,
// 2nd COLUMN IS THE ACCEPTANCE INDICATOR
Expand Down Expand Up @@ -363,6 +367,7 @@ Rcpp::List BASiCS_MCMCcppNoSpikes(
}
}


// PRINT IN CONSOLE SAMPLED VALUES FOR FEW SELECTED PARAMETERS
if((i%(2*Thin) == 0) & (PrintProgress == 1)) {
CurrentIter(i, N);
Expand Down
8 changes: 6 additions & 2 deletions src/MCMCRegNoSpikes.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Rcpp::List BASiCS_MCMCcppRegNoSpikes(
double eta0,
arma::vec lambda0,
double const& variance,
double Constrain,
double SizeTimesConstrain,
arma::vec Index,
int RefGene,
arma::vec RefGenes,
Expand Down Expand Up @@ -286,6 +286,9 @@ Rcpp::List BASiCS_MCMCcppRegNoSpikes(
RefFreq(RefGene) += 1;
}
}
Rcpp::Rcout << "Iteration: " << i << std::endl;
Rcpp::Rcout << "RefGene: " << RefGene+1 << std::endl;
Rcpp::Rcout << "RefGene before update: " << muAux(0, 0) << std::endl;
muAux = muUpdateRegNoSpikes(
muAux.col(0),
exp(LSmuAux),
Expand All @@ -300,7 +303,7 @@ Rcpp::List BASiCS_MCMCcppRegNoSpikes(
y_q0,
u_q0,
ind_q0,
Constrain,
SizeTimesConstrain,
RefGene,
ConstrainGene_uvec,
NotConstrainGene_uvec,
Expand All @@ -317,6 +320,7 @@ Rcpp::List BASiCS_MCMCcppRegNoSpikes(
mintol_mu
);
PmuAux += muAux.col(1); if(i>=Burn) muAccept += muAux.col(1);
Rcout << "RefGene after update: " << muAux(RefGene, 0) << std::endl;

// UPDATE OF DELTA:
// 1st COLUMN IS THE UPDATE,
Expand Down
Loading

0 comments on commit 1c8eab5

Please sign in to comment.