feat: frontend geneset validation (#2258)

* add geneset name validation

* validate genes before addition

* display error messages
This commit is contained in:
Severiano Badajoz
2021-07-01 22:09:50 +00:00
committed by GitHub
parent b8b1d0dd9e
commit b714c18e75
4 changed files with 67 additions and 15 deletions
+19 -2
View File
@@ -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,