npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@lipme/gene-map-component

v0.2.2

Published

Vue Component to display genes.

Readme

gene-map-component

Vue Component to display genes.

Overview

GeneMapComponent is a Vue component designed to visualize gene data in a structured and interactive manner. It supports features like compressed views, pagination, highlighting regions, and exporting visualizations as images.

Features

  • Visualize gene data with customizable labels, tooltips, and links.
  • Support for compressed and paginated views.
  • Highlight specific regions of interest.
  • Export the visualization as an image.
  • Fully configurable dimensions and layout.

Props

label

  • Type: (x: GeneData) => string

  • Description: A function to define how each gene should be labeled.

  • Default: Returns the Name attribute of the gene.

  • Example:

    label: (gene) => gene.attributes!.Name![0] || 'Unnamed Gene'

linksGenerator

  • Type: (x: GeneData) => string | undefined

  • Description: A function to generate a URL for each gene, used for redirection when a gene is clicked.

  • Default: undefined

  • Example:

    linksGenerator: (gene) => `https://example.com/gene/${gene.attributes!.ID![0]}`

tooltip

  • Type: (x: GeneData) => string

  • Description: A function to define the tooltip content for each gene.

  • Default: Returns the Alias attribute of the gene if available.

  • Example:

    tooltip: (gene) => `Gene: ${gene.attributes!.Alias![0]}`

selection

  • Type: RegionInputType | PaginationInputType

  • Description: Specifies the region or pagination configuration for gene display.

  • Required: Yes

  • Types:

    • RegionInputType: For displaying a specific region

      {
        seqID: string;
        start: number;
        end: number;
        compressed?: {
          offset: number;
        };
      }
    • PaginationInputType: For paginated display

      {
        seqID: string
        index: number
        config: {
          numberOfRows: number
        }
      }
  • Examples:

    • Region view:

      selection: {
        seqID: 'chromosome1',
        start: 1000,
        end: 5000,
        compressed: { offset: 50 }
      }
    • Paginated view:

      selection: {
        seqID: 'chromosome1',
        index: 2,
        config: { numberOfRows: 8 }
      }

fileUrl

  • Type: string

  • Description: The HTTP source of the GFF3 file containing gene data.

  • Example:

    fileUrl: 'https://example.com/data/genes.gff3'

showLegend

  • Type: boolean
  • Description: Whether to display the legend in the visualization.
  • Default: true

indexUrl

  • Type: string | undefined
  • Description: The index file URL for the GFF3 file. Defaults to the fileUrl with .tbi appended.
  • Default: undefined

colors

  • Type: ColorService

  • Description: A service to manage color schemes for the visualization.

  • Example:

    import { ColorService } from '@lipme/gffcolors'
    const colors = new ColorService()

highlight

  • Type: Array<[number, number]> | undefined

  • Description: An array of regions to highlight in the visualization.

  • Default: undefined

  • Example:

    highlight: [
      [1000, 2000],
      [3000, 4000]
    ]

config

  • Type: { width: number; height: number; rowSize: number }

  • Description: Configuration for the visualization layout.

    • width: Width of the visualization in pixels.
    • height: Height of the visualization in pixels.
    • rowSize: Size of each level.
  • Default: { width: 1000, height: 800, rowSize: 30000 }

  • Example:

    config: { width: 1200, height: 900, rowSize: 20000 }

Emits

selectGene

  • Type: (value: GeneData) => void

  • Description: Emitted when a gene is selected (clicked).

  • Example:

    <GeneMapComponent @selectGene="onGeneSelect" />
    <script>
      function onGeneSelect(gene) {
        console.log('Selected gene:', gene)
      }
    </script>

Slots

screenshot

  • Props: { screenshotFunction: () => void }

  • Description: Slot to provide a custom button or UI for exporting the visualization as an image.

  • Example:

    <template #screenshot="{ screenshotFunction }">
      <button @click="screenshotFunction">Export as Image</button>
    </template>

Examples

Basic Region View

<template>
  <GeneMapComponent
    :fileUrl="'https://example.com/data/genes.gff3'"
    :colors="colorService"
    :selection="{
      seqID: 'chromosome1',
      start: 1000,
      end: 5000
    }"
  />
</template>

<script setup>
import { ColorService } from '@lipme/gffcolors'
const colorService = new ColorService()
</script>

Paginated View

<template>
  <GeneMapComponent
    :fileUrl="'https://example.com/data/genes.gff3'"
    :colors="colorService"
    :selection="{
      seqID: 'chromosome1',
      index: 2,
      config: { numberOfRows: 8 }
    }"
    :config="{ width: 1200, height: 800, rowSize: 10000 }"
  />
</template>

<script setup>
import { ColorService } from '@lipme/gffcolors'
const colorService = new ColorService()
</script>

Compressed View with Highlighting

<template>
  <GeneMapComponent
    :fileUrl="'https://example.com/data/genes.gff3'"
    :colors="colorService"
    :selection="{
      seqID: 'chromosome1',
      start: 1000,
      end: 5000,
      compressed: { offset: 50 }
    }"
    :highlight="[
      [1500, 2500],
      [3000, 4000]
    ]"
    :config="{ width: 1200, height: 800, rowSize: 10000 }"
  />
</template>

<script setup>
import { ColorService } from '@lipme/gffcolors'
const colorService = new ColorService()
</script>

Custom Gene Labeling and Export

<template>
  <GeneMapComponent
    :fileUrl="'https://example.com/data/genes.gff3'"
    :colors="colorService"
    :selection="{
      seqID: 'chromosome1',
      start: 1000,
      end: 5000
    }"
    :label="customLabel"
    :tooltip="customTooltip"
    :linksGenerator="generateLink"
  >
    <template #screenshot="{ screenshotFunction }">
      <button @click="screenshotFunction">Export as Image</button>
    </template>
  </GeneMapComponent>
</template>

<script setup>
import { ColorService } from '@lipme/gffcolors'
const colorService = new ColorService()

function customLabel(gene) {
  return gene.attributes?.locus_tag?.[0] || gene.attributes?.Name?.[0] || 'Unknown'
}

function customTooltip(gene) {
  return `${gene.attributes?.Name?.[0]} - ${gene.attributes?.product?.[0] || 'No product info'}`
}

function generateLink(gene) {
  return `https://example.com/gene/${gene.attributes?.ID?.[0]}`
}
</script>

Recommended IDE Setup

VSCode + Volar (and disable Vetur).

Type Support for .vue Imports in TS

TypeScript cannot handle type information for .vue imports by default, so we replace the tsc CLI with vue-tsc for type checking. In editors, we need Volar to make the TypeScript language service aware of .vue types.

Customize Configuration

See Vite Configuration Reference.

Project Setup

npm install

Compile and Hot-Reload for Development

npm run dev

Type-Check, Compile and Minify for Production

npm run build

Run Unit Tests with Vitest

npm run test:unit

Run End-to-End Tests with Cypress

npm run test:e2e:dev

This runs the end-to-end tests against the Vite development server. It is much faster than the production build.

But it's still recommended to test the production build with test:e2e before deploying (e.g. in CI environments):

npm run build
npm run test:e2e

Lint with ESLint

npm run lint