mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-10-02 13:58:12 +08:00
feat: frontend geneset validation (#2258)
* add geneset name validation * validate genes before addition * display error messages
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { postUserErrorToast } from "../components/framework/toasters";
|
||||
/*
|
||||
Action creators for gene sets
|
||||
|
||||
@@ -39,9 +40,25 @@ export const genesetDelete = (genesetName) => (dispatch, getState) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const genesetAddGenes = (genesetName, genes) => (dispatch, getState) => {
|
||||
export const genesetAddGenes = (genesetName, genes) => async (
|
||||
dispatch,
|
||||
getState
|
||||
) => {
|
||||
const state = getState();
|
||||
const { obsCrossfilter: prevObsCrossfilter } = state;
|
||||
const { obsCrossfilter: prevObsCrossfilter, annoMatrix } = state;
|
||||
const { schema } = annoMatrix;
|
||||
const varIndex = schema.annotations.var.index;
|
||||
const df = await annoMatrix.fetch("var", varIndex);
|
||||
const geneNames = df.col(varIndex).asArray();
|
||||
genes = genes.reduce((acc, gene) => {
|
||||
if (geneNames.indexOf(gene.geneSymbol) === -1) {
|
||||
postUserErrorToast(
|
||||
`${gene.geneSymbol} doesn't appear to be a valid gene name.`
|
||||
);
|
||||
} else acc.push(gene);
|
||||
return acc;
|
||||
}, []);
|
||||
|
||||
const obsCrossfilter = dropGenesetSummaryDimension(
|
||||
prevObsCrossfilter,
|
||||
state,
|
||||
|
||||
Reference in New Issue
Block a user