Skip to content

Commit

Permalink
Changes for CRAN submission
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiyu committed Dec 12, 2023
1 parent 69f5f44 commit b4a805e
Show file tree
Hide file tree
Showing 21 changed files with 175 additions and 62 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@
^docs$
^pkgdown$
^vignettes/articles$
^\.github$
^cran-comments\.md$
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
49 changes: 49 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: R-CMD-check

jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
- {os: macos-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check

- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
50 changes: 50 additions & 0 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: test-coverage

jobs:
test-coverage:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::covr
needs: coverage

- name: Test coverage
run: |
covr::codecov(
quiet = FALSE,
clean = FALSE,
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
)
shell: Rscript {0}

- name: Show testthat output
if: always()
run: |
## --------------------------------------------------------------------
find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload test results
if: failure()
uses: actions/upload-artifact@v3
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package
17 changes: 11 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
Package: SpaTopic
Type: Package
Title: topic inference to identify tissue architecture in multiplexed images
Title: Topic Inference to Identify Tissue Architecture in Multiplexed Images
Version: 0.99
Date: 2023-12-20
Author: Xiyu Peng
Maintainer: Xiyu Peng <[email protected]>
Description: Fast topic inference to identify tissue architecture across multiplexed images.
Compared to other KNN-based methods, SpaTopic runs much faster on large-scale image data.
Description: A novel spatial topic model to integrate both cell type and spatial
information to identify the complex spatial tissue architectures on
multiplexed tissue images without human intervention. The Package
implements a Collapsed Gibbs sampling algorithm for inference.
Contrasting to computationally intensive K-nearest-neighbor-based
cell neighborhood analysis approaches, SpaTopic is more scalable
to large-scale image datasets without extracting neighborhood
information for every single cell.
License: GPL (>= 3)
Depends: R (>= 3.5.0),
Rcpp (>= 0.12.0),
RcppArmadillo (>= 0.12.0),
RANN (>= 2.6.0),
Imports: sf (>= 1.0-12),
Imports: RANN (>= 2.6.0),
sf (>= 1.0-12),
methods (>= 3.4),
foreach (>= 1.5.0),
iterators (>= 1.0),
Expand Down
3 changes: 0 additions & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

export(Seurat5obj_to_SpaTopic)
export(SpaTopic_inference)
export(gibbs_spatial_LDA_multiple)
export(stratified_sampling_sf)
exportPattern("^[[:alpha:]]+")
import(RcppArmadillo)
import(foreach)
importFrom(RANN,nn2)
importFrom(Rcpp,evalCpp)
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# SpaTopic 0.99

* Version under development
* The Version under development
15 changes: 8 additions & 7 deletions R/Gibbs_sampler.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ beta_est<-function(Nwk, beta){
apply(Nwk + beta, 1, '/', Nk + n.words * beta)
}

#'@export
gibbs_spatial_LDA_multiple<-function(...){
SpaTopic_inference(...)
}
Expand Down Expand Up @@ -104,19 +103,21 @@ gibbs_spatial_LDA_multiple<-function(...){
#'
#' ## tissue is a data frame containing cellular information from one image or
#' ## multiple data frames from multiple images.
#'
#' data("lung5")
#' gibbs.res<-SpaTopic_inference(lung5, ntopics = 7,
#' sigma = 50, region_radius = 400)
#' ## NOT RUN, it takes about 90s
#' #gibbs.res<-SpaTopic_inference(lung5, ntopics = 7,
#' # sigma = 50, region_radius = 400)
#'
#'
#' ## example for multiple images
#' ## Make a fake image 2, NOT RUN
#' ## generate a fake image 2 and make an example for multiple images
#' ## NOT RUN
#' #lung6<-lung5
#' #lung6$image<-"image2"
#' #lung6$image<-"image2" ## The image ID of two images should be different
#' #gibbs.res<-SpaTopic_inference(list(A = lung5, B = lung6),
#' # ntopics = 7, sigma = 50, region_radius = 400)
#'
#' @export
#'
SpaTopic_inference<-function(tissue, ntopics, sigma = 50, region_radius = 400, kneigh = 5,
npoints_selected = 1, ini_LDA = TRUE, ninit = 10,
niter_init = 100, beta = .05, alpha = .01,
Expand Down
2 changes: 0 additions & 2 deletions R/SpaTopic-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@
#' @keywords package
#'
#' @importFrom Rcpp evalCpp
#' @import RcppArmadillo
#'
#' @useDynLib SpaTopic
#' @exportPattern "^[[:alpha:]]+"
NA

1 change: 0 additions & 1 deletion R/prepare_SpaTopic_input.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#' @seealso \code{\link{lung5}}
#'
#' @export
#'
Seurat5obj_to_SpaTopic<-function(object,group.by,image = "image1"){

if (!requireNamespace("SeuratObject", quietly = TRUE)) {
Expand Down
1 change: 0 additions & 1 deletion R/spatial_func.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ GetCoords <- function(tissue,axis = "2D") {
#' pt_idx<-stratified_sampling_sf(lung5, cellsize = c(600,600))
#'
#' @export
#'
stratified_sampling_sf <- function(points, cellsize = c(600,600), num_samples_per_stratum = 1) {

# Convert points to an sf object
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
SpaTopic
=======

<!-- badges: start -->
[![R-CMD-check](https://github.com/xiyupeng/SpaTopic/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/xiyupeng/SpaTopic/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->

An R package for fast topic inference to identify tissue architecture in multiplexed images.
It implements a spatial topic model to identify immunologic topics across multiplexed images, given the cell location and cell type information as input.
Collapsed Gibbs Sampling algorithm is used for model inference.
Expand All @@ -9,7 +13,7 @@ Compared to other KNN-based methods (such as KNN-kmeans, the default in Seurat v

## Installation

`SpaTopic` can be installed from the GitHub repository using the devtools package.
`SpaTopic` can be installed from the [GitHub repository](https://github.com/xiyupeng/SpaTopic) using the devtools package.

``` r
# install.packages("devtools")
Expand Down
5 changes: 5 additions & 0 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## R CMD check results

0 errors | 0 warnings | 1 note

* This is a new release.
3 changes: 2 additions & 1 deletion docs/articles/SpaTopic.html

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

4 changes: 2 additions & 2 deletions docs/authors.html

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

27 changes: 20 additions & 7 deletions docs/index.html

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

2 changes: 1 addition & 1 deletion docs/news/index.html

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

2 changes: 1 addition & 1 deletion docs/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ articles:
Model_Selection: Model_Selection.html
SpaTopic: SpaTopic.html
Intro_SpaTopic: Intro_SpaTopic.html
last_built: 2023-12-12T16:08Z
last_built: 2023-12-12T19:28Z

Loading

0 comments on commit b4a805e

Please sign in to comment.