Skip to content

Commit

Permalink
Merge pull request #26 from NickAkhmetov/nickakhmetov/visx
Browse files Browse the repository at this point in the history
  • Loading branch information
NickAkhmetov authored Oct 23, 2024
2 parents e2e1425 + 544e6e5 commit 2734da4
Show file tree
Hide file tree
Showing 85 changed files with 14,876 additions and 7,119 deletions.
17 changes: 17 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"eslint.format.enable": true,
"eslint.useFlatConfig": true,
"eslint.workingDirectories": ["./src"],
"[javascript|typescript|javascriptreact|typescriptreact]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"editor.codeActionsOnSave": {
"source.sortImports": "always",
"source.fixAll": "always"
},
"cSpell.words": [
"cellpop",
"epanechnikov",
"zustand"
]
}
75 changes: 39 additions & 36 deletions demo/animation.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,43 @@
import { showAnimation } from "../src/visualization/animation";
import { loadHuBMAPData } from "../src/dataLoading/dataHuBMAP";
import { showAnimation } from "../src/visualization/animation";
// data
const uuids = ["ad693f99fb9006e68a53e97598da1509",
"173de2e80adf6a73ac8cff5ccce20dfc",
"b95f34761c252ebbd1e482cd9afae73f",
"5a5ca03fa623602d9a859224aa40ace4",
"3c1b10bc912c60c9afc36b7423695236",
"1dc16eb0270ff73291dd45b6a96aa3c0",
"b05c21f9c94ce1a22a9694cd0fe0291e",
"8cdb42ed1194255c74c8462b99bbd7ef",
"fe0ded5fc0355c95239f9c040dd31e99",
"367fee3b40cba682063289505b922be1",
"b99fc30c4195958fbef217fa9ed9ec8f",
"898138b7f45a67c574e9955fb400e9be",
"f220c9e7bcaea3a87162cbe61287ea4d",
"e5f7a14d93659bd0b8dc2819ffa9bc4b",
"56cbda4789f04d79c0c3dffe21816d48",
"0b6f63f2bd61a8c091fc7afc0f318ad1",
"62efbe0a6abd0bcf53ab9ab29e7cd73f",
"4b62d9d2c248323ce029859f953fdc57",
"c81b0dc9d16eb825a7d6bce6e1b3678f",
"5ee240959c96b49d960702755478b9fc",
"7c9e07c96d144536525b1f889acee14d",
"dd7ccbc306692fc5ff5e61c22845da21",
"9a7e6be288b27ddbd3366c4ae41bbcd2",
"018a905cdbdff684760859f594d3fd77",
"af5741dad7aecf7960a129c3d2ae642a",
"6e1db473492095ccc2f1393d7259b9c0",
"fae9a1f2e7abefca2203765a3c7a5ba1",
"8d631eee88855ac59155edca2a3bc1ca",
"1ea6c0ac5ba60fe35bf63af8699b6fbe"];

const uuids = [
"ad693f99fb9006e68a53e97598da1509",
"173de2e80adf6a73ac8cff5ccce20dfc",
"b95f34761c252ebbd1e482cd9afae73f",
"5a5ca03fa623602d9a859224aa40ace4",
"3c1b10bc912c60c9afc36b7423695236",
"1dc16eb0270ff73291dd45b6a96aa3c0",
"b05c21f9c94ce1a22a9694cd0fe0291e",
"8cdb42ed1194255c74c8462b99bbd7ef",
"fe0ded5fc0355c95239f9c040dd31e99",
"367fee3b40cba682063289505b922be1",
"b99fc30c4195958fbef217fa9ed9ec8f",
"898138b7f45a67c574e9955fb400e9be",
"f220c9e7bcaea3a87162cbe61287ea4d",
"e5f7a14d93659bd0b8dc2819ffa9bc4b",
"56cbda4789f04d79c0c3dffe21816d48",
"0b6f63f2bd61a8c091fc7afc0f318ad1",
"62efbe0a6abd0bcf53ab9ab29e7cd73f",
"4b62d9d2c248323ce029859f953fdc57",
"c81b0dc9d16eb825a7d6bce6e1b3678f",
"5ee240959c96b49d960702755478b9fc",
"7c9e07c96d144536525b1f889acee14d",
"dd7ccbc306692fc5ff5e61c22845da21",
"9a7e6be288b27ddbd3366c4ae41bbcd2",
"018a905cdbdff684760859f594d3fd77",
"af5741dad7aecf7960a129c3d2ae642a",
"6e1db473492095ccc2f1393d7259b9c0",
"fae9a1f2e7abefca2203765a3c7a5ba1",
"8d631eee88855ac59155edca2a3bc1ca",
"1ea6c0ac5ba60fe35bf63af8699b6fbe",
];

// Load data directly as demo
loadHuBMAPData(uuids).then((data) => {
showAnimation(data!);
}).catch(error => {
console.error(error);
});
loadHuBMAPData(uuids)
.then((data) => {
showAnimation(data!);
})
.catch((error) => {
console.error(error);
});
153 changes: 74 additions & 79 deletions demo/demo.tsx
Original file line number Diff line number Diff line change
@@ -1,91 +1,86 @@
import React, { useEffect, useState } from "react";
import { loadHuBMAPData } from "../src/dataLoading/dataHuBMAP";
import { CellPop } from "../src/CellPopComponent";
import { CellPopData, CellPopDimensions } from "../src/cellpop-schema";
import { getDimensions, getDimensionsGlobal } from "../src/visualization/size";

import { CellPopData } from "../src/cellpop-schema";
import { loadHuBMAPData } from "../src/dataLoading/dataHuBMAP";

function Demo() {
const [data, setData] = useState<CellPopData>();

const [data, setData] = useState<CellPopData>();

// data
const uuids = ["ad693f99fb9006e68a53e97598da1509",
"173de2e80adf6a73ac8cff5ccce20dfc",
"b95f34761c252ebbd1e482cd9afae73f",
"5a5ca03fa623602d9a859224aa40ace4",
"3c1b10bc912c60c9afc36b7423695236",
"1dc16eb0270ff73291dd45b6a96aa3c0",
"b05c21f9c94ce1a22a9694cd0fe0291e",
"8cdb42ed1194255c74c8462b99bbd7ef",
"fe0ded5fc0355c95239f9c040dd31e99",
"367fee3b40cba682063289505b922be1",
"b99fc30c4195958fbef217fa9ed9ec8f",
"898138b7f45a67c574e9955fb400e9be",
"f220c9e7bcaea3a87162cbe61287ea4d",
"e5f7a14d93659bd0b8dc2819ffa9bc4b",
"56cbda4789f04d79c0c3dffe21816d48",
"0b6f63f2bd61a8c091fc7afc0f318ad1",
"62efbe0a6abd0bcf53ab9ab29e7cd73f",
"4b62d9d2c248323ce029859f953fdc57",
"c81b0dc9d16eb825a7d6bce6e1b3678f",
"5ee240959c96b49d960702755478b9fc",
"7c9e07c96d144536525b1f889acee14d",
"dd7ccbc306692fc5ff5e61c22845da21",
"9a7e6be288b27ddbd3366c4ae41bbcd2",
"018a905cdbdff684760859f594d3fd77",
"af5741dad7aecf7960a129c3d2ae642a",
"6e1db473492095ccc2f1393d7259b9c0",
"fae9a1f2e7abefca2203765a3c7a5ba1",
"8d631eee88855ac59155edca2a3bc1ca",
"1ea6c0ac5ba60fe35bf63af8699b6fbe"];

// useEffect to make sure the data only loads once
useEffect(() => {
loadHuBMAPData(uuids).then((data) => {
setData(data!);
// getMainVis(data);
}).catch(error => {
console.error(error);
});
}, []);

// const props = {
// data: null,
// theme: "light",
// }

const widthRatio = 0.8;
const heightRatio = 0.8;

const widthRight = 45 * 25;
const heightBottom = 20 * 40;
// data
const uuids = [
"ad693f99fb9006e68a53e97598da1509",
"173de2e80adf6a73ac8cff5ccce20dfc",
"b95f34761c252ebbd1e482cd9afae73f",
"5a5ca03fa623602d9a859224aa40ace4",
"3c1b10bc912c60c9afc36b7423695236",
"1dc16eb0270ff73291dd45b6a96aa3c0",
"b05c21f9c94ce1a22a9694cd0fe0291e",
"8cdb42ed1194255c74c8462b99bbd7ef",
"fe0ded5fc0355c95239f9c040dd31e99",
"367fee3b40cba682063289505b922be1",
"b99fc30c4195958fbef217fa9ed9ec8f",
"898138b7f45a67c574e9955fb400e9be",
"f220c9e7bcaea3a87162cbe61287ea4d",
"e5f7a14d93659bd0b8dc2819ffa9bc4b",
"56cbda4789f04d79c0c3dffe21816d48",
"0b6f63f2bd61a8c091fc7afc0f318ad1",
"62efbe0a6abd0bcf53ab9ab29e7cd73f",
"4b62d9d2c248323ce029859f953fdc57",
"c81b0dc9d16eb825a7d6bce6e1b3678f",
"5ee240959c96b49d960702755478b9fc",
"7c9e07c96d144536525b1f889acee14d",
"dd7ccbc306692fc5ff5e61c22845da21",
"9a7e6be288b27ddbd3366c4ae41bbcd2",
"018a905cdbdff684760859f594d3fd77",
"af5741dad7aecf7960a129c3d2ae642a",
"6e1db473492095ccc2f1393d7259b9c0",
"fae9a1f2e7abefca2203765a3c7a5ba1",
"8d631eee88855ac59155edca2a3bc1ca",
"1ea6c0ac5ba60fe35bf63af8699b6fbe",
];

const width = widthRight / widthRatio;
const height = heightBottom / heightRatio;
// useEffect to make sure the data only loads once
useEffect(() => {
loadHuBMAPData(uuids)
.then((data) => {
setData(data!);
// getMainVis(data);
})
.catch((error) => {
console.error(error);
});
}, []);

const widthLeft = width - widthRight;
const heightTop = height - heightBottom;
// const props = {
// data: null,
// theme: "light",
// }

// const dimensions = {
// global: {width: width, widthSplit: [widthLeft, widthRight], height: height, heightSplit: [heightTop, heightBottom]},
// heatmap: {offsetWidth: widthLeft, offsetHeight: heightTop, width: widthRight, height: heightBottom, margin: {top: 0, right: 400, bottom: 100, left: 0}},
// barTop: {offsetWidth: widthLeft, offsetHeight: 0, width: widthRight, height: heightTop, margin: {top: 50, right: 50, bottom: 0, left: 0}},
// violinTop: {offsetWidth: widthLeft, offsetHeight: 0, width: widthRight, height: heightTop, margin: {top: 50, right: 50, bottom: 0, left: 0}},
// barLeft: {offsetWidth: 0, offsetHeight: heightTop, width: widthLeft, height: heightBottom, margin: {top: 0, right: 0, bottom: 100, left: 50}},
// violinLeft: {offsetWidth: 0, offsetHeight: heightTop, width: widthLeft, height: heightBottom, margin: {top: 0, right: 0, bottom: 100, left: 50}},
// graph: {offsetWidth: widthLeft, offsetHeight: height, width: widthRight, height: heightTop, margin: {top: 0, right: 200, bottom: 0, left: 0}},
// detailBar: {offsetWidth: widthLeft, offsetHeight: 0, width: widthRight, height: height, margin: {top: 50, right: 200, bottom: 50, left: 0}},
// textSize: {title: "20px", label: "30px", labelSmall: "20px", tick: "10px"}
// } as CellPopDimensions;
console.log(data);

const dimensions = getDimensions(1500, 200, 400, 200, 5, 5, 100, 5, 1000, 200, 400, 0, 5, 5, 100, 5, 1000, 900, 50, 50);
if (!data) {
return <div>Loading...</div>;
}

return (
<>
{data ? <CellPop data={data} theme={"light"} dimensions={dimensions}/> : <div>Loading...</div>}
</>
);
return (
<CellPop
data={data}
theme={"light"}
dimensions={{ width: 1500, height: 1000 }}
yAxisConfig={{
label: "Sample",
createHref: (row) =>
`https://portal.hubmapconsortium.org/browse/${row}`,
flipAxisPosition: true,
}}
xAxisConfig={{
label: "Cell Type",
createHref: (col) =>
`https://www.ebi.ac.uk/ols4/search?q=${col}&ontology=cl`,
flipAxisPosition: true,
}}
/>
);
}

export default Demo;
export default Demo;
6 changes: 2 additions & 4 deletions demo/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import React from "react";
import ReactDOM from "react-dom/client";
import Demo from "./demo.jsx";
import Demo from "./demo.tsx";

ReactDOM.createRoot(document.getElementById("root")!).render(
<Demo />
);
ReactDOM.createRoot(document.getElementById("root")!).render(<Demo />);
73 changes: 37 additions & 36 deletions demo/main.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,42 @@
import { getMainVis } from "../src/cellpop";
// import { getMainVis } from "../src/cellpop";
import { loadHuBMAPData } from "../src/dataLoading/dataHuBMAP";

// data
const uuids = ["ad693f99fb9006e68a53e97598da1509",
"173de2e80adf6a73ac8cff5ccce20dfc",
"b95f34761c252ebbd1e482cd9afae73f",
"5a5ca03fa623602d9a859224aa40ace4",
"3c1b10bc912c60c9afc36b7423695236",
"1dc16eb0270ff73291dd45b6a96aa3c0",
"b05c21f9c94ce1a22a9694cd0fe0291e",
"8cdb42ed1194255c74c8462b99bbd7ef",
"fe0ded5fc0355c95239f9c040dd31e99",
"367fee3b40cba682063289505b922be1",
"b99fc30c4195958fbef217fa9ed9ec8f",
"898138b7f45a67c574e9955fb400e9be",
"f220c9e7bcaea3a87162cbe61287ea4d",
"e5f7a14d93659bd0b8dc2819ffa9bc4b",
"56cbda4789f04d79c0c3dffe21816d48",
"0b6f63f2bd61a8c091fc7afc0f318ad1",
"62efbe0a6abd0bcf53ab9ab29e7cd73f",
"4b62d9d2c248323ce029859f953fdc57",
"c81b0dc9d16eb825a7d6bce6e1b3678f",
"5ee240959c96b49d960702755478b9fc",
"7c9e07c96d144536525b1f889acee14d",
"dd7ccbc306692fc5ff5e61c22845da21",
"9a7e6be288b27ddbd3366c4ae41bbcd2",
"018a905cdbdff684760859f594d3fd77",
"af5741dad7aecf7960a129c3d2ae642a",
"6e1db473492095ccc2f1393d7259b9c0",
"fae9a1f2e7abefca2203765a3c7a5ba1",
"8d631eee88855ac59155edca2a3bc1ca",
"1ea6c0ac5ba60fe35bf63af8699b6fbe"];

const uuids = [
"ad693f99fb9006e68a53e97598da1509",
"173de2e80adf6a73ac8cff5ccce20dfc",
"b95f34761c252ebbd1e482cd9afae73f",
"5a5ca03fa623602d9a859224aa40ace4",
"3c1b10bc912c60c9afc36b7423695236",
"1dc16eb0270ff73291dd45b6a96aa3c0",
"b05c21f9c94ce1a22a9694cd0fe0291e",
"8cdb42ed1194255c74c8462b99bbd7ef",
"fe0ded5fc0355c95239f9c040dd31e99",
"367fee3b40cba682063289505b922be1",
"b99fc30c4195958fbef217fa9ed9ec8f",
"898138b7f45a67c574e9955fb400e9be",
"f220c9e7bcaea3a87162cbe61287ea4d",
"e5f7a14d93659bd0b8dc2819ffa9bc4b",
"56cbda4789f04d79c0c3dffe21816d48",
"0b6f63f2bd61a8c091fc7afc0f318ad1",
"62efbe0a6abd0bcf53ab9ab29e7cd73f",
"4b62d9d2c248323ce029859f953fdc57",
"c81b0dc9d16eb825a7d6bce6e1b3678f",
"5ee240959c96b49d960702755478b9fc",
"7c9e07c96d144536525b1f889acee14d",
"dd7ccbc306692fc5ff5e61c22845da21",
"9a7e6be288b27ddbd3366c4ae41bbcd2",
"018a905cdbdff684760859f594d3fd77",
"af5741dad7aecf7960a129c3d2ae642a",
"6e1db473492095ccc2f1393d7259b9c0",
"fae9a1f2e7abefca2203765a3c7a5ba1",
"8d631eee88855ac59155edca2a3bc1ca",
"1ea6c0ac5ba60fe35bf63af8699b6fbe",
];

// Load data directly as demo
loadHuBMAPData(uuids).then((data) => {
getMainVis(data!);
}).catch(error => {
console.error(error);
});
// loadHuBMAPData(uuids).then((data) => {
// getMainVis(data!);
// }).catch(error => {
// console.error(error);
// });
27 changes: 22 additions & 5 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,34 @@
// @ts-check

import eslint from "@eslint/js";
import eslintConfigPrettier from "eslint-plugin-prettier/recommended";
import reactPlugin from "eslint-plugin-react";
import globals from 'globals';
import tseslint from "typescript-eslint";

export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.recommended,
eslintConfigPrettier,
{
"rules": {
files: ['**/*.{jsx,tsx}'],
...reactPlugin.configs.flat.recommended,
},
{
files: ['**/*.{jsx,tsx}'],
languageOptions: {
globals: {
...globals.serviceworker,
...globals.browser,
},
},
},
{
rules: {
"linebreak-style": ["error", "unix"],
"quotes": ["error", "double"],
"semi": ["error", "always"],
quotes: ["error", "double"],
semi: ["error", "always"],
"no-trailing-spaces": "error",
}
},
}
);
);
2 changes: 1 addition & 1 deletion missing-types.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
declare module "@vitessce/zarr" {
export * from "@vitessce/zarr";
export * from "@vitessce/zarr";
}
Loading

0 comments on commit 2734da4

Please sign in to comment.