Commit 077b777e authored by Ariane Mora's avatar Ariane Mora

Have added the chromosones and filtering by gene and chroms.

parent 5f102e8b
......@@ -4,12 +4,12 @@
* top sorts descending (text or num) on the field
* returns the top x amount. Can sort in terms of top infinity --> to get a sorted list.
* bottom sorts ascending (but same same).
*
*
* to remove dimesnion = dispose
* Can have max 32 (> 8 dimensions cause it to be very slow).
* Can make an array to have several elements in a dimensions (i.e. start and end).
* .all() on the grouped data exposes the data to be able to use it in Javascrippt
*
*
* filterRangd([>=min, <max]); Can also do on strings
* there is also a filter for a function.
*/
......@@ -19,7 +19,7 @@
* Helps with debugging. Native cross filter objects can't be viewed properly in
* console.log.
*/
function print_filter(filter) {
function get_filter(filter) {
var f = eval(filter);
if (typeof (f.length) != "undefined") {
} else {
......@@ -34,7 +34,8 @@ function print_filter(filter) {
}).top(Infinity);
} else {
}
console.log(filter + "(" + f.length + ") = " + JSON.stringify(f).replace("[", "[\n\t").replace(/}\,/g, "},\n\t").replace("]", "\n]"));
return f;
//console.log(filter + "(" + f.length + ") = " + JSON.stringify(f).replace("[", "[\n\t").replace(/}\,/g, "},\n\t").replace("]", "\n]"));
}
/**
......@@ -43,25 +44,27 @@ function print_filter(filter) {
* ----------------------------------------------------------------------------
*/
var processed_data = {};
var processed_data = {
curr_chrom: 'chr1', // keep track of the current chromosone.
};
var set_up_genome_data = function (data) {
// Set up the crossfilter facts. --> use a JSON object i.e. data
// that contains elements (array) these get translated to facts.
// Data contains the following:
// 1.chrom 2.start 3.end 4.gene or network
// 1.chrom 2.start 3.end 4.gene or network
var genome_facts = crossfilter(data);
// Store globally
processed_data["genome_facts"] = genome_facts;
processed_data["fact_size"] = genome_facts.size();
}
var add_network_data = function(network_data) {
// Add the network data to the genome data
processed_data.genome_facts.add(network_data);
}
/**
......@@ -74,7 +77,7 @@ var create_type_dimension = function () {
var type_dimension = processed_data.genome_facts.dimension(function (d) {
return d.type;
});
// Store globally
processed_data["type_dimension"] = type_dimension;
......@@ -82,24 +85,24 @@ var create_type_dimension = function () {
var create_start_dimension = function () {
// Dimensions are stateful.
// Dimensions are stateful.
// Create a dimesnsion on the start of either the gene or network
var start_dimension = processed_data.genome_facts.dimension(function (d) {
return d.start;
});
// Store globally
processed_data["start_dimension"] = start_dimension;
}
var create_end_dimension = function () {
// Dimensions are stateful.
// Dimensions are stateful.
// Create a dimesnsion on the end of either the gene or network
var end_dimension = processed_data.genome_facts.dimension(function (d) {
return d.end;
});
// Store Globally
processed_data["end_dimension"] = end_dimension;
......@@ -110,12 +113,23 @@ var create_chrom_dimension = function () {
var chrom_dimension = processed_data.genome_facts.dimension(function (d) {
return d.chrom;
});
// Store Globally
processed_data["chrom_dimension"] = chrom_dimension;
processed_data["chrom_dimension"] = chrom_dimension;
}
/**
* ----------------------------------------------------------------------------
* Create groups
* ----------------------------------------------------------------------------
*/
var create_chrom_group = function() {
// Want to get all the chromosones as a group
processed_data["chrom_group"] = processed_data.chrom_dimension.group(function(d) {return d.split('_');}).all();
};
/**
* ----------------------------------------------------------------------------
......@@ -134,7 +148,7 @@ var filter_on_position = function(start, end) {
// Clear the associated filters.
processed_data.start_dimension.filterAll();
processed_data.end_dimension.filterAll();
// Filters the data based on the start and end positions
// filterRange([>=min, <max]); Can also do on strings
processed_data.start_dimension.filterRange([start, end]);
......@@ -146,30 +160,34 @@ var filter_on_position = function(start, end) {
var filter_on_chrom = function(chrom) {
// Clear associated filter
processed_data.chrom_dimension.filterAll();
// Use an exact filter as we only want that specific chromosone.
processed_data.chrom_dimension.filterExact(chrom);
// Now the underlying data has changed (will need to redraw)
return get_filter(processed_data.genome_facts);
}
var filter_on_networks = function() {
// Clear associated filter
processed_data.type_dimension.filterAll();
// Allows us to only look at networks (the genes will have the gene ID in
// that collumn).
processed_data.type_dimension.filterExact("network");
// Now the underlying data has changed (will need to redraw)
// Now the underlying data has changed (will need to redraw)
return get_filter(processed_data.genome_facts);
}
var filter_on_gene = function(gene) {
// Clear associated filter.
processed_data.type_dimension.filterAll();
// Here we filter using the type dimension as that will either have "network"
// or the gene ID.
processed_data.type_dimension.exactFilter(gene);
// Now the underlying data has changed (will need to redraw)
processed_data.type_dimension.filterExact(gene);
// Now the underlying data has changed (will need to redraw)
return get_filter(processed_data.genome_facts);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment