import React from "react"; import { connect } from "react-redux"; import Async from "react-async"; import { ButtonGroup, Popover, Button, Radio, RadioGroup, Tooltip, Position, } from "@blueprintjs/core"; import * as globals from "../../globals"; import actions from "../../actions"; import { getDiscreteCellEmbeddingRowIndex } from "../../util/stateManager/viewStackHelpers"; @connect((state) => { return { layoutChoice: state.layoutChoice, // TODO: really should clean up naming, s/layout/embedding/g schema: state.annoMatrix?.schema, crossfilter: state.obsCrossfilter, }; }) class Embedding extends React.PureComponent { constructor(props) { super(props); this.state = {}; } handleLayoutChoiceChange = (e) => { const { dispatch } = this.props; dispatch(actions.layoutChoiceAction(e.currentTarget.value)); }; render() { const { layoutChoice, schema, crossfilter } = this.props; const { annoMatrix } = crossfilter; return ( } // minimal /* removes arrow */ position={Position.TOP_LEFT} content={

Embedding Choice

There are {schema?.dataframe?.nObs} cells in the entire dataset.

{layoutChoice.available.map((name) => ( ))}
} />
); } } export default Embedding; const loadEmbeddingCounts = async ({ annoMatrix, layoutName }) => { const embedding = await annoMatrix.fetch("emb", layoutName); const discreteCellIndex = getDiscreteCellEmbeddingRowIndex(embedding); return { embedding, discreteCellIndex }; }; const LayoutChoice = ({ annoMatrix, layoutName }) => { return ( {({ data, error, isPending }) => { if (error) { /* log, as this is unexpected */ console.error(error); } if (error || isPending) { /* still loading, or errored out - just omit counts (TODO: spinner?) */ return ; } if (data) { const { embedding, discreteCellIndex } = data; const isAllCells = discreteCellIndex.size() === embedding.length; const sizeHint = `${discreteCellIndex.size()} ${ isAllCells ? "(all) " : "" }cells`; return ( ); } return null; }} ); };