# graphgenomeviewer

> React component for graph genome visualization

Latest version **5.0.5** (published 2025-02-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install graphgenomeviewer
pnpm add graphgenomeviewer
yarn add graphgenomeviewer
bun add graphgenomeviewer
```

## Health

**Score 35/100 (D)** — status: stable.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 5.0.5 |
| Published | 2025-02-12 |
| First published | 2020-09-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=10 |
| Dependencies | 16 |
| Unpacked size | 70.5 KB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 13 |
| Author | cmdcolin |
| Maintainers | cmdcolin |

## Links

- npm: https://www.npmjs.com/package/graphgenomeviewer
- Repository: https://github.com/cmdcolin/graphgenomeviewer
- npm.io page: https://npm.io/package/graphgenomeviewer

## Dependencies (16)

- [d3](https://npm.io/package/d3.md) ^7.8.5
- [eslint](https://npm.io/package/eslint.md) ^9.7.0
- [mathjs](https://npm.io/package/mathjs.md) ^14.0.0
- [storybook](https://npm.io/package/storybook.md) ^8.1.6
- [@types/d3-zoom](https://npm.io/package/@types/d3-zoom.md) ^3.0.4
- [d3-interpolate](https://npm.io/package/d3-interpolate.md) ^3.0.1
- [@storybook/test](https://npm.io/package/@storybook/test.md) ^8.1.6
- [@types/d3-force](https://npm.io/package/@types/d3-force.md) ^3.0.5
- [@storybook/react](https://npm.io/package/@storybook/react.md) ^8.1.6
- [@storybook/blocks](https://npm.io/package/@storybook/blocks.md) ^8.1.6
- [@storybook/react-vite](https://npm.io/package/@storybook/react-vite.md) ^8.1.6
- [@storybook/addon-links](https://npm.io/package/@storybook/addon-links.md) ^8.1.6
- [@types/d3-scale-chromatic](https://npm.io/package/@types/d3-scale-chromatic.md) ^3.0.0
- [@storybook/addon-essentials](https://npm.io/package/@storybook/addon-essentials.md) ^8.1.6
- [@storybook/addon-onboarding](https://npm.io/package/@storybook/addon-onboarding.md) ^8.1.6
- [@storybook/addon-interactions](https://npm.io/package/@storybook/addon-interactions.md) ^8.1.6

## Recent versions

- 5.0.5 (latest) — 2025-02-12
- 5.0.4 — 2024-07-24
- 5.0.3 — 2024-07-24
- 5.0.2 — 2024-06-20
- 5.0.1 — 2024-06-20
- 5.0.0 — 2024-06-20
- 4.0.9 — 2024-06-10
- 4.0.8 — 2024-06-10
- 4.0.7 — 2024-06-10
- 4.0.6 — 2024-06-10
- 4.0.5 — 2024-06-10
- 4.0.4 — 2024-06-10
- 4.0.3 — 2024-06-10
- 4.0.2 — 2024-06-10
- 4.0.1 — 2024-06-10
- … 14 more at https://npm.io/package/graphgenomeviewer/versions

## README

# graphgenomeviewer

## Install

The graphgenomeviewer NPM module is a React component that can be installed with
yarn or npm

    yarn add graphgenomeviewer

## Usage with React

```typescript
import {Graph} from 'graphgenomeviewer'

function App() {
  return (
    <Graph
      graph={{
        nodes: [
          { id: 'id1', length: 5000 },
          { id: 'id2', length: 10000 },
        ],
        links: [{ source: 'id1', target: 'id2', id: 'edge1' }],
      }}
      width={800}
      height={600}
    />
  )
}
```

or with helper that fetches a GFA file and parses it

```typescript
import {GFAGraph} from 'graphgenomeviewer'

function App() {
  return (
    <GFAGraph
      url="myfile.gfa"
      width={800}
      height={600}

    />
  )
}
```

## API

Here are all the props for the Graph component

```typescript
function Graph({
  graph,
  drawPaths = false,
  drawLabels = false,
  colorScheme = 'Rainbow',
  chunkSize = 1000,
  linkSteps = 10,
  sequenceThickness = 10,
  linkThickness = 2,
  theta = 0.9,
  strengthCenter = -50,
  width = 2000,
  height = 1000,
  onFeatureClick = () => {},
}: {
  graph: Graph
  drawPaths?: boolean
  drawLabels?: boolean
  colorScheme?: string
  width?: number
  height?: number
  chunkSize?: number
  linkSteps?: number
  sequenceThickness?: number
  linkThickness?: number
  theta?: number
  strengthCenter?: number
  onFeatureClick?: (arg?: Record<string, unknown>) => void
}) {
  /*...*/
}
```

The GFAGraph everything is the same except you use either

- a url to a GFA file supplied to the url prop
- a string of GFA data supplied to the data prop

```typescript
function GFAGraph({
  url,
  data,
  drawPaths = false,
  drawLabels = false,
  colorScheme = 'Rainbow',
  chunkSize = 1000,
  linkSteps = 10,
  sequenceThickness = 10,
  linkThickness = 2,
  theta = 0.9,
  strengthCenter = -50,
  width = 2000,
  height = 1000,
  onFeatureClick = () => {},
}: {
  url: string
  data: string
  drawPaths?: boolean
  drawLabels?: boolean
  colorScheme?: string
  width?: number
  height?: number
  chunkSize?: number
  linkSteps?: number
  sequenceThickness?: number
  linkThickness?: number
  theta?: number
  strengthCenter?: number
  onFeatureClick?: (arg?: Record<string, unknown>) => void
}) {
  /*...*/
}
```

the Graph type (used by the "Graph" component and not "GFAGraph" since GFAGraph
just builds this internally is as follows

```typescript

export interface Path { name: string path: string }

export interface Node { id: string sequence?: string tags?: Record<string, unknown> cigar?: string length?: number }

export interface Graph { nodes: Node[] links: Link[] paths?: Path[] }


```

---
_Source: https://npm.io/package/graphgenomeviewer · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
