Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
braneyboo committed Nov 11, 2020
2 parents 4887b80 + a81191b commit 5207737
Show file tree
Hide file tree
Showing 13 changed files with 464 additions and 249 deletions.
1 change: 1 addition & 0 deletions cellbrowserData/genes/log.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ wget ftp://ftp.ncbi.nih.gov/gene/DATA/GENE_INFO/Mammalia/Homo_sapiens.gene_info.
wget ftp://ftp.ncbi.nih.gov/gene/DATA/GENE_INFO/Mammalia/Mus_musculus.gene_info.gz -O - | zcat | cut -f2,3 | grep -v ^Gene > entrez-mouse.symbols.tsv
zcat entrez-human.symbols.tsv.gz | cat - entrez-mouse.symbols.tsv > entrez.symbols.tsv
cp entrez.symbols.tsv.gz ~/htdocs-cells/downloads/cellbrowserData/genes/
cp /hive/data/outside/gencode/tsv/gencode28.genes.bed ./hg38.gencode28.genes.bed
2 changes: 1 addition & 1 deletion cellbrowserData/genomes/barChartBed.as
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ table barChartBed
string name; "Gene identifier"
uint score; "Score from 0-1000, typically derived from total of median value from all categories"
char[1] strand; "+ or - for strand. Use . if not applicable"
string name2; "Gene name"
string name2; "Gene symbol"
uint expCount; "Number of categories"
float[expCount] expScores; "Comma separated list of category values"
bigint _dataOffset; "Offset of sample data in data matrix file, for boxplot on details page"
Expand Down
9 changes: 5 additions & 4 deletions docs/seurat.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ There are a number of ways to create a cell browser using Seurat:

Each of these methods are described in more detail below.

Convert a Seurat ``rds`` file
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Convert a Seurat ``rds`` or ``.rdata` file
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
First, create an .rds file in R as described in the Seurat tutorial::
Expand All @@ -21,8 +21,9 @@ file into a cell browser::

cbImportSeurat -i pbmc3k_small.rds -o pbmc3kImport

This works with objects created by versions 2 and 3 of Seurat. Make sure that
you have the same major version of Seurat installed that was used to create the
This works with objects created by versions 2 and 3 of Seurat. ``cbImportSeurat`` can read
both ``.rds`` and ``.rdata`` files, for `.rdata` it assume the first object is the Seurat object.
Make sure that you have the same major version of Seurat installed that was used to create the
object. You cannot open Seurat2 objects with Seurat3 or vice versa.
(We often need to switch between Seurat versions and found conda environments very helpful for this.)

Expand Down
10 changes: 6 additions & 4 deletions src/cbPyLib/cellbrowser/R/ExportToCellbrowser-seurat.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ findMatrix = function( object, matrix.slot ) {
#' exprMatrix.tsv, tsne.coords.tsv, meta.tsv, markers.tsv and a default cellbrowser.conf
#' @param dataset.name name of the dataset. Defaults to Seurat project name
#' @param reductions vector of reduction names to export, defaults to all reductions.
#' @param markers.file path to file with marker genes. Alternatively,
#' markers can also be supplied in the object, as misc$markers.
#' @param markers.file path to file with marker genes. By defaults, marker
#' are searched in the object itself as misc$markers. If none are supplied in
#' object or via this argument, they are recalculated with \code{FindAllMarkers}
#' @param markers.n if no markers were supplied, FindAllMarkers is run.
#' This parameter indicates how many markers to calculate, default is 100
#' @param matrix.slot matrix to use, default is 'counts'
Expand All @@ -86,7 +87,7 @@ findMatrix = function( object, matrix.slot ) {
#' @param skip.metadata whether to skip exporting metadata
#' @param skip.reductions whether to skip exporting reductions
#' @param port on which port to run UCSC cellbrowser webserver after export
#' @param ... specifies the metadata fields to export. To supply field with
#' @param ... specifies the metadata fields to export. To supply a field name and its
#' human readable name, pass name as \code{field="name"} parameter.
#'
#' @return This function exports Seurat object as a set of tsv files
Expand All @@ -101,9 +102,10 @@ findMatrix = function( object, matrix.slot ) {
#'
#' @author Maximilian Haeussler, Nikolay Markov
#'
#' @importFrom tools file_ext
#' @importFrom utils browseURL
#' @importFrom reticulate py_module_available import
#' @importFrom tools file_ext
#' @importFrom Seurat Project Idents GetAssayData Embeddings FetchData
#'
#' @export
#'
Expand Down
60 changes: 25 additions & 35 deletions src/cbPyLib/cellbrowser/cbWeb/js/cellBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -949,9 +949,8 @@ var cellbrowser = function() {

function openDatasetDialog(openDsInfo, selName) {
/* build dataset open dialog,
* - datasetList is the list of all datasets to show on the left, null to hide list
* - openDsInfo is the currently open object or a collection.
* - openCollection is true to show 'collection' decorations: summary entry, note at the top and back link
* - selName is the currently selected dataset in this list
*/

var datasetList = [];
Expand Down Expand Up @@ -1142,8 +1141,11 @@ var cellbrowser = function() {

var buttons = [];
if (db!==null) {
var cancelLabel = "Cancel";
if (onlyInfo)
cancelLabel = "Close";
buttons.push( {
text:"Cancel",
text: cancelLabel,
click: function() {
$( this ).dialog( "close" );
if (openDsInfo.isCollection)
Expand Down Expand Up @@ -1566,7 +1568,8 @@ var cellbrowser = function() {
}
}

function addNewAnnotation(fieldLabel, newMetaValue, cellIds) { var metaInfo;
function addNewAnnotation(fieldLabel, newMetaValue, cellIds) {
var metaInfo;
let cellCount = db.conf.sampleCount;
if (!db.getMetaFields()[0].isCustom) {
// add a new enum meta field
Expand Down Expand Up @@ -2372,8 +2375,6 @@ var cellbrowser = function() {
$('#tpTutorialButton').click( function() { showIntro(false); } );
$('#tpAboutButton').click( onAboutClick );
$('#tpOpenDatasetLink').click( openCurrentDataset );
//$('#tpOpenDatasetLink').click( function() {
//openDatasetDialog(db.conf, db.name); } );
$('#tpSaveImage').click( onSaveAsClick );
$('#tpSelectAll').click( onSelectAllClick );
$('#tpSelectNone').click( onSelectNoneClick );
Expand Down Expand Up @@ -4007,12 +4008,14 @@ var cellbrowser = function() {
metaCounts[valIdx].push(valIdx);

var oldSortBy = getFromUrl("SORT");
// URL overrides default value
if (sortBy===undefined && oldSortBy!==undefined)
sortBy = oldSortBy;
if (sortBy===undefined && db.conf.sortBy)
sortBy = db.conf.sortBy[metaInfo.label];

if (sortBy!==undefined && sortBy!=="freq" && sortBy!=="name") {

// default sorting can be specfied with "sortBy" in cellbrowser.conf
if (sortBy===undefined && metaInfo.sortBy)
sortBy = metaInfo.sortBy;
if (sortBy!==undefined && sortBy!=="freq" && sortBy!=="name" && sortBy!=="none") {
alert("sortBy is '"+cleanString(sortBy)+' but it can only be "freq" or "name"');
sortBy = undefined;
}
Expand Down Expand Up @@ -4040,14 +4043,11 @@ var cellbrowser = function() {
//var defaultColors = makeColorPalette(countListSorted.length, useGradient);

var rows = [];
//var defColIdx = 0;
var shortLabels = metaInfo.ui.shortLabels;
var longLabels = metaInfo.ui.longLabels;
for (var legRowIdx = 0; legRowIdx < countListSorted.length; legRowIdx++) {
var legRowInfo = countListSorted[legRowIdx];
//var label = legRowInfo[0];
let valIdx = legRowInfo[2]; // index of the original field in fieldInfo
//let valIdx = legRowInfo.intKey;
var label = shortLabels[valIdx];

var desc = null;
Expand Down Expand Up @@ -4345,7 +4345,12 @@ var cellbrowser = function() {
resizeDivs(true);

if (!db.conf.metaFields) {
showCollectionDialog(datasetName);
// pablo often has single-dataset installations, there is no need to open the
// dataset selection box then.
if (db.conf.datasets.length===1 && datasetName==="") // "" is the root dataset
loadDataset(db.conf.datasets[0].name, false);
else
showCollectionDialog(datasetName);
return;
}

Expand All @@ -4358,6 +4363,9 @@ var cellbrowser = function() {

cartLoad(db);
renderData();

if (getVar("openDialog"))
openDatasetDialog(db.conf, db.name); // open Info dialog
cartSave(db); // = set the current URL from local storage settings

// start the tutorial after a while
Expand Down Expand Up @@ -5202,36 +5210,18 @@ var cellbrowser = function() {

function sortPairsBy(countList, sortBy) {
/* sort an array in the format [name, count] by either name (using naturalSort) or count */
// XX no need anymore to return a dict, just return the list
// convert the dict to a list of (count, key)
//var countList = [];
//var numCount = 0;
//var count = null;
//var useGradient = false; // use a rainbow or gradient palette?
//for (var key in dict) {
//count = dict[key];
//if (!isNaN(key)) // key looks like a number
//numCount++;
//countList.push( [count, key] );
//}

// auto-detect: sort list by name if most names are numbers
//if ((countList.length >= 4 && numCount >= countList.length-1)) {
//if (sortBy===undefined)
//sortBy = "name";
//useGradient = true;
//}

var isSortedByName = null;

if (sortBy==="name") {
countList.sort(function(a, b) { return naturalSort(a[0], b[0]); }); // I have a feeling that this is very slow...
isSortedByName = true;
}
else {
else if (sortBy=="count") {
// sort this list by count
countList = countList.sort(function(a, b){ return b[1] - a[1]; }); // reverse-sort by count
isSortedByName = false;
} else {
isSortedByName = false;
}

var ret = {};
Expand Down

0 comments on commit 5207737

Please sign in to comment.