Skip to content

Commit 5b99e7d

Browse files
authored
Merge pull request #72 from YosefLab/staging
Staging
2 parents d6458f2 + 5b5e1c8 commit 5b99e7d

File tree

146 files changed

+269
-154
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+269
-154
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: VISION
22
Title: Functional interpretation of single cell RNA-seq latent manifolds
3-
Version: 2.0.0
3+
Version: 2.1.0
44
Authors@R: c(person("Matt", "Jones", email = "mattjones315@gmail.com", role = c("aut", "cre")),
55
person("David", "Detomaso", email = "david.detomaso@berkeley.edu", role = c("aut", "cre")),
66
person("Tal", "Ashuach", email = "tal_ashuach@berkeley.edu", role = c("aut")),

NEWS.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# VISION 2.1.0
2+
3+
Added parameter `sig_gene_threshold` with **changed default behavior**
4+
5+
* Before it was a guideline to filter lowly expressed genes before running VISION
6+
* Now, by default, genes expressed in fewer than 0.1% of cells will be filtered automatically
7+
8+
Bug Fixes:
9+
10+
* Better colors in output when more than 10 categories
11+
* Errors with certain output object accessors
12+
* Selections not saving when loading results server
13+
* Crashes when running on more than 1200 signatures
14+
115
# VISION 2.0.0
216

317
Lots of changes for this version.

R/AnalysisFunctions.R

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,11 @@ computeProjectionGenes <- function(object,
211211
#' on creating Signature objects.
212212
#' @param min_signature_genes Signature that match less than this number of genes in the
213213
#' supplied expression matrix are removed.
214+
#' @param sig_gene_threshold Proportion of cells that a gene must be detected in (nonzero)
215+
#' to be used in signature score calculations.
214216
#' @return the VISION object, with the @sigData slot updated
215217
#' @export
216-
addSignatures <- function(object, signatures, min_signature_genes=5) {
218+
addSignatures <- function(object, signatures, min_signature_genes=5, sig_gene_threshold=.01) {
217219

218220
if (is.list(signatures)) {
219221
sigs <- lapply(signatures, function(sig){
@@ -237,7 +239,7 @@ addSignatures <- function(object, signatures, min_signature_genes=5) {
237239
Signature objects")
238240
}
239241

240-
sigs <- processSignatures(sigs, rownames(object@exprData), min_signature_genes)
242+
sigs <- processSignatures(sigs, object@exprData, min_signature_genes, sig_gene_threshold)
241243

242244
object@sigData <- c(object@sigData, sigs)
243245

R/NormalizationMethods.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,17 +110,20 @@ getNormalizedCopySparse <- function(data, func) {
110110
if (func == "znorm_rows" || func == "znorm_rows_then_columns") {
111111
rowOffsets <- rowMeans(data) * -1
112112
rowScaleFactors <- rowVarsSp(data) ** -0.5
113+
rowScaleFactors[is.infinite(rowScaleFactors)] <- 1
113114
}
114115

115116
if (func == "znorm_columns") {
116117
colOffsets <- colMeans(data) * -1
117118
colScaleFactors <- colVarsSp(data) ** -0.5
119+
colScaleFactors[is.infinite(colScaleFactors)] <- 1
118120
}
119121

120122
if (func == "znorm_rows_then_columns") {
121123
result <- .colNormHelper(data, rowOffsets, rowScaleFactors)
122124
colOffsets <- result$colOffsets
123125
colScaleFactors <- result$colScaleFactors
126+
colScaleFactors[is.infinite(colScaleFactors)] <- 1
124127
}
125128

126129
nd <- NormData(data, rowOffsets = rowOffsets, colOffsets = colOffsets,

R/methods-Signature.R

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,31 @@
44
#' Drops signatures with less than `minSignatureGenes` matching genes
55
#'
66
#' @param sigData list of signature objects
7-
#' @param expressionGenes list of gene identifiers in the expression matrix
7+
#' @param exprData gene expression matrix
88
#' @param minSignatureGenes minimum number of genes a signature must match
99
#' in the expression matrix in order to be retained
10+
#' @param sig_gene_threshold Proportion of cells that a gene must be detected in (nonzero)
11+
#' to be used in signature score calculations.
12+
#' @importFrom Matrix rowSums
1013
#' @return processedSigData list of signature objects
11-
processSignatures <- function(sigData, expressionGenes, minSignatureGenes){
14+
processSignatures <- function(sigData, exprData, minSignatureGenes, sig_gene_threshold){
15+
expressionGenes <- rownames(exprData)
16+
17+
18+
cell_threshold <- sig_gene_threshold * ncol(exprData)
19+
gene_detects <- rowSums(exprData > 0)
20+
valid_genes <- gene_detects >= cell_threshold
21+
22+
message(
23+
sprintf(
24+
"\nUsing %i/%i genes detected in %.2f%% of cells for signature analysis.",
25+
sum(valid_genes), nrow(exprData), sig_gene_threshold*100)
26+
)
27+
message(
28+
"See the `sig_gene_threshold` input to change this behavior.\n"
29+
)
30+
31+
expressionGenes <- rownames(exprData)[valid_genes]
1232
out <- lapply(sigData, function(sig){
1333
validGenes <- names(sig@sigDict) %in% expressionGenes
1434
sig@sigDict <- sig@sigDict[validGenes]

R/methods-Vision.R

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#' genes to use when computing projections.
2121
#' @param min_signature_genes Signature that match less than this number of genes in the
2222
#' supplied expression matrix are removed.
23+
#' @param sig_gene_threshold Proportion of cells that a gene must be detected in (nonzero)
24+
#' to be used in signature score calculations.
2325
#' @param threshold Threshold to apply when using the 'threshold' or 'fano' projection genes filter.
2426
#' If greater than 1, this specifies the number of cells in which a gene must be detected
2527
#' for it to be used when computing PCA. If less than 1, this instead specifies the proportion of cells needed
@@ -75,7 +77,9 @@ setMethod("Vision", signature(data = "matrixORSparse"),
7577
function(data, signatures=list(),
7678
proteinData=NULL,
7779
unnormalizedData = NULL, meta=NULL,
78-
projection_genes=c("fano"), min_signature_genes=5,
80+
projection_genes=c("fano"),
81+
min_signature_genes=5,
82+
sig_gene_threshold=.001,
7983
threshold=.05, perm_wPCA=FALSE,
8084
projection_methods = c("tSNE30"),
8185
sig_norm_method = c("znorm_columns", "none", "znorm_rows",
@@ -101,7 +105,16 @@ setMethod("Vision", signature(data = "matrixORSparse"),
101105
.Object@params$micropooling <- list()
102106

103107
rownames(data) <- toupper(rownames(data))
104-
data <- data[ !duplicated(rownames(data)), , drop = FALSE]
108+
toRemove <- rownames(data)[duplicated(rownames(data))]
109+
if (length(toRemove) > 0){
110+
message(sprintf(
111+
"\nRemoving %i genes with duplicate IDs (ignoring case): %s\n",
112+
length(toRemove) + length(unique(toRemove)),
113+
paste(unique(toRemove), collapse = ", ")
114+
)
115+
)
116+
data <- data[ !(rownames(data) %in% toRemove), , drop = FALSE]
117+
}
105118
.Object@exprData <- data
106119

107120
if (!is.null(unnormalizedData)){
@@ -198,7 +211,7 @@ setMethod("Vision", signature(data = "matrixORSparse"),
198211
Signature objects")
199212
}
200213

201-
.Object@sigData <- processSignatures(.Object@sigData, rownames(.Object@exprData), min_signature_genes)
214+
.Object@sigData <- processSignatures(.Object@sigData, .Object@exprData, min_signature_genes, sig_gene_threshold)
202215

203216
if (!is.null(meta)) {
204217
if(is.matrix(meta)){

docs/LICENSE-text.html

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/articles/Signatures.html

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/articles/VISION-vignette.html

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/articles/index.html

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)