Skip to content

Commit

Permalink
Merge pull request #4266 from onursumer/oncoprintjs-package
Browse files Browse the repository at this point in the history
Migrate oncoprintjs with its commit history
  • Loading branch information
alisman authored Jun 8, 2022
2 parents de475f0 + 6cb3ddf commit 2d9f920
Show file tree
Hide file tree
Showing 76 changed files with 19,443 additions and 1,070 deletions.
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
*.ejs
*.toml
*.xml
*.py
*module.scss.d.ts
**/generated/**
src/shared/lib/oql/oql-parser.js
packages/**/dist/**
yarn.lock
LICENSE
.prettierignore
.DS_Store
.gitignore
Expand Down
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,10 @@
"@babel/plugin-transform-modules-commonjs": "^7.4.4",
"@babel/preset-env": "^7.4.4",
"@babel/preset-react": "^7.0.0",
"@rollup/plugin-commonjs": "^11.0.0",
"@rollup/plugin-json": "^4.0.2",
"@rollup/plugin-node-resolve": "^6.0.0",
"@rollup/plugin-url": "^4.0.0",
"@svgr/rollup": "^4.2.0",
"@rollup/plugin-commonjs": "^22.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.3.0",
"@rollup/plugin-image": "^2.1.1",
"@types/chai": "3.5.2",
"@types/chai-enzyme": "^0.6.2",
"@types/chart.js": "^2.4.6",
Expand Down Expand Up @@ -222,7 +221,7 @@
"object-sizeof": "^1.2.0",
"oncokb-styles": "~1.3.0",
"oncokb-ts-api-client": "^1.3.1",
"oncoprintjs": "5.0.4",
"oncoprintjs": "^6.0.0-beta.0",
"pako": "2.0.2",
"parameter-validator": "^1.0.2",
"path-browserify": "^1.0.1",
Expand Down Expand Up @@ -295,11 +294,12 @@
"reselect": "^2.5.4",
"resolve-url-loader": "^1.6.1",
"responsive-fixed-data-table": "^2.0.0",
"rollup": "^1.32.1",
"rollup-plugin-auto-external": "^2.0.0",
"rollup-plugin-postcss": "^2.0.3",
"rollup-plugin-sourcemaps": "^0.4.2",
"rollup-plugin-typescript2": "^0.27.0",
"rollup": "^2.73.0",
"rollup-plugin-node-externals": "^4.0.0",
"rollup-plugin-postcss": "^2.9.0",
"rollup-plugin-sourcemaps": "^0.6.3",
"rollup-plugin-typescript2": "^0.31.2",
"rollup-plugin-web-worker-loader": "^1.6.1",
"route-parser": "0.0.5",
"sass": "^1.32.4",
"sass-loader": "10.1.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/cbioportal-frontend-commons/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"cbioportal-utils": "^0.3.20",
"classnames": "^2.2.5",
"jquery": "^3.2.1",
"lodash": "^4.17.11",
"lodash": "^4.17.15",
"measure-text": "0.0.4",
"mobxpromise": "github:cbioportal/mobxpromise#303db72588860bff0a6862a4f07a4e8a3578c94f",
"object-sizeof": "^1.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/cbioportal-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"dependencies": {
"buffer": "^6.0.3",
"genome-nexus-ts-api-client": "^1.1.22",
"lodash": "^4.17.11",
"lodash": "^4.17.15",
"oncokb-ts-api-client": "^1.3.1",
"superagent": "^3.8.3",
"typescript": "4.0.3"
Expand Down
1 change: 1 addition & 0 deletions packages/config/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const config: InitialOptionsTsJest = {
'\\.(css|sass|less|scss)$': 'identity-obj-proxy',
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
'<rootDir>/../config/fileMock.js',
'web-worker:*': 'identity-obj-proxy',
},
globals: {
'ts-jest': {
Expand Down
15 changes: 8 additions & 7 deletions packages/config/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
import typescript from 'rollup-plugin-typescript2';
import commonjs from '@rollup/plugin-commonjs';
// import external from 'rollup-plugin-peer-deps-external';
import autoExternal from 'rollup-plugin-auto-external';
import externals from 'rollup-plugin-node-externals';
import json from '@rollup/plugin-json';
import postcss from 'rollup-plugin-postcss';
import resolve from '@rollup/plugin-node-resolve';
import sourcemaps from 'rollup-plugin-sourcemaps';
import url from '@rollup/plugin-url';
import image from '@rollup/plugin-image';
import postcssUrl from 'postcss-url';
import svgr from '@svgr/rollup';
import workerLoader from 'rollup-plugin-web-worker-loader';

// common rollup config options for all libraries under packages
export default function getRollupOptions(
input,
mainOutput,
moduleOutput,
styles
styles,
nodeExternalsOptions
) {
return {
input: input,
Expand All @@ -34,7 +35,7 @@ export default function getRollupOptions(
},
],
plugins: [
autoExternal(),
externals(nodeExternalsOptions),
postcss({
autoModules: true,
extract: styles,
Expand All @@ -44,12 +45,12 @@ export default function getRollupOptions(
}),
],
}),
url(),
svgr(),
image(),
typescript({
clean: true,
}),
json(),
workerLoader(),
commonjs(),
resolve(),
sourcemaps(),
Expand Down
165 changes: 165 additions & 0 deletions packages/oncoprintjs/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007

Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.


This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.

0. Additional Definitions.

As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.

"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.

An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.

A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".

The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.

The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.

1. Exception to Section 3 of the GNU GPL.

You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.

2. Conveying Modified Versions.

If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:

a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or

b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.

3. Object Code Incorporating Material from Library Header Files.

The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:

a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.

b) Accompany the object code with a copy of the GNU GPL and this license
document.

4. Combined Works.

You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:

a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.

b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.

c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.

d) Do one of the following:

0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.

1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.

e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)

5. Combined Libraries.

You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:

a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.

b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.

6. Revised Versions of the GNU Lesser General Public License.

The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.

Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.

If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
73 changes: 73 additions & 0 deletions packages/oncoprintjs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
[![Build Status](https://travis-ci.org/cBioPortal/oncoprintjs.svg?branch=master)](https://travis-ci.org/cBioPortal/oncoprintjs)
# OncoprintJS
This is the library that generates the Oncoprint visualization in cBioPortal. Essentially, it populates a canvas of a grid of `m` tracks of `n` types, where each element can either be a discrete value represented by a colored glyph on a grey background or a continuous value within a color range. Oncoprint can have many conceivable uses, but in cBioPortal, it is primarily used to visualize tracks of `m` genes and `n` patient samples, where the colored glyphs represent genomic alterations. It is also used to display a heatmap of gene and/or protein expression values for those `m` genes and `n` patient samples.

## Using the Node Module
Oncoprint is on [NPM](https://www.npmjs.com/package/oncoprintjs). To install:

npm install --save oncoprintjs

In order to use it, just `require` it into your script.

const Oncoprint = require('oncoprintjs');

It can also be imported

import Oncoprint from "oncoprintjs";

A full documentation of the API is still pending, but the typescript declarations in `dist/js/oncoprint.d.ts` may be of use.

## Development
### Getting Started
First, clone the repo:

git clone https://github.com/cBioPortal/oncoprintjs.git

Install the necessary NPM packages defined in `package.json` by running:

npm install

Next, build

npm run build

Which will write `dist/oncoprint.bundle.js`, which is a CommonJS module and can be included using `require`, or `import`.

The directory `rules/` contains glyph styling specifications that are specific to the genomic alterations use case of Oncoprint, which you may want to use.

### Using a local version of oncoprintjs during development (e.g. in cBioPortal)

yalc (https://github.com/wclr/yalc) is extremely useful for this.

Whenever you have made a change to oncoprintjs you want to bring into another package:
(1) First navigate to the oncoprint directory. Then build:

npm run build

(2) Then "publish" the package locally using yalc

yalc publish

(3) Now go to the directory of your project (e.g. cbioportal-frontend), and add the local package

yalc add oncoprintjs

(4) Install packages again, using npm or yarn. Now, you will be using your local version of oncoprintjs.

(5) When you no longer want to be using the local version of oncoprintjs, simply run

yalc remove oncoprintjs

And run npm or yarn again.

### Changes to Oncoprint
If you make changes to the Oncoprint code base and want to load it into the examples, do not modify `oncoprint.bundle.js`, since all of your code will get overwritten when compiled using `npm run build`. Instead, modify the files in `src/` and then re-run `npm run build`.

### Schematic diagrams
oncoprintjs is written loosely with a Model-View-Controller framework, although some Views definitely have their own state.

![image](https://user-images.githubusercontent.com/636232/163244642-6ef2c80e-a0b5-43d6-ab95-24b8f8a4a2a3.png)

![image](https://user-images.githubusercontent.com/636232/163244709-cbe64929-e650-44cd-a579-2de3294dccc0.png)


2 changes: 2 additions & 0 deletions packages/oncoprintjs/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import config from '../config/jest.config';
export default config;
Loading

0 comments on commit 2d9f920

Please sign in to comment.