Skip to content

Instantly share code, notes, and snippets.

@nachocab
nachocab / _.md
Created May 19, 2013 12:49
saveable graph layout

An interactive longitudinal heatmap

@nachocab
nachocab / README.md
Last active December 15, 2015 21:39
Worry about correctness and repeatability, not p-values.

clickme D3 straight from R

An interactive longitudinal heatmap next to a parallel coordinates plot, one of the pre-installed clickme examples

@nachocab
nachocab / d3.min.js
Last active December 15, 2015 01:18
example force directed viz
(function(){function t(t){return t.target}function n(t){return t.source}function e(t,n){try{for(var e in n)Object.defineProperty(t.prototype,e,{value:n[e],enumerable:!1})}catch(r){t.prototype=n}}function r(t){for(var n=-1,e=t.length,r=[];e>++n;)r.push(t[n]);return r}function i(t){return Array.prototype.slice.call(t)}function u(){}function a(t){return t}function o(){return!0}function c(t){return"function"==typeof t?t:function(){return t}}function l(t,n,e){return function(){var r=e.apply(n,arguments);return arguments.length?t:r}}function s(t){return null!=t&&!isNaN(t)}function f(t){return t.length}function h(t){return t.trim().replace(/\s+/g," ")}function d(t){for(var n=1;t*n%1;)n*=10;return n}function g(t){return 1===t.length?function(n,e){t(null==n?e:null)}:t}function p(t){return t.responseText}function m(t){return JSON.parse(t.responseText)}function v(t){var n=document.createRange();return n.selectNode(document.body),n.createContextualFragment(t.responseText)}function y(t){return t.responseXML}function M(){}
(function(){function t(t){return t.target}function n(t){return t.source}function e(t,n){try{for(var e in n)Object.defineProperty(t.prototype,e,{value:n[e],enumerable:!1})}catch(r){t.prototype=n}}function r(t){for(var n=-1,e=t.length,r=[];e>++n;)r.push(t[n]);return r}function i(t){return Array.prototype.slice.call(t)}function u(){}function a(t){return t}function o(){return!0}function c(t){return"function"==typeof t?t:function(){return t}}function l(t,n,e){return function(){var r=e.apply(n,arguments);return arguments.length?t:r}}function s(t){return null!=t&&!isNaN(t)}function f(t){return t.length}function h(t){return t.trim().replace(/\s+/g," ")}function d(t){for(var n=1;t*n%1;)n*=10;return n}function g(t){return 1===t.length?function(n,e){t(null==n?e:null)}:t}function p(t){return t.responseText}function m(t){return JSON.parse(t.responseText)}function v(t){var n=document.createRange();return n.selectNode(document.body),n.createContextualFragment(t.responseText)}function y(t){return t.responseXML}function M(){}
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Force directed</title>
<script src="ractives/force_directed/external/d3.min.js"></script>
<link href="ractives/force_directed/external/main.css" rel="stylesheet">
</head>
<body>
@nachocab
nachocab / avoid_pdf_tables
Created January 27, 2013 14:52
A request to use text files instead of pdfs to share supplementary material.
Dear Doctor ____,
I wanted to thank you for your published paper on _____. It provides a significant contribution to the field of ______, and I hope you will continue publishing similar work in the future. I have been trying to build on your work, integrating your results with my own research. Unfortunately, this has proved challenging because the supplementary tables were published in a .pdf format, which requires manual copying and pasting, it doesn't preserve the original format, and is prone to character encoding errors.
In future publications, you could easily avoid these issues by making the supplementary tables available in files of comma-separated values (.csv), or plain-text format. Figshare is a popular online resource used by many authors to publish this type of data in a way that is easily citeable. You can read more about it here: http://figshare.com/features. Feel free to share it with your colleagues.
Thank you for making scientific research more accessible.
Best,
____
@nachocab
nachocab / gene_list.r
Last active October 8, 2015 17:26
Using yaml to deal with gene sets in R
install.packages("yaml")
# change path to your favorite local directory
gene_list <- function(filename, format = "yaml", path = "/Users/nacho/gene_info/gene_sets"){
path <- file.path(path, filename)
if (format == "yaml"){
raw_genes <- yaml::yaml.load_file(path)
# TODO: run through the nested names in genes and check that
# there are no "." or ":", give warning or replace with "_"
unlisted_genes <- unlist(raw_genes)
<!DOCTYPE html>
<html>
<head>
<script src='http://mbostock.github.com/d3/d3.js'></script>
</head>
<body>
<script type="text/javascript">
var textElems = ["text1","text2"]
var x = d3.scale.ordinal().domain(d3.range(textElems.length)).rangeBands([0, 120]);