Closed wikiselev closed 7 years ago
I was about to ask if you guys were planning on adding more non-interactive options. It'd be really convenient for me to be able to run the entire process in a script since I'd love to use SC3 as part of a larger pipeline!
Quick question: is there any way to generate the consensus distance matrix without going through the interactive browser?
Thanks! Yan
Hi Yan,
Ok I will start it here, but will try to add a more detailed description to the package vignette very soon.
Hope this helps:
library(SC3)
# run SC3 with interactivity = FALSE
sc3(treutlein, 3:7, interactivity = FALSE)
# all results used in the interactive session are stored in sc3.interactive.arg$cons.table
d <- sc3.interactive.arg$cons.table
# d is a matrix of SC3 results
# each row corresponds to a combination
# of checkboxes and the number of clusters k
# in the interactive tool
# now, if you want results from
# "euclidean + pearson + spearman" with "PCA + Spectral" for 5 clusters:
res <- d[d[,1] == "euclidean pearson spearman" & d[,2] == "PCA Spectral" & d[,3] == "5"]
# res is a list in which res[[4]] contains all clustering results for
# the combination of parameters defined in the previous step
clust.res <- res[[4]]
# clust.res is a list again
# clust.res[[1]] - is an unclustered consensus matrix
# clust.res[[2]] - are the cell index labels
# clust.res[[3]] - is an hclust object, corresponding to heirarchical clustering
# of the consensus matrix
# clust.res[[4]] - silhouette index results
consens <- clust.res[[1]]
hc <- clust.res[[3]]
# this command will plot the same plot that you see in the interactive session
library(pheatmap)
pheatmap(
consens,
cluster_rows = hc,
cluster_cols = hc,
cutree_rows = 5,
cutree_cols = 5
)
# get the ordering of the cells in the consensus matrix
ordering <- order.dendrogram(as.dendrogram(hc))
# order cells in the consensus matrix
consens.ordered <- consens[ordering, ordering]
# now you do not need to cluster rows and cols, because consens is already ordered
pheatmap(
consens.ordered,
cluster_rows = FALSE,
cluster_cols = FALSE
)
# to get cluster labels
clusts <- cutree(hc, 5)
Thanks so much! This is perfect for what I'm working on.
Best, Yan
The newest version 1.1.7 has a full non-interactive support via scater.
Please follow the manual here: https://cdn.rawgit.com/hemberg-lab/SC3/master/vignettes/my-vignette.html
To be able to use it at the moment you need to reinstall both scater and SC3 from the GitHub: install.packages("devtools") devtools::install_github("davismcc/scater", build_vignettes = TRUE) devtools::install_github("hemberg-lab/SC3")
These features will become available on Bioconductor after the next release of Bioconductor.