Git Product home page Git Product logo

logomakerjs's Introduction

LogoMakerJS: Embeddable SVG Sequence Logos

This is forked from and heavily based on https://github.com/weng-lab/logojs-package, and aims to add functionality akin to Python's LogoMaker

LogoMakerJS is a Javascipt package for creating SVG sequence logos. LogoMakerJS supports a wide range of biological use cases. This README provides a quick overview of LogoMakerJS installation and usage.

For detailed examples with code samples are available at our Storybook instance on GitHub Pages.

LogoMakerJS can be used with and without ReactJS. A companion web app makes it easy to share SVG logos and generate them in batches from the output of common tools such as the MEME Suite.

Using in your web application

You can add LogoMakerJS to your project using NPM or Yarn:

yarn add logomakerjs

or

npm install logomakerjs

If you want to use LogoMakerJS in a static web page, you can simply include the package along with React with a few static script tag, which will add LogoMakerJS to the global namespace as logomakerjs:

<script
  crossorigin
  src="https://unpkg.com/react@18/umd/react.production.min.js"
></script>
<script
  crossorigin
  src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"
></script>
<script
  src="https://cdn.jsdelivr.net/npm/[email protected]/dist/index.js"
  type="text/javascript"
></script>

Quick example: a DNA logo

The transcription factor CTCF binds a well-known consensus DNA sequence, rendered below with LogoMakerJS:

CTCF logo

If you use ReactJS, the following code creates the CTCF consensus binding logo:

import { DNALogo } from "logomakerjs";

const CTCF_PPM = [
  [0.09, 0.31, 0.08, 0.5],
  [0.18, 0.15, 0.45, 0.2],
  [0.3, 0.05, 0.49, 0.14],
  [0.06, 0.87, 0.02, 0.03],
  [0.0, 0.98, 0.0, 0.02],
  [0.81, 0.01, 0.07, 0.09],
  [0.04, 0.57, 0.36, 0.01],
  [0.11, 0.47, 0.05, 0.35],
  [0.93, 0.01, 0.03, 0.01],
  [0.0, 0.0, 0.99, 0.01],
  [0.36, 0.0, 0.64, 0.0],
  [0.05, 0.01, 0.55, 0.37],
  [0.03, 0.0, 0.97, 0.0],
  [0.06, 0.0, 0.85, 0.07],
  [0.11, 0.8, 0.0, 0.07],
  [0.4, 0.01, 0.55, 0.01],
  [0.09, 0.53, 0.33, 0.04],
  [0.12, 0.35, 0.08, 0.43],
  [0.44, 0.19, 0.29, 0.06],
];

export const CTCFLogo = (props) => <DNALogo data={CTCF_PPM} type="PPM" />;

If you don't use React, the following code embeds the DNA logo in a div element:

<!doctype html>
<html>
  <body>
    <script
      crossorigin
      src="https://unpkg.com/react@18/umd/react.production.min.js"
    ></script>
    <script
      crossorigin
      src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"
    ></script>
    <script
      src="https://cdn.jsdelivr.net/npm/logomakerjs@latest/dist/index.umd.js"
      type="text/javascript"
    ></script>
    <div id="logo" style="width: 500px"></div>
    <script type="text/javascript">
      const CTCF_PPM = [
        [0.09, 0.31, 0.08, 0.5],
        [0.18, 0.15, 0.45, 0.2],
        [0.3, 0.05, 0.49, 0.14],
        [0.06, 0.87, 0.02, 0.03],
        [0.0, 0.98, 0.0, 0.02],
        [0.81, 0.01, 0.07, 0.09],
        [0.04, 0.57, 0.36, 0.01],
        [0.11, 0.47, 0.05, 0.35],
        [0.93, 0.01, 0.03, 0.01],
        [0.0, 0.0, 0.99, 0.01],
        [0.36, 0.0, 0.64, 0.0],
        [0.05, 0.01, 0.55, 0.37],
        [0.03, 0.0, 0.97, 0.0],
        [0.06, 0.0, 0.85, 0.07],
        [0.11, 0.8, 0.0, 0.07],
        [0.4, 0.01, 0.55, 0.01],
        [0.09, 0.53, 0.33, 0.04],
        [0.12, 0.35, 0.08, 0.43],
        [0.44, 0.19, 0.29, 0.06],
      ];
      logomakerjs.embedDNALogo(document.getElementById("logo"), {
        data: CTCF_PPM,
        dataType: "PPM",
      });
    </script>
  </body>
</html>

logomakerjs's People

Contributors

hpratt avatar riyavsinha avatar dependabot[bot] avatar jackh726 avatar nishiphalke avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.