Skip to content

Commit 4f82675

Browse files
committed
Merge branch 'master' of github.com:maximilianh/cellBrowser
2 parents 13cbd07 + 73a5d28 commit 4f82675

3 files changed

Lines changed: 28 additions & 18 deletions

File tree

src/cbPyLib/cellbrowser/R/ExportToCellbrowser-seurat2.R

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ ExportToCellbrowser <- function(
4545
skip.markers = FALSE,
4646
all.meta = FALSE
4747
) {
48-
if (substr(object@version, 1, 1)!='2') {
49-
stop("can only process Seurat2 objects, version of rds is ", object@version)
48+
if (substr(object@version, 1, 1)!='2') {
49+
stop("can only process Seurat2 objects, version of rds is ", object@version)
5050
}
5151

5252
#idents <- FetchData(object,c("ident"))$ident;
@@ -150,23 +150,32 @@ ExportToCellbrowser <- function(
150150
}
151151
file <- paste0("markers.", ext)
152152
fname <- file.path(dir, file)
153-
if (is.null(markers.file) & !skip.markers) {
153+
154+
if (!is.null(markers.file) && !skip.markers) {
155+
message("Copying ", markers.file, " to ", fname)
156+
file.copy(markers.file, fname)
157+
}
158+
if (is.null(markers.file) && skip.markers) {
159+
file <- NULL
160+
}
161+
if (is.null(markers.file) && !skip.markers) {
154162
if (length(levels(idents)) > 1) {
155163
message("Running FindAllMarkers(), using ROC test, min logfc diff 0.35, and writing top ", markers.n, ", cluster markers to ", fname)
156164
markers <- FindAllMarkers(object, do.print=TRUE, print.bar=TRUE, test.use="roc", logfc.threshold = 0.35)
157-
require(dplyr) # if this fails, install dplyr with install.packages("dplyr")
158-
top.markers <- markers %>% group_by(cluster) %>% top_n(markers.n, avg_logFC)
159-
write.table(top.markers, fname, quote=FALSE, sep="\t", row.names=FALSE)
165+
markers.helper <- function(x) {
166+
partition <- markers[x,]
167+
ord <- order(partition$p_val_adj < 0.05, -partition$avg_logFC)
168+
res <- x[ord]
169+
res <- c(res[1:markers.n], rep(NA, length(x) - markers.n))
170+
return(res)
171+
}
172+
markers.order <- ave(rownames(markers), markers$cluster, FUN=markers.helper)
173+
top.markers <- markers[markers.order[!is.na(markers.order)],]
174+
write.table(top.markers, fname, quote=FALSE, sep="\t", col.names=NA)
160175
} else {
176+
message("No clusters found in Seurat object, so no marker genes can be computed")
161177
file <- NULL
162178
}
163-
} else if (!skip.markers) {
164-
message("Copying ", markers.file, " to ", fname)
165-
file.copy(markers.file, fname)
166-
}
167-
else {
168-
message("No marker genes file defined")
169-
file <- NULL
170179
}
171180

172181
if (!is.null(file)) {

src/cbPyLib/cellbrowser/cbWeb/css/cellBrowser.css

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ canvas { user-select: none }
3333
.tpIconButton { padding: 1px 2px 1px 2px; border-radius: 0; height:28px; width: 28px; cursor: default}
3434
.tpClicked { background-color: #AAA }
3535
.tpClicked:hover { background-color: #AAA }
36-
.btn-primary.load-dataset {float: right; margin-left: 10px; color: white;}
36+
.btn-primary.load-dataset {float: right; margin-left: 10px; color: white; font-size: 12px; margin-top: -4px;}
3737
.list-group-item.active>.btn-primary {color: #337ab7;background-color: #fff;}
38+
.list-group-item .badge {margin-top: -2px;}
3839

3940
.link { text-decoration: underline; color: #0000EE; cursor: pointer; }
4041

@@ -169,7 +170,7 @@ button { line-height: 12px }
169170

170171
/* flying-sheep's suggestions */
171172
.ui-dialog-titlebar { border: none }
172-
button.list-group-item { background-color: #EEE }
173+
a.list-group-item { background-color: #EEE }
173174
.nav-tabs > li > a { border-top-left-radius: 4px; border-top-right-radius: 4px; background-color: #EEE; padding-left: 10px; padding-right: 10px; padding-top: 4px; padding-bottom:4px}
174175
.nav-tabs > li.active > a { background-color: #337ab7; color: white; border: 1px solid #EEE }
175176
/* .nav-tabs > li { background-color: #E9E9E9 } */

src/cbPyLib/cellbrowser/cbWeb/js/cellBrowser.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,9 +336,9 @@ var tsnePlot = function() {
336336
htmls.push("<div class='list-group' style='width:"+buttonWidth+"px'>");
337337
for (var i = 0; i < gDatasetList.length; i++) {
338338
var dataset = gDatasetList[i];
339-
var line = "<button id='tpDatasetButton_"+i+"' type='button' class='list-group-item' data-datasetid='"+i+"'>"; // bootstrap seems to remove the id
339+
var line = "<a id='tpDatasetButton_"+i+"' role='button' class='list-group-item' data-datasetid='"+i+"'>"; // bootstrap seems to remove the id
340340
htmls.push(line);
341-
htmls.push('<a role="button" class="btn btn-primary btn-xs load-dataset">Open dataset</a>')
341+
htmls.push('<button type="button" class="btn btn-primary btn-xs load-dataset">Open dataset</button>')
342342

343343
if (dataset.sampleCount!==undefined) {
344344
var countDesc = prettyNumber(dataset.sampleCount);
@@ -351,7 +351,7 @@ var tsnePlot = function() {
351351
htmls.push("<span class='badge'>"+tag+"</span>");
352352
}
353353
}
354-
htmls.push(dataset.shortLabel+"</button>");
354+
htmls.push(dataset.shortLabel+"</a>");
355355
if (db!==null && db.name===dataset.name)
356356
activeIdx = i;
357357
}

0 commit comments

Comments
 (0)