Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: React-less and HiGlass-less Gosling.js #1094

Open
wants to merge 179 commits into
base: main
Choose a base branch
from
Open

feat: React-less and HiGlass-less Gosling.js #1094

wants to merge 179 commits into from

Conversation

sehilyi
Copy link
Member

@sehilyi sehilyi commented Jan 9, 2025

This is a PR of @etowahadams's fork that tries to get rid of HiGlass and React dependencies. Not yet ready to merge.

  • Etowah's comment of things left
  • More extensive testing of the new renderer. It seems to work well for the examples in the editor, but I'm sure we'll find more bugs. We have ways to comprehensively test certain aspects of the spec but not all.
  • React API: I implemented a basic GoslingComponent but it doesn't have all of the features of the current component. I don't think this will be too difficult though.

Issues to Address

  • pnpm build gives a bunch of TypeScript errors (Found 43 errors in 13 files as of 8b3cea)
  • pnpm test gives 7 fails in 2 files → Fixed in #1097
  • pnpm run format gives 74 problems (29 errors, 45 warnings) → Fixed in #1099
    • Include /demo to eslint scope and fix lint errors
  • Zoom speed has been changed when using mouse wheels (much faster when tested in this PR) → Fixed in c58c7d9
  • GoslingComponents' original features need to be fully implemented (feat: React-less and HiGlass-less Gosling.js #1094 (comment))
  • BAM file won't load (bam-data-fetcher.ts:55 Uncaught (in promise) ReferenceError: Buffer is not defined). Probably, this should work in the preview (pnpm preview).
  • TrackTemplates does not work, resulting in the empty canvas (Track Templates: Genes, Sequence, and Ideograms example in the Editor)
  • Move track-def, renderer, and linking to src. Currently they are under demo
  • Make two packages? (gosling core and component). How to manage that, e.g., separate repo vs monorepo?
  • Showing the mouse position does not seem to work?

@sehilyi sehilyi mentioned this pull request Jan 9, 2025
5 tasks
@sehilyi sehilyi changed the title feat: React-less and HiGlass-less Gosling.js feat(core): React-less and HiGlass-less Gosling.js Jan 13, 2025
setHg(h);
}}
/>
<GoslingComponent spec={goslingSpec} width={1000} height={2000} />
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional implementation needed here for removed options.

package.json Outdated Show resolved Hide resolved
Comment on lines -11 to +16
export { init } from './core/init';
// export { init } from './core/init';
export { compile } from './compiler/compile';
export { validateGoslingSpec } from '@gosling-lang/gosling-schema';
export { GoslingComponent } from './core/gosling-component';
// export { GoslingComponent } from './core/gosling-component';
export type { GoslingRef } from './core/gosling-component';
export { embed } from './core/gosling-embed';
// export { embed } from './core/gosling-embed';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be reverted back

@@ -484,6 +481,10 @@ declare module '@higlass/tracks' {
abstract mouseMoveZoomHandler(absX?: number, abxY?: number): void;
}

export abstract class HeatmapTiledPixiTrack<Options> extends Tiled1DPixiTrack<TileData, Options> {
// TODO: fill this out
Copy link
Member Author

@sehilyi sehilyi Jan 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TS types to be added here

@dvdkouril
Copy link
Collaborator

dvdkouril commented Jan 24, 2025

I'll try to tackle at least some of the typescript errors we get at pnpm build.
Starting point: Found 120 errors in 25 files.

Edit: some low-hanging fruit fixes bring this to Found 44 errors in 14 files., but most of the remaining errors might need some more thinking...

Comment on lines -23 to +32
callback: CompileCallback,
templates: TemplateTrackDef[],
theme: Required<CompleteThemeDeep>,
containerStatus: {
containerSize?: { width: number; height: number };
containerParentSize?: { width: number; height: number };
},
urlToFetchOptions?: UrlToFetchOptions
) {
): CompileResult {
Copy link
Member Author

@sehilyi sehilyi Jan 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change makes sense (i.e., returning desired objects instead of passing over the callback function) but is not consistently reflected on other parts of code (e.g., several test fails come from this). I will stick to this change and address other parts.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! I was slightly confused about the changes to compile function and didn't want to touch it in case the callback approach is needed for some use case.

* fixed test fails related to compiled callback functions

* fix all tests except one

* remove comment statements
@sehilyi sehilyi changed the title feat(core): React-less and HiGlass-less Gosling.js feat: React-less and HiGlass-less Gosling.js Jan 27, 2025
* chore: upgrade lint and prettier for new TS version

* fix: all lint/prettier errors

* chore: update the gosling schema
Comment on lines +3 to +48
/**
* After the Gosling spec is compiled, it is a "processed spec".
* A processed spec has most of the same properties as the original spec, but some properties are
* added or modified during the compilation process.
*
* For example, a valid Gosling spec may have no 'id' property, but a processed spec will always have an 'id' property.
*
* This file contains the types for the processed spec.
*
* TODO: this file is incomplete. It should be updated to include all the properties that a processed spec can have.
*/

/** A Track after it has been compiled */
export type ProcessedTrack = ProcessedLinearTrack | ProcessedCircularTrack | ProcessedDummyTrack;
/** All tracks potentially have these properties */
export interface ProcessedTrackBase {
id: string;
height: number;
width: number;
static: boolean;
mark?: string;
orientation: 'horizontal' | 'vertical';
title?: string;
subtitle?: string;
data?: DataDeep;
assembly?: Assembly;
overlayOnPreviousTrack?: boolean;
_overlay?: OverlayTrack[];
color?: { value: string };
stroke?: { value: string };
opacity?: { value: number };
strokeWidth?: { value: number };
}

export type ProcessedLinearTrack = ProcessedTrackBase & {
layout: 'linear';
};

export type ProcessedCircularTrack = ProcessedTrackBase & {
id: string;
layout: 'circular';
startAngle: number;
endAngle: number;
outerRadius: number;
innerRadius: number;
};
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this change. I will see how I could address the TS errors that are occurred by this change.

@dvdkouril
Copy link
Collaborator

I just realized one thing:
in demo/GoslingComponent.tsx:

function renderGosling(/* ... */) {
    const compileResult = compile(gs, [], getTheme('light'), { containerSize: { width: 0, height: 0 } });
    const { trackInfos, gs: processedSpec, theme } = compileResult;
    /* ... */
}

the compile function calls this function:

// Make HiGlass models for individual tracks
const compileResult = createHiGlassModels(specCopy, trackInfos, theme, urlToFetchOptions);

But the higlass part of compileResult is ignored above! I was pretty confused today, cause I found myself in the part of the code that creates the custom Higlass tracks (views?) and was wondering how is that getting rid of the Higlass dependency.

The explanation in this diagram was super helpful to realize this. I hope I'm not mistaken.

So I guess besides just documenting my confusion from today, the insight for the PR itself is that there's a lot more fat that needs trimming in the code!

@sehilyi
Copy link
Member Author

sehilyi commented Feb 6, 2025

Ah, that's good to know. I didn't realize that those HiGlass-related parts are largely unused. I can try to see how I can cut the fat, and it may make the compiling process simpler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants