Skip to content

Commit

Permalink
Merge pull request #2605 from satijalab/develop
Browse files Browse the repository at this point in the history
Seurat v3.1.3
  • Loading branch information
mojaveazure committed Feb 11, 2020
2 parents 49a1be0 + c772da1 commit 87e2454
Show file tree
Hide file tree
Showing 25 changed files with 509 additions and 218 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
@@ -1,6 +1,6 @@
Package: Seurat
Version: 3.1.2
Date: 2019-12-12
Version: 3.1.3
Date: 2020-02-07
Title: Tools for Single Cell Genomics
Description: A toolkit for quality control, analysis, and exploration of single cell RNA sequencing data. 'Seurat' aims to enable users to identify and interpret sources of heterogeneity from single cell transcriptomic measurements, and to integrate diverse types of single cell data. See Satija R, Farrell J, Gennert D, et al (2015) <doi:10.1038/nbt.3192>, Macosko E, Basu A, Satija R, et al (2015) <doi:10.1016/j.cell.2015.05.002>, and Butler A and Satija R (2017) <doi:10.1101/164889> for more details.
Authors@R: c(
Expand Down Expand Up @@ -57,7 +57,6 @@ Imports:
Rtsne,
scales,
sctransform (>= 0.2.0),
SDMTools,
stats,
tools,
tsne,
Expand Down Expand Up @@ -86,6 +85,7 @@ Encoding: UTF-8
biocViews:
Suggests:
loomR,
SDMTools,
testthat,
hdf5r,
S4Vectors,
Expand Down
3 changes: 2 additions & 1 deletion NAMESPACE
Expand Up @@ -199,6 +199,7 @@ export(DefaultAssay)
export(DietSeurat)
export(DimHeatmap)
export(DimPlot)
export(DiscretePalette)
export(DoHeatmap)
export(DotPlot)
export(ElbowPlot)
Expand Down Expand Up @@ -357,7 +358,6 @@ importFrom(RcppAnnoy,AnnoyEuclidean)
importFrom(RcppAnnoy,AnnoyHamming)
importFrom(RcppAnnoy,AnnoyManhattan)
importFrom(Rtsne,Rtsne)
importFrom(SDMTools,pnt.in.poly)
importFrom(ape,as.phylo)
importFrom(ape,drop.tip)
importFrom(ape,nodelabels)
Expand All @@ -379,6 +379,7 @@ importFrom(ggplot2,coord_cartesian)
importFrom(ggplot2,coord_fixed)
importFrom(ggplot2,coord_flip)
importFrom(ggplot2,cut_number)
importFrom(ggplot2,discrete_scale)
importFrom(ggplot2,dup_axis)
importFrom(ggplot2,element_blank)
importFrom(ggplot2,element_line)
Expand Down
12 changes: 12 additions & 0 deletions NEWS.md
Expand Up @@ -2,6 +2,18 @@
All notable changes to Seurat will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)

## [3.1.3] = 2020-02-07
### Added
- New system agnostic `Which` function to address problems with FItSNE on Windows

### Changes
- Export `CellsByIdentities` and `RowMergeSparseMatrices` functions
- nCount and nFeature metadata variables retained after subset and updated properly with `UpdateSeuratObject`
- Fix uwot support for running directly on feature matrices
- Fixes for keys with underscores
- Fix issue with leiden option for `FindClusters`
- Fix for data transfer when using sctransform
- SDMTools moved to Suggests as package is orphaned

## [3.1.2] - 2019-12-11
### Added
Expand Down
52 changes: 29 additions & 23 deletions R/clustering.R
Expand Up @@ -713,29 +713,35 @@ RunLeiden <- function(
call. = FALSE
)
}
if (method %in% c("matrix", "igraph")) {
if (method == "igraph") {
object <- graph_from_adjacency_matrix(adjmatrix = object)
}
} else {
warning(
"method for Leiden recommended as 'matrix' or 'igraph'",
call. = FALSE,
immediate. = TRUE
)
}
input <- if (inherits(x = object, what = 'list')) {
graph_from_adj_list(adjlist = object)
} else if (inherits(x = object, what = c('dgCMatrix', 'matrix', "Matrix"))) {
graph_from_adjacency_matrix(adjmatrix = object)
} else if (inherits(x = object, what = 'igraph')) {
object
} else {
stop(
paste("method for Leiden not found for class", class(x = object)),
call. = FALSE
)
}
switch(
EXPR = method,
"matrix" = {
input <- as(object = object, Class = "matrix")
},
"igraph" = {
input <- if (inherits(x = object, what = 'list')) {
if (is.null(x = weights)) {
graph_from_adj_list(adjlist = object)
} else {
graph_from_adj_list(adjlist = object)
}
} else if (inherits(x = object, what = c('dgCMatrix', 'matrix', "Matrix"))) {
if (is.null(x = weights)) {
graph_from_adjacency_matrix(adjmatrix = object)
} else {
graph_from_adjacency_matrix(adjmatrix = object, weighted = TRUE)
}
} else if (inherits(x = object, what = 'igraph')) {
object
} else {
stop(
"Method for Leiden not found for class", class(x = object),
call. = FALSE
)
}
},
stop("Method for Leiden must be either 'matrix' or igraph'")
)
#run leiden from CRAN package (calls python with reticulate)
partition <- leiden(
object = input,
Expand Down
21 changes: 7 additions & 14 deletions R/differential_expression.R
Expand Up @@ -437,7 +437,7 @@ FindConservedMarkers <- function(
#' @param pseudocount.use Pseudocount to add to averaged expression values when
#' calculating logFC. 1 by default.
#'
#' @importFrom Matrix rowSums
#' @importFrom Matrix rowSums rowMeans
#' @importFrom stats p.adjust
#'
#' @rdname FindMarkers
Expand Down Expand Up @@ -540,25 +540,18 @@ FindMarkers.default <- function(
switch(
EXPR = slot,
'data' = function(x) {
return(log(x = mean(x = expm1(x = x)) + pseudocount.use))
return(log(x = rowMeans(x = expm1(x = x)) + pseudocount.use))
},
function(x) {
return(log(x = mean(x = x) + pseudocount.use))
return(log(x = rowMeans(x = x) + pseudocount.use))
}
)
} else {
mean
rowMeans
}
data.1 <- apply(
X = data[features, cells.1, drop = FALSE],
MARGIN = 1,
FUN = mean.fxn
)
data.2 <- apply(
X = data[features, cells.2, drop = FALSE],
MARGIN = 1,
FUN = mean.fxn
)
data.1 <- mean.fxn(data[features, cells.1, drop = FALSE])
data.2 <- mean.fxn(data[features, cells.2, drop = FALSE])

total.diff <- (data.1 - data.2)
if (is.null(x = reduction) && slot != "scale.data") {
features.diff <- if (only.pos) {
Expand Down
31 changes: 28 additions & 3 deletions R/dimensional_reduction.R
Expand Up @@ -861,7 +861,7 @@ RunPCA.default <- function(
return(reduction.data)
}

#' @param features Features to compute PCA on. If features=NULL, PCA will be run
#' @param features Features to compute PCA on. If features=NULL, PCA will be run
#' using the variable features for the Assay. Note that the features must be present
#' in the scaled data. Any requested features that are not scaled or have 0 variance
#' will be dropped, and the PCA will be run using the remaining features.
Expand Down Expand Up @@ -1456,10 +1456,30 @@ RunUMAP.Seurat <- function(
stop("Please specify only one of the following arguments: dims, features, or graph")
}
if (!is.null(x = features)) {
data.use <- t(x = GetAssayData(object = object, slot = 'data', assay = assay)[features, ])
data.use <- as.matrix(x = t(x = GetAssayData(object = object, slot = 'data', assay = assay)[features, , drop = FALSE]))
if (ncol(x = data.use) < n.components) {
stop(
"Please provide as many or more features than n.components: ",
length(x = features),
" features provided, ",
n.components,
" UMAP components requested",
call. = FALSE
)
}
} else if (!is.null(x = dims)) {
data.use <- Embeddings(object[[reduction]])[, dims]
assay <- DefaultAssay(object = object[[reduction]])
if (length(x = dims) < n.components) {
stop(
"Please provide as many or more dims than n.components: ",
length(x = dims),
" dims provided, ",
n.components,
" UMAP components requested",
call. = FALSE
)
}
} else if (!is.null(x = graph)) {
data.use <- object[[graph]]
} else {
Expand Down Expand Up @@ -1703,7 +1723,12 @@ fftRtsne <- function(X,
result_path <- tempfile(pattern = 'fftRtsne_result_', fileext = '.dat')
}
if (is.null(x = fast_tsne_path)) {
suppressWarnings(expr = fast_tsne_path <- system2(command = 'which', args = 'fast_tsne', stdout = TRUE))
# suppressWarnings(expr = fast_tsne_path <- system2(command = 'which', args = 'fast_tsne', stdout = TRUE))
fast_tsne_path <- SysExec(progs = ifelse(
test = .Platform$OS.type == 'windows',
yes = 'FItSNE.exe',
no = 'fast_tsne'
))
if (length(x = fast_tsne_path) == 0) {
stop("no fast_tsne_path specified and fast_tsne binary is not in the search path")
}
Expand Down
3 changes: 0 additions & 3 deletions R/generics.R
Expand Up @@ -764,9 +764,6 @@ RunALRA <- function(object, ...) {
#'
#' @return Returns a combined Seurat object with the CCA results stored.
#'
#' @rdname RunCCA
#' @export RunCCA
#'
#' @seealso \code{\link{merge.Seurat}}
#'
#' @examples
Expand Down

0 comments on commit 87e2454

Please sign in to comment.