Skip to content

Commit

Permalink
sync: master to vercel-preview (#7)
Browse files Browse the repository at this point in the history
* Create sync-vercel-preview-branch.yml

* Cell Activity in Lineage Tree (#5)

* Separate static info from dynamic state

* Add tab for activity in cell lineage

* Small cleanup

---------

Co-authored-by: Jonathan Fisher <[email protected]>
  • Loading branch information
screenumass and jpfisher72 committed Apr 23, 2024
1 parent 1869475 commit 603a2e6
Show file tree
Hide file tree
Showing 4 changed files with 808 additions and 328 deletions.
28 changes: 13 additions & 15 deletions immuscreen/src/app/celllineage/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@ import FlashAutoIcon from '@mui/icons-material/FlashAuto';
import UndoOutlinedIcon from '@mui/icons-material/UndoOutlined';
import LoadingButton from '@mui/lab/LoadingButton';
import { Download, Sync } from "@mui/icons-material";
import { downloadSVG, extractQueryValues, generateCellLineageTreeState } from "./utils";
import { CellQueryValue, CellLineageTreeState, CellName, DynamicCellTypeInfo } from "./types";
import { cellTypeStaticInfo } from "../../common/consts";
import { StaticCellTypeInfo, CellLineageTreeState, downloadSVG, extractQueryValues, generateCellLineageTreeState, DynamicCellTypeInfo, CellName, cellLineageTreeStaticInfo } from "./utils";


type QueryGroup = {
intersect?: CellQueryValue[][],
exclude?: CellQueryValue[][],
union?: CellQueryValue[],
intersect?: string[][],
exclude?: string[][],
union?: string[],
name: string
}

Expand Down Expand Up @@ -103,7 +101,7 @@ export default function UpSet() {
if (mode === "B" && (currentlySelected * 2) > cellTreeSelectionLimit) {
handleOpenSnackbar("Unable to apply \"Both\" stimulation status due to selection limit (6)")
} else {
const newState: CellLineageTreeState = Object.fromEntries(Object.entries(cellTypeState).map(([key, value]: [CellName, DynamicCellTypeInfo]) => cellTypeStaticInfo[key].stimulable ? [key, {...value, stimulated: mode}] : [key, value])) as CellLineageTreeState
const newState: CellLineageTreeState = Object.fromEntries(Object.entries(cellTypeState).map(([key, value]: [CellName, DynamicCellTypeInfo]) => cellLineageTreeStaticInfo[key].stimulable ? [key, {...value, stimulated: mode}] : [key, value])) as CellLineageTreeState
setCellTypeState(newState)
}
}
Expand Down Expand Up @@ -199,23 +197,23 @@ export default function UpSet() {
*/
const generateQuery = useCallback((selectedCellsState: Partial<CellLineageTreeState>, classes: CCRE_CLASS[]) => {
//stores extracted relevant information from selectedCells for easier access
let cells: { displayName: string, queryVals: CellQueryValue[] }[] = [];
let cells: { displayName: string, queryVals: string[] }[] = [];

//Out of selectedCells, extract relevant information. Create two entries for cells with "B" stimulation to iterate through more easily later
Object.entries(selectedCellsState).forEach(([key, value]: [CellName, DynamicCellTypeInfo]) => {
const name = key.replace('-', '_')
if (value.stimulated == "B") {
cells.push({ displayName: name + '_U', queryVals: extractQueryValues(cellTypeStaticInfo[key], "U") })
cells.push({ displayName: name + '_S', queryVals: extractQueryValues(cellTypeStaticInfo[key], "S") })
} else cells.push({ displayName: name + '_' + value.stimulated, queryVals: extractQueryValues(cellTypeStaticInfo[key], value.stimulated) })
cells.push({ displayName: name + '_U', queryVals: extractQueryValues(cellLineageTreeStaticInfo[key], "U") })
cells.push({ displayName: name + '_S', queryVals: extractQueryValues(cellLineageTreeStaticInfo[key], "S") })
} else cells.push({ displayName: name + '_' + value.stimulated, queryVals: extractQueryValues(cellLineageTreeStaticInfo[key], value.stimulated) })
})

//Holds the combination of union/intersection/exlude and name for each query
let queryGroups: QueryGroup[] = []

//Union of all cells
if (Object.keys(selectedCellsState).length > 0) {
queryGroups.push({ union: Object.entries(selectedCellsState).map(([key, value]: [CellName, DynamicCellTypeInfo]) => extractQueryValues(cellTypeStaticInfo[key], value.stimulated)).flat(2), name: 'Union_All' })
queryGroups.push({ union: Object.entries(selectedCellsState).map(([key, value]: [CellName, DynamicCellTypeInfo]) => extractQueryValues(cellLineageTreeStaticInfo[key], value.stimulated)).flat(2), name: 'Union_All' })
}

//Individual counts
Expand Down Expand Up @@ -427,11 +425,11 @@ export default function UpSet() {
//These boolean values are used to disable buttons in certain situaions
const noneSelected = !Object.values(cellTypeState).map(x => x.selected).find(x => x)
const noneStimulated = Object.entries(cellTypeState)
.every(([key, value]: [CellName, DynamicCellTypeInfo]) => cellTypeStaticInfo[key].stimulable ? value.stimulated === "U" : true)
.every(([key, value]: [CellName, DynamicCellTypeInfo]) => cellLineageTreeStaticInfo[key].stimulable ? value.stimulated === "U" : true)
const allStimulated = Object.entries(cellTypeState)
.every(([key, value]: [CellName, DynamicCellTypeInfo]) => cellTypeStaticInfo[key].stimulable ? value.stimulated === "S": true)
.every(([key, value]: [CellName, DynamicCellTypeInfo]) => cellLineageTreeStaticInfo[key].stimulable ? value.stimulated === "S": true)
const allBothStimulated = Object.entries(cellTypeState)
.every(([key, value]: [CellName, DynamicCellTypeInfo]) => cellTypeStaticInfo[key].stimulable ? value.stimulated === "B" : true)
.every(([key, value]: [CellName, DynamicCellTypeInfo]) => cellLineageTreeStaticInfo[key].stimulable ? value.stimulated === "B" : true)

const groupCheckbox = (group: CCRE_CLASS, key: number) => {
return (
Expand Down
Loading

0 comments on commit 603a2e6

Please sign in to comment.