Skip to content

Commit

Permalink
minor additions and bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
edward130603 committed Nov 4, 2021
1 parent 75fe41b commit cd2c155
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 9 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: BayesSpace
Version: 1.5.0
Date: 2021-08-05
Version: 1.5.1
Date: 2021-11-03
Title: Clustering and Resolution Enhancement of Spatial Transcriptomes
Authors@R: c(
person("Edward", "Zhao", role=c("aut"), email="[email protected]"),
Expand Down
24 changes: 22 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
# BayesSpace 1.5.1

## Minor improvements and fixes

- Update `readVisium` to work properly when feature names include whitespaces
- Fix rounding of w_i sum in MCMC
- Add details to vignette related to `spatialEnhance`

# BayesSpace 1.5.0

## New Bioconductor devel (3.15)

- Version numbering change with Bioconductor version bump

# BayesSpace 1.4.0

## New Bioconductor release (3.14)

- Version numbering change with Bioconductor version bump

# BayesSpace 1.3.1

## Minor improvements and fixes
Expand All @@ -13,9 +33,9 @@

# BayesSpace 1.2.0

## Minor improvements and fixes
## New Bioconductor release (3.12)

- Stable Bioconductor release 3.12
- Version numbering change with Bioconductor version bump

# BayesSpace 1.1.2

Expand Down
4 changes: 2 additions & 2 deletions R/readVisium.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ readVisium <- function(dirname) {
rownames(colData) <- colData$spot
colData <- colData[colData$in_tissue > 0, ]

rowData <- read.table(file.path(matrix_dir, "features.tsv.gz"), header=FALSE)
rowData <- read.table(file.path(matrix_dir, "features.tsv.gz"), header=FALSE, sep = "\t")
colnames(rowData) <- c("gene_id", "gene_name", "feature_type")
rowData <- rowData[, c("gene_id", "gene_name")]
rownames(rowData) <- scater::uniquifyFeatureNames(rowData$gene_id, rowData$gene_name)

counts <- Matrix::readMM(file.path(matrix_dir, "matrix.mtx.gz"))
barcodes <- read.table(file.path(matrix_dir, "barcodes.tsv.gz"), header=FALSE)
barcodes <- read.table(file.path(matrix_dir, "barcodes.tsv.gz"), header=FALSE, sep = "\t")
colnames(counts) <- barcodes$V1
rownames(counts) <- rownames(rowData)
counts <- counts[, rownames(colData)]
Expand Down
5 changes: 5 additions & 0 deletions src/RcppExports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@

using namespace Rcpp;

#ifdef RCPP_USE_GLOBAL_ROSTREAM
Rcpp::Rostream<true>& Rcpp::Rcout = Rcpp::Rcpp_cout_get();
Rcpp::Rostream<false>& Rcpp::Rcerr = Rcpp::Rcpp_cerr_get();
#endif

// iterate
List iterate(arma::mat Y, List df_j, int nrep, int n, int d, double gamma, int q, arma::vec init, NumericVector mu0, arma::mat lambda0, double alpha, double beta);
RcppExport SEXP _BayesSpace_iterate(SEXP YSEXP, SEXP df_jSEXP, SEXP nrepSEXP, SEXP nSEXP, SEXP dSEXP, SEXP gammaSEXP, SEXP qSEXP, SEXP initSEXP, SEXP mu0SEXP, SEXP lambda0SEXP, SEXP alphaSEXP, SEXP betaSEXP) {
Expand Down
6 changes: 3 additions & 3 deletions src/cluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ List iterate_t(arma::mat Y, List df_j, int nrep, int n, int d, double gamma, int
NumericVector Ysums;
for (int k = 1; k <= q; k++){
uvec index_1k = find(df_sim_z.row(i-1) == k);
int n_i = sum(w(index_1k));
double n_i = sum(w(index_1k));
mat Yrows = Y.rows(index_1k);
Yrows.each_col() %= w(index_1k);
Ysums = sum(Yrows, 0);
Expand Down Expand Up @@ -359,7 +359,7 @@ List iterate_t_vvv(arma::mat Y, List df_j, int nrep, int n, int d, double gamma,
NumericVector Ysums;
for (int k = 1; k <= q; k++){
uvec index_1k = find(df_sim_z.row(i-1) == k);
int n_i = sum(w(index_1k));
double n_i = sum(w(index_1k));
mat Yrows = Y.rows(index_1k);
Yrows.each_col() %= w(index_1k);
Ysums = sum(Yrows, 0);
Expand Down Expand Up @@ -489,7 +489,7 @@ List iterate_deconv(arma::mat Y, List df_j, bool tdist, int nrep, int n, int n0,
NumericVector Ysums;
for (int k = 1; k <= q; k++){
uvec index_1k = find(z == k);
int n_i = sum(w(index_1k));
double n_i = sum(w(index_1k));
mat Yrows = Y.rows(index_1k);
Yrows.each_col() %= w(index_1k);
Ysums = sum(Yrows, 0);
Expand Down
7 changes: 7 additions & 0 deletions vignettes/BayesSpace.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,13 @@ components, and add these PCs as well as predicted cluster labels at subspot
resolution to a new `SingleCellExperiment`. As with our demonstration of
`spatialCluster()` above, we are using fewer iterations for the purpose of this
example (`nrep=1000`) than we recommend in practice (`nrep=100000` or greater).
Note that the `jitter_scale` parameter should be tuned so that proposals for
updating subspot-level expression are accepted around 30% of the time. This can
be evaluated using `mcmcChain(melanoma.enhanced, "Ychange")`, where the chain
should stabilize to 0.25-0.40. Typically 1000-2500 iterations are sufficient to
evaluate if `jitter_scale` should be increased if acceptance is too high or
decreased if acceptance is too low. After tuning, proceed to a full run of
`spatialEnhance` with more iterations.

```{r enhance, eval=TRUE}
melanoma.enhanced <- spatialEnhance(melanoma, q=4, platform="ST", d=7,
Expand Down

0 comments on commit cd2c155

Please sign in to comment.