Skip to content

Commit 5ef3e10

Browse files
authored
Merge pull request #89 from YosefLab/yr-cass
PhyloVision & version bump
2 parents c8598d9 + b21442f commit 5ef3e10

File tree

313 files changed

+89887
-5233
lines changed

Some content is hidden

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

313 files changed

+89887
-5233
lines changed

DESCRIPTION

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
Package: VISION
22
Title: Functional interpretation of single cell RNA-seq latent manifolds
3-
Version: 2.1.0
3+
Version: 3.0.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")),
7+
person("Yanay", "Rosen", email = "yanayrosen@berkeley.edu", role = c("aut")),
78
person("Nir", "Yosef", email = "niryosef@berkeley.edu", role = c("ctb", "cph")))
89
Author: Matt Jones [aut, cre], David Detomaso [aut, cre], Tal Ashuach [aut], Nir Yosef [ctb]
910
Maintainer: Matt Jones <mattjones315@gmail.com>
1011
Description: VISION provides functional interpretation of single cell RNA-seq (scRNA-seq) latent manifolds through the use of biological signatures (which can be downloaded from online databases). VISION can operate downstream of other common analyses such as dimensionality reduction, clustering, or trajectory analysis of scRNA-seq data. VISION produces an interactive web-based output report that can be easily shared with other collaborators or the greater scientific community.
1112
Depends: R (>= 3.4)
1213
Imports:
14+
dplyr,
1315
fastICA,
1416
igraph,
1517
irlba,
@@ -31,14 +33,16 @@ Imports:
3133
Rtsne,
3234
utils,
3335
vegan,
36+
ape,
37+
reticulate,
3438
wordspace
3539
LinkingTo: Rcpp
3640
License: MIT + file LICENSE
3741
Encoding: UTF-8
3842
LazyData: true
3943
URL: https://yoseflab.github.io/VISION, https://github.com/yoseflab/VISION
4044
BugReports: https://github.com/YosefLab/VISION/issues
41-
RoxygenNote: 6.1.1
45+
RoxygenNote: 7.1.1
4246
Suggests:
4347
Biobase,
4448
BiocStyle,

NAMESPACE

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,49 @@
11
# Generated by roxygen2: do not edit by hand
22

3+
export(PhyloVision)
34
export(Vision)
5+
export(addHotspotToVision)
46
export(addSignatures)
57
export(addTSNE)
68
export(addUMAP)
9+
export(analyzeHotspotObjectVision)
710
export(analyzeLocalCorrelations)
11+
export(analyzeLocalCorrelationsModules)
812
export(annotateLatentComponents)
913
export(applyMicroClustering)
14+
export(calcModuleScores)
1015
export(calcSignatureScores)
16+
export(calc_mod_sig_enrichment)
17+
export(calc_set_enrichment)
18+
export(clusterModScores)
1119
export(clusterSigScores)
1220
export(computeLatentSpace)
1321
export(convertGeneIds)
1422
export(createGeneSignature)
23+
export(depthBasedCladewiseTreeCluster)
24+
export(depthBasedTreeCluster)
25+
export(draw_hotspot_heatmap)
26+
export(generateOverlapSignatures)
27+
export(group_modules_enrichment)
28+
export(hsCalculateModuleScores)
29+
export(hsComputeAutoCorrelations)
30+
export(hsComputeLocalCorrelations)
31+
export(hsCreateKnnGraph)
32+
export(hsInit)
33+
export(lca_based_depth)
34+
export(loadHotspotObject)
1535
export(poolMatrixCols)
1636
export(poolMatrixRows)
1737
export(poolMetaData)
1838
export(read_10x)
1939
export(read_10x_h5)
2040
export(read_10x_h5_v2)
2141
export(read_10x_h5_v3)
42+
export(runHotspot)
43+
export(saveHSBytestToPickle)
44+
export(treeClusterMinCladeSize)
45+
export(trivial_dist)
46+
exportMethods(PhyloVision)
2247
exportMethods(Vision)
2348
exportMethods(addProjection)
2449
exportMethods(analyze)
@@ -31,13 +56,16 @@ exportMethods(getSelections)
3156
exportMethods(getSignatureAutocorrelation)
3257
exportMethods(getSignatureDifferential)
3358
exportMethods(getSignatureScores)
59+
exportMethods(phyloAnalyze)
3460
exportMethods(saveAndViewResults)
3561
exportMethods(viewResults)
3662
import(Matrix)
3763
import(Rcpp)
64+
import(ape)
3865
import(loe)
3966
import(logging)
4067
import(methods)
68+
import(reticulate)
4169
importFrom(Matrix,Diagonal)
4270
importFrom(Matrix,Matrix)
4371
importFrom(Matrix,colMeans)

NEWS.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
# VISION 3.0.0
2+
3+
Major version bump!
4+
5+
* Added support for Phylogenies as latent spaces in core VISION and integrated with VISION api
6+
* Re-engineered UI into Signature Autocorrelation and Hotspot views
7+
* Integrated [Hotspot](https://yoseflab.github.io/Hotspot/index.html) into VISION analysis and report UI.
8+
* Deprecated support for trajectories and LC Annotator.
9+
* New color-scheme for gene expression values
10+
11+
112
# VISION 2.1.0
213

314
Added parameter `sig_gene_threshold` with **changed default behavior**

R/AllClasses.R

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,16 @@
55
# scores, distance matrices, and anything else, is computed
66
# on the different types of data.
77

8+
89
setClassUnion("numericORNULL", members = c("numeric", "NULL"))
910
setClassUnion("matrixORSparse", members = c("matrix", "dgCMatrix"))
1011
setClassUnion("matrixORNULL", members = c("matrix", "NULL"))
1112
setClassUnion("dataframeORNULL", members = c("data.frame", "NULL"))
13+
setClassUnion("rawORNULL", members = c("raw", "NULL"))
14+
15+
16+
# setClassUnion("treeorNull", members=c("phylo", "NULL"))
17+
# setClassUnion("pythonorNull", members = c("python.builtin.object", "NULL"))
1218

1319
Cluster <- setClass("Cluster",
1420
slots = c(
@@ -58,6 +64,8 @@ Trajectory <- setClass("Trajectory",
5864
# columns: from (character), to (character), position (numeric, 0 to 1)
5965
))
6066

67+
setClassUnion("trajectoryORNULL", members = c("Trajectory", "NULL"))
68+
6169
TrajectoryProjection <- setClass("TrajectoryProjection",
6270
slots = c(
6371
name = "character", # Name of projection
@@ -101,17 +109,23 @@ Vision <- setClass("Vision",
101109
unnormalizedData = "matrixORSparse",
102110
sigData = "list",
103111
metaData = "data.frame",
112+
modData = "list",
104113
SigScores = "matrix",
114+
ModScores = "matrix",
105115
LocalAutocorrelation = "list",
106116
TrajectoryAutocorrelation = "list",
107117
ClusterComparisons = "list",
108118
LCAnnotatorData = "LCAnnotatorDataOrNULL",
109119
Projections = "list",
110120
TrajectoryProjections = "list", # list of TrajectoryProjection
111121
SigGeneImportance = "list",
122+
ModGeneImportance = "list",
112123
Pools = "list",
113124
LatentSpace = "matrix",
114-
LatentTrajectory = "Trajectory",
125+
LatentTrajectory = "trajectoryORNULL",
126+
Hotspot = "rawORNULL",
127+
ModuleSignatureEnrichment = "list",
128+
ModuleHotspotScores = "data.frame",
115129
Viewer = "list",
116130
params = "list",
117131
version = "numeric"
@@ -122,18 +136,33 @@ Vision <- setClass("Vision",
122136
unnormalizedData = matrix(NA, 1, 1),
123137
sigData = list(),
124138
metaData = data.frame(),
139+
modData=list(),
125140
SigScores = matrix(NA, 1, 1),
141+
ModScores = matrix(NA, 1, 1),
126142
LocalAutocorrelation = list(),
127143
TrajectoryAutocorrelation = list(),
128144
ClusterComparisons = list(),
129145
LCAnnotatorData = NULL,
130146
Projections = list(),
131147
TrajectoryProjections = list(),
132148
SigGeneImportance = list(),
149+
ModGeneImportance = list(),
133150
Pools = list(),
134151
LatentSpace = matrix(NA, 1, 1),
135152
LatentTrajectory = NULL,
153+
Hotspot = NULL,
154+
ModuleSignatureEnrichment = list(),
155+
ModuleHotspotScores = data.frame(),
136156
Viewer = list(),
137157
params = list(),
138158
version = 1.2
139159
))
160+
161+
# This is a hack to try and get R to play nice with the phylo class
162+
# Which the Ape package doesn't expose
163+
phylo <- setClass("phylo")
164+
165+
PhyloVision <- setClass("PhyloVision", contains = "Vision",
166+
slots = c(tree = "phylo"),
167+
prototype = list(tree=NULL)
168+
)

R/AllGenerics.R

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,20 @@ setGeneric("Vision", function(data, ...) {
44
standardGeneric("Vision")
55
})
66

7+
#' @rdname PhyloVision-class
8+
#' @export
9+
setGeneric("PhyloVision", function(tree, ...) {
10+
standardGeneric("PhyloVision")
11+
})
12+
713
setGeneric("analyze", function(object, ...) {
814
standardGeneric("analyze")
915
})
1016

17+
setGeneric("phyloAnalyze", function(object, ...) {
18+
standardGeneric("phyloAnalyze")
19+
})
20+
1121
setGeneric("addProjection", function(object, ...) {
1222
standardGeneric("addProjection")
1323
})

R/AnalysisFunctions.R

Lines changed: 53 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,32 @@
44
#'
55
#' @param object the VISION object for which to cluster the cells
66
#' @return the VISION object modifed as described above
7-
clusterCells <- function(object) {
7+
clusterCells <- function(object, tree=FALSE) {
88

99
message("Clustering cells...", appendLF = FALSE)
1010

1111
res <- object@LatentSpace
1212

1313
K <- min(object@params$numNeighbors, 30)
14-
kn <- find_knn_parallel(res, K)
15-
16-
cl <- louvainCluster(kn, res)
17-
14+
15+
if (!tree) {
16+
kn <- find_knn_parallel(res, K)
17+
cl <- louvainCluster(kn, res)
18+
} else {
19+
message("Using Tree to compute clusters...\n")
20+
# Get the MRCA matrix and convert the node indexes to depths
21+
cl <- maxSizeCladewiseTreeCluster(object@tree)
22+
}
23+
1824
names(cl) <- paste('Cluster', seq(length(cl)))
1925

2026
# cl is list of character vector
21-
cluster_variable <- "VISION_Clusters"
27+
if (!tree) {
28+
cluster_variable <- "VISION_Clusters"
29+
} else {
30+
cluster_variable <- "VISION_Clusters_Tree"
31+
}
32+
2233
metaData <- object@metaData
2334

2435
metaData[cluster_variable] <- factor(levels = names(cl))
@@ -154,7 +165,7 @@ computeProjectionGenes <- function(object,
154165
if (!is.null(projection_genes)){
155166
object@params$latentSpace$projectionGenes <- projection_genes
156167
} else {
157-
object@params$latentSpace$projectionGenes <- NULL
168+
object@params$latentSpace$projectionGenes <- NA
158169
}
159170

160171
if (!is.null(projection_genes_method)){
@@ -163,7 +174,7 @@ computeProjectionGenes <- function(object,
163174

164175
message("Determining projection genes...")
165176

166-
if (is.null(object@params$latentSpace[["projectionGenes"]])){
177+
if (is.na(object@params$latentSpace[["projectionGenes"]])){
167178

168179
exprData <- matLog2(object@exprData)
169180
projection_genes <- applyFilters(
@@ -283,22 +294,43 @@ calcSignatureScores <- function(
283294
object@exprData,
284295
object@params$signatures$sigNormMethod
285296
)
286-
287-
sigScores <- batchSigEvalNorm(object@sigData, normExpr)
288-
297+
298+
sigData <- object@sigData
299+
300+
for (sig_name in names(object@sigData)){
301+
signature <- object@sigData[[sig_name]]
302+
directional <- all(c(1, -1) %in% signature@sigDict)
303+
if (directional) {
304+
up <- names(which(signature@sigDict == 1))
305+
down <- names(which(signature@sigDict == -1))
306+
307+
up_name <- paste(signature@name, "_UP", sep = "")
308+
down_name <- paste(signature@name, "_DOWN", sep = "")
309+
310+
up_sig <- Signature(sigDict = signature@sigDict[up], name = up_name, source = signature@source, metaData = signature@metaData)
311+
down_sig <- Signature(sigDict = signature@sigDict[down], name = down_name, source = signature@source, metaData = signature@metaData)
312+
sigData[[up_name]] <- up_sig
313+
sigData[[down_name]] <- down_sig
314+
}
315+
}
316+
317+
object@sigData <- sigData # persist back to the object because of issues with up/down
318+
319+
sigScores <- batchSigEvalNorm(sigData, normExpr)
320+
289321
if (sig_gene_importance) {
290322

291323
if (is(object@exprData, "sparseMatrix")) {
292324
sigGeneImportance <- evalSigGeneImportanceSparse(
293-
sigScores, object@sigData, normExpr
325+
sigScores, sigData, normExpr
294326
)
295327
} else {
296328
normExprDense <- getNormalizedCopy(
297329
object@exprData,
298330
object@params$signatures$sigNormMethod
299331
)
300332
sigGeneImportance <- evalSigGeneImportance(
301-
sigScores, object@sigData, normExprDense
333+
sigScores, sigData, normExprDense
302334
)
303335
}
304336

@@ -715,7 +747,7 @@ addTSNE <- function(object, perplexity = 30, name = "tSNE", source = "LatentSpac
715747
#' @param object the VISION object
716748
#' @return the VISION object with values set for the analysis results
717749
#' @export
718-
analyzeLocalCorrelations <- function(object) {
750+
analyzeLocalCorrelations <- function(object, tree=FALSE) {
719751

720752
signatureBackground <- generatePermutationNull(
721753
object@exprData, object@sigData, num = 3000
@@ -726,9 +758,13 @@ analyzeLocalCorrelations <- function(object) {
726758
object@params$signatures$sigNormMethod)
727759

728760
message("Computing KNN Cell Graph in the Latent Space...\n")
729-
730-
weights <- computeKNNWeights(object@LatentSpace, object@params$numNeighbors)
731-
761+
if (!tree) {
762+
weights <- computeKNNWeights(object@LatentSpace, object@params$numNeighbors)
763+
} else {
764+
message("Using Tree to compute neighbors...\n")
765+
weights <- computeKNNWeights(object@tree, object@params$numNeighbors)
766+
}
767+
732768
message("Evaluating local consistency of signatures in latent space...\n")
733769

734770
sigConsistencyScores <- sigConsistencyScores(

0 commit comments

Comments
 (0)