Skip to content

Commit

Permalink
merge dev
Browse files Browse the repository at this point in the history
  • Loading branch information
evanbiederstedt committed Nov 8, 2021
2 parents e9f4b04 + bd6f6bd commit e0c0c37
Show file tree
Hide file tree
Showing 11 changed files with 82 additions and 17 deletions.
3 changes: 2 additions & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ CHANGELOG.md
^vignettes\figure$
docker
CONTRIBUTING.md
data-raw
data-raw
^\.circleci$
20 changes: 20 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: 2
jobs:
build:
docker:
- image: rocker/verse:4.0.3
environment:
_R_CHECK_FORCE_SUGGESTS_: false
steps:
- checkout
- run:
name: Install package dependencies
command: R -e "devtools::install_deps(dep = TRUE)"
- run:
name: Build package
command: R CMD build .
- run:
name: Check package
command: R CMD check --no-manual *tar.gz
- store_test_results:
path: tmp/tests
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
.RData
.Ruserdata
conos*.tar.gz
conos*Rcheck
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
## Upcoming

## [1.4.4] - 2021-11-08

### Changed
- Added `fail.on.error=TRUE` in some plapplys
- Re-added `getGeneExpression()` methods for Seurat (lost in merge 552408f)
- Switched to CircleCI


## [1.4.3] - 2021-02-08

### Changed
Expand Down
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: conos
Title: Clustering on Network of Samples
Version: 1.4.3
Version: 1.4.4
Authors@R: c(person("Viktor","Petukhov", email="[email protected]", role="aut"), person("Nikolas","Barkas", email="[email protected]", role="aut"), person("Peter", "Kharchenko", email = "[email protected]", role = "aut"), person("Weiliang", "Qiu", email = "[email protected]", role = c("ctb")), person("Evan", "Biederstedt", email="[email protected]", role=c("aut", "cre")))
Description: Wires together large collections of single-cell RNA-seq datasets, which allows for both the identification of recurrent cell clusters and the propagation of information between datasets in multi-sample or atlas-scale collections. 'Conos' focuses on the uniform mapping of homologous cell types across heterogeneous sample collections. For instance, users could investigate a collection of dozens of peripheral blood samples from cancer patients combined with dozens of controls, which perhaps includes samples of a related tissue such as lymph nodes. This package interacts with data available through the 'conosPanel' package, which is available in a 'drat' repository. To access this data package, see the instructions at <https://github.com/kharchenkolab/conos>. The size of the 'conosPanel' package is approximately 12 MB.
License: GPL-3
Expand Down Expand Up @@ -30,11 +30,11 @@ Imports:
reshape2,
rlang,
Rtsne,
sccore (> 0.1.2),
sccore (>= 1.0.0),
stats,
tools,
utils
RoxygenNote: 7.1.1
RoxygenNote: 7.1.2
Suggests:
AnnotationDbi,
BiocParallel,
Expand Down
23 changes: 23 additions & 0 deletions R/access_wrappers.R
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,29 @@ getGeneExpression.default <- function(sample, gene) {
return(stats::setNames(rep(NA, ncol(count.matrix)), colnames(count.matrix)))
}

#' @rdname getGeneExpression
setMethod("getGeneExpression", signature("Seurat"), function(sample, gene) {
checkSeuratV3()
## https://satijalab.org/seurat/essential_commands.html
if (gene %in% rownames(Seurat::GetAssayData(object = sample))){
## rownames(data) are gene names
return(Seurat::GetAssayData(object = sample)[gene, ])
}

return(stats::setNames(rep(NA, ncol(Seurat::GetAssayData(object = sample))), colnames(Seurat::GetAssayData(object = sample))))
})

#' @rdname getGeneExpression
setMethod("getGeneExpression", signature("seurat"), function(sample, gene) {
## https://satijalab.org/seurat/essential_commands.html
if (gene %in% rownames(sample@data)){
## rownames(data) are gene names
return(sample@data[gene, ])
}

return(stats::setNames(rep(NA, ncol(sample@data)), colnames(sample@data)))
})


#' Access raw count matrix from sample
#'
Expand Down
15 changes: 8 additions & 7 deletions R/conclass.R
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ Conos <- R6::R6Class("Conos", lock_objects=FALSE,
#' @return joint graph to be used for downstream analysis
#' @examples
#' con <- Conos$new(small_panel.preprocessed, n.cores=1)
#' con$buildGraph(k=10, k.self=5, space='PCA', ncomps=10, n.odgenes=20, matching.method='mNN',
#' con$buildGraph(k=10, k.self=5, space='PCA', ncomps=10, n.odgenes=20, matching.method='mNN',
#' metric='angular', score.component.variance=TRUE, verbose=TRUE)
#'
#'
Expand Down Expand Up @@ -381,7 +381,7 @@ Conos <- R6::R6Class("Conos", lock_objects=FALSE,
groups %<>% as.factor() %>% droplevels()
# TODO: add Seurat
'%ni%' <- Negate('%in%')
if ('Pagoda2' %ni% class(self$samples[[1]])){
if ('Pagoda2' %ni% class(self$samples[[1]])) {
stop("Only Pagoda2 objects are supported for marker genes")
}

Expand All @@ -396,7 +396,8 @@ Conos <- R6::R6Class("Conos", lock_objects=FALSE,

de.genes %<>% lapply(function(x) if ((length(x) > 0) && (nrow(x) > 0)) subset(x, complete.cases(x)) else x)
de.genes %<>% names() %>% setNames(., .) %>%
sccore::plapply(function(n) appendSpecificityMetricsToDE(de.genes[[n]], groups.clean, n, p2.counts=cm.merged, append.auc=append.auc), progress=verbose, n.cores=self$n.cores)
sccore::plapply(function(n) appendSpecificityMetricsToDE(de.genes[[n]], groups.clean, n, p2.counts=cm.merged, append.auc=append.auc),
progress=verbose, n.cores=self$n.cores, fail.on.error=TRUE)
}

if (verbose) message("All done!")
Expand All @@ -418,7 +419,7 @@ Conos <- R6::R6Class("Conos", lock_objects=FALSE,
#' @return invisible list containing identified communities (groups) and the full community detection result (result); The results are stored in $clusters$name slot in the conos object. Each such slot contains an object with elements: $results which stores the raw output of the community detection method, and $groups which is a factor on cells describing the resulting clustering. The later can be used, for instance, in plotting: con$plotGraph(groups=con$clusters$leiden$groups). If test.stability==TRUE, then the result object will also contain a $stability slot.
#' @examples
#' con <- Conos$new(small_panel.preprocessed, n.cores=1)
#' con$buildGraph(k=10, k.self=5, space='PCA', ncomps=10, n.odgenes=20, matching.method='mNN',
#' con$buildGraph(k=10, k.self=5, space='PCA', ncomps=10, n.odgenes=20, matching.method='mNN',
#' metric='angular', score.component.variance=TRUE, verbose=TRUE)
#' con$findCommunities(method = igraph::walktrap.community, steps=5)
#'
Expand Down Expand Up @@ -851,7 +852,7 @@ Conos <- R6::R6Class("Conos", lock_objects=FALSE,
#' @param count.matrix Alternative gene count matrix to correct (rows: genes, columns: cells; has to be dense matrix). Default: joint count matrix for all datasets.
#' @param normalize boolean Whether to normalize values (default=TRUE)
#' @return smoothed expression of the input genes
#'
#'
correctGenes=function(genes=NULL, n.od.genes=500, fading=10.0, fading.const=0.5, max.iters=15, tol=5e-3, name='diffusion', verbose=TRUE, count.matrix=NULL, normalize=TRUE) {
edges <- igraph::as_edgelist(self$graph)
edge.weights <- igraph::edge.attributes(self$graph)$weight
Expand Down Expand Up @@ -1065,7 +1066,7 @@ Conos <- R6::R6Class("Conos", lock_objects=FALSE,
if(any(is.na(mi))) { # some pairs are missing
if(verbose) message('running ',sum(is.na(mi)),' additional ',space,' space pairs ')
xl2 <- sccore::plapply(which(is.na(mi)), function(i) {
if(space=='CPCA') {
if (space=='CPCA') {
xcp <- quickCPCA(self$samples[sn.pairs[,i]],data.type=data.type,ncomps=ncomps,n.odgenes=n.odgenes,verbose=FALSE,var.scale=var.scale, score.component.variance=score.component.variance)
} else if(space=='JNMF') {
xcp <- quickJNMF(self$samples[sn.pairs[,i]],data.type=data.type,n.comps=ncomps,n.odgenes=n.odgenes,var.scale=var.scale,verbose=FALSE,max.iter=3e3)
Expand All @@ -1078,7 +1079,7 @@ Conos <- R6::R6Class("Conos", lock_objects=FALSE,
}
if(verbose) cat(".")
xcp
}, n.cores=self$n.cores, mc.preschedule=(space=='PCA'), progress=FALSE)
}, n.cores=self$n.cores, mc.preschedule=(space=='PCA'), progress=FALSE, fail.on.error=TRUE)

names(xl2) <- apply(sn.pairs[,which(is.na(mi)),drop=FALSE],2,paste,collapse='.vs.')
xl2 <- xl2[!unlist(lapply(xl2,is.null))]
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Build Status](https://travis-ci.com/kharchenkolab/conos.svg?branch=master)](https://travis-ci.com/github/kharchenkolab/conos)
[![<kharchenkolab>](https://circleci.com/gh/kharchenkolab/conos.svg?style=svg)](https://app.circleci.com/pipelines/github/kharchenkolab/conos)
[![CRAN status](https://www.r-pkg.org/badges/version/conos)](https://cran.r-project.org/package=conos)
[![CRAN downloads](https://cranlogs.r-pkg.org/badges/conos)](https://cran.r-project.org/package=conos)

Expand Down Expand Up @@ -238,5 +238,5 @@ The R package can be cited as:
```
Viktor Petukhov, Nikolas Barkas, Peter Kharchenko, and Evan
Biederstedt (2021). conos: Clustering on Network of Samples. R
package version 1.4.3.
package version 1.4.4.
```
8 changes: 4 additions & 4 deletions man/Conos.Rd

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

6 changes: 6 additions & 0 deletions man/getGeneExpression.Rd

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

5 changes: 5 additions & 0 deletions src/RcppExports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,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

// RjnmfC
arma::field<arma::mat> RjnmfC(arma::mat Xs, arma::mat Xu, int k, double alpha, double lambda, double epsilon, int maxiter, bool verbose);
RcppExport SEXP _conos_RjnmfC(SEXP XsSEXP, SEXP XuSEXP, SEXP kSEXP, SEXP alphaSEXP, SEXP lambdaSEXP, SEXP epsilonSEXP, SEXP maxiterSEXP, SEXP verboseSEXP) {
Expand Down

0 comments on commit e0c0c37

Please sign in to comment.