Skip to content

Commit

Permalink
Merge branch 'develop' into release/visium
Browse files Browse the repository at this point in the history
  • Loading branch information
mojaveazure committed Dec 4, 2019
2 parents 0945b7e + 21aa9c4 commit b6e7a22
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 26 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: Seurat
Version: 3.1.1.9021
Date: 2019-11-19
Version: 3.1.1.9023
Date: 2019-12-04
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
6 changes: 3 additions & 3 deletions R/differential_expression.R
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ FindAllMarkers <- function(
return(cond$message)
}
)
if (class(x = genes.de[[i]]) == "character") {
if (is.character(x = genes.de[[i]])) {
messages[[i]] <- genes.de[[i]]
genes.de[[i]] <- NULL
}
Expand Down Expand Up @@ -233,7 +233,7 @@ FindConservedMarkers <- function(
verbose = TRUE,
...
) {
if (class(x = meta.method) != "function") {
if (!is.function(x = meta.method)) {
stop("meta.method should be a function from the metap package. Please see https://cran.r-project.org/web/packages/metap/metap.pdf for a detailed description of the available functions.")
}
object.var <- FetchData(object = object, vars = grouping.var)
Expand Down Expand Up @@ -1412,7 +1412,7 @@ NBModelComparison <- function(y, theta, latent.data, com.fac, grp.fac) {
),
silent = TRUE
)
if (class(x = fit2)[1] == 'numeric' | class(x = fit4)[1] == 'numeric') {
if (is.numeric(x = fit2) || is.numeric(x = fit4)) {
message('One of the glm.nb calls failed')
return(c(rep(x = NA, 5), freqs))
}
Expand Down
4 changes: 2 additions & 2 deletions R/objects.R
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ CreateSeuratObject <- function(
warning("Some cells in meta.data not present in provided counts matrix.")
meta.data <- meta.data[intersect(x = rownames(x = meta.data), y = colnames(x = counts)), ]
}
if (class(x = meta.data) == "data.frame") {
if (is.data.frame(x = meta.data)) {
new.meta.data <- data.frame(row.names = colnames(x = counts))
for (ii in 1:ncol(x = meta.data)) {
new.meta.data[rownames(x = meta.data), colnames(x = meta.data)[ii]] <- meta.data[, ii, drop = FALSE]
Expand Down Expand Up @@ -6355,7 +6355,7 @@ setMethod( # because R doesn't allow S3-style [[<- for S4 classes
)
}
# Check keyed objects
if (class(x = value) %in% c('Assay', 'DimReduc')) {
if (inherits(x = value, what = c('Assay', 'DimReduc'))) {
if (length(x = Key(object = value)) == 0) {
Key(object = value) <- paste0(tolower(x = i), '_')
} else if (!grepl(pattern = '^[[:alnum:]]+_$', x = Key(object = value))) {
Expand Down
35 changes: 17 additions & 18 deletions R/preprocessing.R
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ CalculateBarcodeInflections <- function(
}
)$x
## workaround for aggregate behavior noted above
if (class(x = whichmin_list) == 'list') { # uneven lengths
if (is.list(x = whichmin_list)) { # uneven lengths
is_inflection <- unlist(x = whichmin_list)
} else if (class(x = whichmin_list) == 'matrix') { # even lengths
} else if (is.matrix(x = whichmin_list)) { # even lengths
is_inflection <- as.vector(x = t(x = whichmin_list))
}
tmp <- cbind(barcode_dist_sub, is_inflection)
Expand Down Expand Up @@ -191,15 +191,15 @@ CreateGeneActivityMatrix <- function(
peak.df <- as.data.frame(x = peak.df)
colnames(x = peak.df) <- c("chromosome", 'start', 'end')
peaks.gr <- GenomicRanges::makeGRangesFromDataFrame(df = peak.df)

# if any peaks start at 0, change to 1
# otherwise GenomicRanges::distanceToNearest will not work
# otherwise GenomicRanges::distanceToNearest will not work
BiocGenerics::start(peaks.gr[BiocGenerics::start(peaks.gr) == 0, ]) <- 1

# get annotation file, select genes
gtf <- rtracklayer::import(con = annotation.file)
gtf <- GenomeInfoDb::keepSeqlevels(x = gtf, value = seq.levels, pruning.mode = 'coarse')

# change seqlevelsStyle if not the same
if (!any(GenomeInfoDb::seqlevelsStyle(x = gtf) == GenomeInfoDb::seqlevelsStyle(x = peaks.gr))) {
GenomeInfoDb::seqlevelsStyle(gtf) <- GenomeInfoDb::seqlevelsStyle(peaks.gr)
Expand All @@ -216,11 +216,11 @@ CreateGeneActivityMatrix <- function(
keep.overlaps <- gene.distances[rtracklayer::mcols(x = gene.distances)$distance == 0]
peak.ids <- peaks.gr[S4Vectors::queryHits(x = keep.overlaps)]
gene.ids <- gtf.genes[S4Vectors::subjectHits(x = keep.overlaps)]

# Some GTF rows will not have gene_name attribute
# Replace it by gene_id attribute
gene.ids$gene_name[is.na(gene.ids$gene_name)] <- gene.ids$gene_id[is.na(gene.ids$gene_name)]

peak.ids$gene.name <- gene.ids$gene_name
peak.ids <- as.data.frame(x = peak.ids)
peak.ids$peak <- rownames(peak.matrix)[S4Vectors::queryHits(x = keep.overlaps)]
Expand Down Expand Up @@ -584,10 +584,10 @@ GetResidual <- function(
#' mat_norm
#'
LogNormalize <- function(data, scale.factor = 1e4, verbose = TRUE) {
if (class(x = data) == "data.frame") {
if (is.data.frame(x = data)) {
data <- as.matrix(x = data)
}
if (class(x = data) != "dgCMatrix") {
if (!inherits(x = data, what = 'dgCMatrix')) {
data <- as(object = data, Class = "dgCMatrix")
}
# call Rcpp function to normalize
Expand Down Expand Up @@ -1068,10 +1068,10 @@ Read10X_h5 <- function(filename, use.names = TRUE, unique.features = TRUE) {
#' mat_norm
#'
RelativeCounts <- function(data, scale.factor = 1, verbose = TRUE) {
if (class(x = data) == "data.frame") {
if (is.data.frame(x = data)) {
data <- as.matrix(x = data)
}
if (class(x = data) != "dgCMatrix") {
if (!inherits(x = data, what = 'dgCMatrix')) {
data <- as(object = data, Class = "dgCMatrix")
}
if (verbose) {
Expand Down Expand Up @@ -1422,10 +1422,10 @@ SubsetByBarcodeInflections <- function(object) {
#' mat_norm <- TF.IDF(data = mat)
#'
TF.IDF <- function(data, verbose = TRUE) {
if (class(x = data) == "data.frame") {
if (is.data.frame(x = data)) {
data <- as.matrix(x = data)
}
if (class(x = data) != "dgCMatrix") {
if (!inherits(x = data, what = 'dgCMatrix')) {
data <- as(object = data, Class = "dgCMatrix")
}
if (verbose) {
Expand Down Expand Up @@ -2116,7 +2116,7 @@ RunALRA.Seurat <- function(

#' @importFrom future nbrOfWorkers
#'
#' @param features Vector of features names to scale/center. Default is all features
#' @param features Vector of features names to scale/center. Default is variable features.
#' @param vars.to.regress Variables to regress out (previously latent.vars in
#' RegressOut). For example, nUMI, or percent.mito.
#' @param latent.data Extra data to regress out, should be cells x latent data
Expand Down Expand Up @@ -2505,7 +2505,6 @@ ClassifyCells <- function(data, q) {
message("No threshold found for ", colnames(x = data)[i], "...")
}
)
# if (class(x = model) == "character") {
if (is.character(x = model)) {
next
}
Expand Down Expand Up @@ -2572,10 +2571,10 @@ ClassifyCells <- function(data, q) {
# @import Matrix
#
CustomNormalize <- function(data, custom_function, margin, verbose = TRUE) {
if (class(x = data) == "data.frame") {
if (is.data.frame(x = data)) {
data <- as.matrix(x = data)
}
if (class(x = data) != "dgCMatrix") {
if (!inherits(x = data, what = 'dgCMatrix')) {
data <- as(object = data, Class = "dgCMatrix")
}
myapply <- ifelse(test = verbose, yes = pbapply, no = apply)
Expand Down Expand Up @@ -2785,7 +2784,7 @@ NBResiduals <- function(fmla, regression.mat, gene, return.mode = FALSE) {
data = regression.mat
),
silent = TRUE)
if (class(fit)[1] == 'numeric') {
if (is.numeric(x = fit)) {
message(sprintf('glm.nb failed for gene %s; falling back to scale(log(y+1))', gene))
resid <- scale(x = log(x = regression.mat[, 'GENE'] + 1))[, 1]
mode <- 'scale'
Expand Down
2 changes: 1 addition & 1 deletion man/ScaleData.Rd

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

0 comments on commit b6e7a22

Please sign in to comment.