mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-09-27 02:08:11 +08:00
lodash cleanup (#747)
* add own range() function * lodash cleanup * remove redundant fill range implementations * remove use of _.get * sync test babel config with build * update tests to match new range implementation
This commit is contained in:
committed by
Colin Megill
parent
c12cb2424a
commit
846b8d15bd
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
Helper functions for the embedded graph colors
|
||||
*/
|
||||
import _ from "lodash";
|
||||
import * as d3 from "d3";
|
||||
import { interpolateRainbow, interpolateCool } from "d3-scale-chromatic";
|
||||
import * as globals from "../../globals";
|
||||
import parseRGB from "../parseRGB";
|
||||
import finiteExtent from "../finiteExtent";
|
||||
import { range } from "../range";
|
||||
|
||||
/*
|
||||
create new colors state object. Paramters:
|
||||
@@ -37,9 +37,7 @@ function createColors(world, colorMode = null, colorAccessor = null) {
|
||||
}
|
||||
|
||||
function createColorsByCategoricalMetadata(world, accessor) {
|
||||
const { categories } = _.filter(world.schema.annotations.obs, {
|
||||
name: accessor
|
||||
})[0];
|
||||
const { categories } = world.schema.annotations.obsByName[accessor];
|
||||
|
||||
const scale = d3
|
||||
.scaleSequential(interpolateRainbow)
|
||||
@@ -67,7 +65,7 @@ function createColorsByContinuousMetadata(world, accessor) {
|
||||
const scale = d3
|
||||
.scaleQuantile()
|
||||
.domain([min, max])
|
||||
.range(_.range(colorBins - 1, -1, -1));
|
||||
.range(range(colorBins - 1, -1, -1));
|
||||
|
||||
/* pre-create colors - much faster than doing it for each obs */
|
||||
const colors = new Array(colorBins);
|
||||
@@ -97,7 +95,7 @@ function createColorsByExpression(world, accessor) {
|
||||
const scale = d3
|
||||
.scaleQuantile()
|
||||
.domain([min, max])
|
||||
.range(_.range(colorBins - 1, -1, -1));
|
||||
.range(range(colorBins - 1, -1, -1));
|
||||
|
||||
/* pre-create colors - much faster than doing it for each obs */
|
||||
const colors = new Array(colorBins);
|
||||
|
||||
@@ -5,7 +5,7 @@ Helper functions for the controls reducer
|
||||
import _ from "lodash";
|
||||
|
||||
import * as globals from "../../globals";
|
||||
import { fillRange } from "../typedCrossfilter/util";
|
||||
import { rangeFill as fillRange } from "../range";
|
||||
import {
|
||||
userDefinedDimensionName,
|
||||
diffexpDimensionName
|
||||
|
||||
@@ -122,15 +122,15 @@ function reconcileSchemaCategoriesWithSummary(universe) {
|
||||
cases, add a 'categories' field to the schema so it is accessible.
|
||||
*/
|
||||
|
||||
_.forEach(universe.schema.annotations.obs, s => {
|
||||
universe.schema.annotations.obs.forEach(s => {
|
||||
if (
|
||||
s.type === "string" ||
|
||||
s.type === "boolean" ||
|
||||
s.type === "categorical"
|
||||
) {
|
||||
const categories = _.union(
|
||||
_.get(s, "categories", []),
|
||||
_.get(universe.obsAnnotations.col(s.name).summarize(), "categories", [])
|
||||
s.categories ?? [],
|
||||
universe.obsAnnotations.col(s.name).summarize().categories ?? []
|
||||
);
|
||||
s.categories = categories;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user