├── .gitignore
├── .npmignore
├── .DS_Store
├── index.js
├── src
├── .DS_Store
└── d3-electrophoresis.js
├── test
├── .DS_Store
└── d3-electrophoresis_test.js
├── assets
├── result_scale_200-400_1.png
├── result_text_name1_small1.png
├── electrophoresis_trump-speech_cleanbench1_small1.jpg
└── electrophoresis_trump-speech_cleanbench1_up1_smal1.jpg
├── package.json
├── LICENSE
├── examples
├── d3-electrophoresis_simple1.html
├── d3-electrophoresis_switch_DNA_sequence1.html
└── d3-electrophoresis_switch_trump-inauguration1.html
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | assets
--------------------------------------------------------------------------------
/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/squarednob/d3-electrophoresis/HEAD/.DS_Store
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | export {default as electrophoresis} from "./src/d3-electrophoresis";
2 |
--------------------------------------------------------------------------------
/src/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/squarednob/d3-electrophoresis/HEAD/src/.DS_Store
--------------------------------------------------------------------------------
/test/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/squarednob/d3-electrophoresis/HEAD/test/.DS_Store
--------------------------------------------------------------------------------
/assets/result_scale_200-400_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/squarednob/d3-electrophoresis/HEAD/assets/result_scale_200-400_1.png
--------------------------------------------------------------------------------
/assets/result_text_name1_small1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/squarednob/d3-electrophoresis/HEAD/assets/result_text_name1_small1.png
--------------------------------------------------------------------------------
/assets/electrophoresis_trump-speech_cleanbench1_small1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/squarednob/d3-electrophoresis/HEAD/assets/electrophoresis_trump-speech_cleanbench1_small1.jpg
--------------------------------------------------------------------------------
/assets/electrophoresis_trump-speech_cleanbench1_up1_smal1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/squarednob/d3-electrophoresis/HEAD/assets/electrophoresis_trump-speech_cleanbench1_up1_smal1.jpg
--------------------------------------------------------------------------------
/test/d3-electrophoresis_test.js:
--------------------------------------------------------------------------------
1 | // install tape with "npm instll tape".
2 | // From top folder, "node test/d3-electrophoresis_test.js".
3 | var test = require("../node_modules/tape");
4 | var elect = require("../src/d3-electrophoresis.js");
5 |
6 | test("test_test1", function(t){
7 | t.equal(1+1, 2);
8 | t.end();
9 | })
10 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "d3-electrophoresis",
3 | "version": "1.0.3",
4 | "description": "D3.js plugin to simulate electrophoresis by cutting text.",
5 | "main": "index.js",
6 | "directories": {
7 | "test": "test"
8 | },
9 | "dependencies": {},
10 | "devDependencies": {
11 | "tape": "^4.6.3"
12 | },
13 | "scripts": {
14 | "test": "node test/d3-electrophoresis_test.js"
15 | },
16 | "repository": {
17 | "type": "git",
18 | "url": "git+https://github.com/squarednob/d3-electrophoresis.git"
19 | },
20 | "keywords": [
21 | "d3",
22 | "d3-module",
23 | "svg",
24 | "visualization",
25 | "data",
26 | "biology",
27 | "NLP"
28 | ],
29 | "author": "Nobuyuki Hirakata",
30 | "url": "http://gappyfacets.com/",
31 | "license": "MIT",
32 | "bugs": {
33 | "url": "https://github.com/squarednob/d3-electrophoresis/issues"
34 | },
35 | "homepage": "https://github.com/squarednob/d3-electrophoresis#readme"
36 | }
37 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 squarednob
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/examples/d3-electrophoresis_simple1.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # d3-electrophoresis
2 | A D3.js plugin to simulate electrophoresis which is a basic biotechnological technique to visualize length of DNA segments cut by restriction enzyme.
3 | Using this plugin, you can cut not only DNA sequence, but also any text, by words.
4 |
5 | ### Examples
6 | #### Cutting text by words
7 | 
8 |
9 | You can change text and words in the showcases.
10 | * Simple example: [Showcase and code](https://bl.ocks.org/squarednob/bd2a39f09d177c99b982ca406ca9cf1d).
11 | * Changinge scale: [showcase and code](https://bl.ocks.org/squarednob/fc711a3e6a25800efbf03067b0231825).
12 | * Trump inauguration text: [Showcase](https://bl.ocks.org/squarednob/raw/846808f07995e537dc7af2e9bcffdf3b/), [Code](https://bl.ocks.org/squarednob/846808f07995e537dc7af2e9bcffdf3b).
13 | * DNA sequence: [Showcas](https://bl.ocks.org/squarednob/raw/959bac1f4eca03059e02dbd480982c60/), [Code](https://bl.ocks.org/squarednob/959bac1f4eca03059e02dbd480982c60).
14 |
15 |
16 |
17 | ##### Using SVG for CGI
18 | By [SVG Crowbar](http://nytimes.github.io/svg-crowbar/), you can download the resulted DNA bands as SVG. And the SVG can be used for, such as 3D object in Blender. The CGI image below was made with Blender, including SVG bands in the gel.
19 |
20 | The detail and other images are on the blog: [New D3.js plugin: D3-electrophoresis released](http://gappyfacets.com/2017/02/18/new-d3-js-plugin-d3-electrophoresis-released/).
21 | 
22 |
23 | ### Install
24 | 1. Download [d3-electrophoresis.js](https://raw.githubusercontent.com/squarednob/d3-electrophoresis/master/src/d3-electrophoresis.js) from right click, or use npm `npm install d3-electrophoresis` and get it in "src" folder.
25 | 2. In HTML, load D3.js (__v.4__) and d3-electrophoresis.js with `
29 |
30 | ```
31 |
32 | ### Basic Usage
33 | ```js
34 | var gel = electrophoresis();
35 |
36 | var svg = d3.select("body").append("svg")
37 | .attr("width", 460)
38 | .attr("height", 500)
39 | .call(gel.makeGel); // Make black background first.
40 |
41 | var text = "AGCGCCCAATACGCAAACCGCCTCTCCCCGCGCGTTGGCCGATTCACGTTTACGAGTTGGAAACGA";
42 | var words = [[1,5,10,15,20,30,40,50,70,100],"CAAA","GTTGG","GGATCC", "GA",["GT","CCT"],"ACC", "GAAA"];
43 | var names = ["marker", "1", "2", "3", "4", "5", "6", "7"];
44 | // You can set every parameter by dictionary or method-chain. Example: {DNA: text} or .DNA(text).
45 | gel = electrophoresis().DNA(text).enzymes(words).names(names);
46 | svg.call(gel);
47 | ```
48 |
49 | ### Parameters
50 | You can set every parameter by dictionary input:
51 | ```js
52 | var gel = electrophoresis({DNA:"agtctatcacg", enzymes:["ac","gca"]});
53 | ```
54 | __and/or__ by method-chain:
55 | ```js
56 | var gel = electrophoresis().DNA("agtctatcacg").enzymes(["ac","gca"]);
57 | ```
58 |
59 | ### Tips
60 | #### Changing scale
61 | 
62 |
63 | To change vertical scale of band, like changing gel concentration, use `.scale()` chain, and input d3's scale object.
64 |
65 | For example, to make band within y=200 to 400 in linear scale, add scale() chain after electrophoresis().~, and input d3-scale object:
66 | ```js
67 | var yScale = d3.scaleLinear().range([200,400]);
68 | gel = electrophoresis({DNA: text}).enzymes(words).names(names).scale(yScale);
69 | ```
70 | [Demo](https://bl.ocks.org/squarednob/fc711a3e6a25800efbf03067b0231825).
71 |
72 | ### API Reference
73 | # electrophoresis.__DNA__([_text_])
74 |
75 | Target text to be cut.
76 |
77 | Default: _"AGCGCCCAATACGCAAACCGCCTCTCCCCGCGCGTTGGCCGATTCACGTTTACGAGTTGGAAACGA"_.
78 |
79 | # electrophoresis.__enzymes__([_list_])
80 |
81 | Word list to cut target text.
82 |
83 | When the word list includes a number list as a element, (e.g. _["AC",[10,15,20]]_), the numbers are directly used as resulted length of cut segmented text without cutting text. When the word list includes a word list as a element, (e.g. _["AC",["GT","CCT"]]_), target text is cut by both of the two words all together.
84 |
85 | Default: _[[1,5,10,15,20,30,40,50,70,100],"CAAA","GTTGG","GGATCC", "GA",["GT","CCT"],"ACC", "GAAA"]_.
86 |
87 | # electrophoresis.__names__([_list_])
88 |
89 | Name list of enzymes. They appear as tooltips on each resulted lane.
90 |
91 | Default: _["marker", "1", "2", "3", "4", "5", "6", "7"]_.
92 |
93 | # electrophoresis.__scale__([_obj_])
94 |
95 | A scale to map length values of segmented texts from top to the bottom. The input must be a scale object in D3-v.4 syntax, such as `d3.scaleSqrt()`, `d3.scaleLinear()`, `d3.scalePow()` .etc. See how to use [d3/d3-scale](https://github.com/d3/d3-scale).
96 |
97 | To make band within height of 200-500 in linear scale, for example, use `d3.scaleLinear().range([200, 500]))`.
98 |
99 | Default: _`d3.scaleLinear()`_.
100 |
101 | # electrophoresis.__lane_number__([_int_])
102 |
103 | Max number of lanes.
104 |
105 | Default: _8_.
106 |
107 | # electrophoresis.__gel_margin__([_dict_])
108 |
109 | Margin size from edges of background.
110 |
111 | Default: _{top: 40, right: 20, bottom: 30, left: 20}_.
112 |
113 | # electrophoresis.__duration__([_float_])
114 |
115 | Time to finish animation.
116 |
117 | Default: _6000_.
118 |
119 | # electrophoresis.__band_width__([_float_])
120 |
121 | Width of bands.
122 |
123 | Default: _38_.
124 |
125 | # electrophoresis.__band_blur__([_float_])
126 |
127 | Blur of bands.
128 |
129 | Default: _2_.
130 |
131 | # electrophoresis.__band_thick_min__([_float_])
132 |
133 | Minimum thickness of bands.
134 |
135 | Default: _1_.
136 |
137 | # electrophoresis.__band_thick_rate__([_float_])
138 |
139 | How bands turns less thick as the bands go down.
140 |
141 | Default: _0.04_
142 |
143 | # electrophoresis.__tooltip_name_on__([_str_])
144 |
145 | "on" or "off" for tooltips of enzyme name on upper side.
146 |
147 | Default: _"on"_.
148 |
149 | # electrophoresis.__tooltip_name_size__([_float_])
150 |
151 | Size of name tooltips.
152 |
153 | Default: _17_.
154 |
155 | # electrophoresis.__tooltip_name_offsetX__([_float_])
156 |
157 | Horizontal offset of name tooltips.
158 |
159 | Default: _0_.
160 |
161 | # electrophoresis.__tooltip_name_offsetY__([_float_])
162 |
163 | Vertical Offset of name tooltips.
164 |
165 | Default: _20_.
166 |
167 | # electrophoresis.__tooltip_band_on__([_str_])
168 |
169 | "on" or "off" for tooltips of band length.
170 |
171 | Default: _"on"_;
172 |
173 | # electrophoresis.__tooltip_band_size__([_float_])
174 |
175 | size of band tooltips.
176 |
177 | Default: _13_.
178 |
179 | # electrophoresis.__tooltip_band_offsetX__([_float_])
180 |
181 | Horizontal offset of band tooltips.
182 |
183 | Default: _0_.
184 |
185 | # electrophoresis.__tooltip_band_offsetY__([_float_])
186 |
187 | Vertical offset of band tooltips.
188 |
189 | Default: _0_.
190 |
--------------------------------------------------------------------------------
/examples/d3-electrophoresis_switch_DNA_sequence1.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | D3 Electrophoresis Generator
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |