mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-10-07 02:38:11 +08:00
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
This commit is contained in:
@@ -5,14 +5,14 @@ action creators related to embeddings choice
|
|||||||
import { AnnoMatrixObsCrossfilter } from "../annoMatrix";
|
import { AnnoMatrixObsCrossfilter } from "../annoMatrix";
|
||||||
import { _setEmbeddingSubset } from "../util/stateManager/viewStackHelpers";
|
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
|
DRY helper used by this and reembedding action creators
|
||||||
*/
|
*/
|
||||||
const base = prevAnnoMatrix.base();
|
const base = prevAnnoMatrix.base();
|
||||||
const embeddingDf = await base.fetch("emb", newEmbeddingName);
|
const embeddingDf = await base.fetch("emb", newEmbeddingName);
|
||||||
const annoMatrix = _setEmbeddingSubset(prevAnnoMatrix, embeddingDf);
|
const annoMatrix = _setEmbeddingSubset(prevAnnoMatrix, embeddingDf);
|
||||||
const obsCrossfilter = await new AnnoMatrixObsCrossfilter(annoMatrix).select(
|
const obsCrossfilter = await new AnnoMatrixObsCrossfilter(annoMatrix, prevCrossfilter.obsCrossfilter).select(
|
||||||
"emb",
|
"emb",
|
||||||
newEmbeddingName,
|
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
|
On layout choice, make sure we have selected all on the previous layout, AND the new
|
||||||
layout.
|
layout.
|
||||||
*/
|
*/
|
||||||
const { annoMatrix: prevAnnoMatrix } = getState();
|
const { annoMatrix: prevAnnoMatrix, obsCrossfilter: prevCrossfilter } = getState();
|
||||||
const [annoMatrix, obsCrossfilter] = await _switchEmbedding(
|
const [annoMatrix, obsCrossfilter] = await _switchEmbedding(
|
||||||
prevAnnoMatrix,
|
prevAnnoMatrix,
|
||||||
|
prevCrossfilter,
|
||||||
newLayoutChoice
|
newLayoutChoice
|
||||||
);
|
);
|
||||||
dispatch({
|
dispatch({
|
||||||
|
|||||||
Reference in New Issue
Block a user