From 4b240920e242630ef85da0dd4cac788f87f40f96 Mon Sep 17 00:00:00 2001 From: maniarathi Date: Sat, 12 Sep 2020 10:32:00 -0700 Subject: [PATCH] Pass in the previous crossfilter when creating a new annomatrix for a switched embedding in order to retain the previous selection of cells. (#1832) * Pass in the previous crossfilter when creating a new annomatrix for a switched embedding in order to retain the previous selection of cells. * Address Bruce's PR comment --- client/src/actions/embedding.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/client/src/actions/embedding.js b/client/src/actions/embedding.js index 5e882160..615bcd68 100644 --- a/client/src/actions/embedding.js +++ b/client/src/actions/embedding.js @@ -5,14 +5,14 @@ action creators related to embeddings choice import { AnnoMatrixObsCrossfilter } from "../annoMatrix"; import { _setEmbeddingSubset } from "../util/stateManager/viewStackHelpers"; -export async function _switchEmbedding(prevAnnoMatrix, newEmbeddingName) { +export async function _switchEmbedding(prevAnnoMatrix, prevCrossfilter, newEmbeddingName) { /* DRY helper used by this and reembedding action creators */ const base = prevAnnoMatrix.base(); const embeddingDf = await base.fetch("emb", newEmbeddingName); const annoMatrix = _setEmbeddingSubset(prevAnnoMatrix, embeddingDf); - const obsCrossfilter = await new AnnoMatrixObsCrossfilter(annoMatrix).select( + const obsCrossfilter = await new AnnoMatrixObsCrossfilter(annoMatrix, prevCrossfilter.obsCrossfilter).select( "emb", newEmbeddingName, { @@ -30,9 +30,10 @@ export const layoutChoiceAction = (newLayoutChoice) => async ( On layout choice, make sure we have selected all on the previous layout, AND the new layout. */ - const { annoMatrix: prevAnnoMatrix } = getState(); + const { annoMatrix: prevAnnoMatrix, obsCrossfilter: prevCrossfilter } = getState(); const [annoMatrix, obsCrossfilter] = await _switchEmbedding( prevAnnoMatrix, + prevCrossfilter, newLayoutChoice ); dispatch({