mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-09-30 08:58:12 +08:00
Color by gene set mean expression (#2157)
* colorby histo
* color graph by mean expression
* move var index after returns
* add genesets as an argument
* varindex
* undo redo for mean expression
* destructure
* ternary
* Revert "destructure"
This reverts commit 2d9432c1c7.
* color by mean for diffexp
This commit is contained in:
@@ -12,8 +12,15 @@ import { range } from "../range";
|
||||
given a color mode & accessor, generate an annoMatrix query that will
|
||||
fulfill it
|
||||
*/
|
||||
export function createColorQuery(colorMode, colorByAccessor, schema) {
|
||||
if (!colorMode || !colorByAccessor || !schema) return null;
|
||||
export function createColorQuery(
|
||||
colorMode,
|
||||
colorByAccessor,
|
||||
schema,
|
||||
genesets,
|
||||
diffExp
|
||||
) {
|
||||
if (!colorMode || !colorByAccessor || !schema || !genesets) return null;
|
||||
|
||||
switch (colorMode) {
|
||||
case "color by categorical metadata":
|
||||
case "color by continuous metadata": {
|
||||
@@ -33,6 +40,38 @@ export function createColorQuery(colorMode, colorByAccessor, schema) {
|
||||
},
|
||||
];
|
||||
}
|
||||
case "color by geneset mean expression": {
|
||||
const varIndex = schema?.annotations?.var?.index;
|
||||
|
||||
if (!varIndex) return null;
|
||||
if (!genesets) return null;
|
||||
|
||||
let _geneset;
|
||||
let _setGenes;
|
||||
|
||||
if (colorByAccessor === "Temp DiffExp Set") {
|
||||
_geneset = diffExp;
|
||||
_setGenes = _geneset.map((diffexpResultItem) => {
|
||||
const geneName = diffexpResultItem[0];
|
||||
return geneName;
|
||||
});
|
||||
} else {
|
||||
_geneset = genesets.get(colorByAccessor);
|
||||
_setGenes = [..._geneset.genes.keys()];
|
||||
}
|
||||
|
||||
return [
|
||||
"X",
|
||||
{
|
||||
summarize: {
|
||||
method: "mean",
|
||||
field: "var",
|
||||
column: varIndex,
|
||||
values: _setGenes,
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
default: {
|
||||
return null;
|
||||
}
|
||||
@@ -86,6 +125,11 @@ function _createColorTable(
|
||||
const { min, max } = col.summarize();
|
||||
return createColorsByContinuousMetadata(col.asArray(), min, max);
|
||||
}
|
||||
case "color by geneset mean expression": {
|
||||
const col = colorByData.icol(0);
|
||||
const { min, max } = col.summarize();
|
||||
return createColorsByContinuousMetadata(col.asArray(), min, max);
|
||||
}
|
||||
default: {
|
||||
return defaultColors(schema.dataframe.nObs);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user