Kevin Mader
7 May 2015
There are three different types of problems that we will run into.
Full adult animal at cellular resolution 1000s of samples of full adult animals, imaged at 0.74 \mu m resolution: Images 11500 x 2800 x 628 \longrightarrow 20-40GVx / sample
Whole brain with cellular resolution 1 cm^3 scanned at 1 \mu m resolution: Images \longrightarrow 1000 GVx / sample
Normally when problems are approached they are solved for a single task as quickly as possible
im_in=imread('test.jpg');
im_filter=medfilt2(im_in,[5,5]);
cl_img=bwlabel(im_filter>10);
cl_count=hist(cl_img,1:100);
dlmwrite(cl_count,'out.txt')
You have to rewrite everything, everytime
If you start with a bad approach, it is very difficult to fix, big data and reproducibility must be considered from the beginning
Parallelism is when you can divide a task into separate pieces which can then be worked on at the same time.
Some tasks are easy to parallelize while others are very difficult. Rather than focusing on programming, real-life examples are good indicators of difficultly.
Distributed computing is very similar to parallel computing, but a bit more particular. Parallel means you process many tasks at the same time, while distributed means you are no longer on the same CPU, process, or even on the same machine.
The distributed has some important implications since once you are no longer on the same machine the number of variables like network delay, file system issues, and other users becomes a major problem.
The largest issue with parallel / distributed tasks is the need to access the same resources at the same time
Parallel computing requires a significant of coordinating between computers for non-easily parallelizable tasks.
The second major issue is mutability, if you have two cores / computers trying to write the same information at the same it is no longer deterministic (not good)
The simple act of taking turns and waiting for every independent process to take its turn can completely negate the benefits of parallel computing
Inherits all of the problems of parallel programming with a whole variety of new issues.
If you have 1000 computers working on solving a problem and one fails, you do not want your whole job to crash
How can you access and process data from many different computers quickly without very expensive infrastructure
Directly coordinating tasks on a computer.
They look fairly similar, so what is the difference? The second is needlessly complicated for one person, but what if you have a team, how can several people make an imparitive soup faster (chopping vegetables together?)
How can many people make a declarative soup faster? Give everyone a different task (not completely efficient since some tasks have to wait on others)
One of the major challenges of scaling up experiments and analysis is keeping all of the results organized in a clear manner. As we have seen in the last lectures, many of the results produced many text files
Queue processing systems (like Sun Grid Engine, Oracle Grid Engine, Apple XGrid, Condor, etc) are used to manage
The node with which every other node communicates, the main address.
The nodes where the computation is performed.
The actual process that decides which jobs will run using which resources (worker nodes, memory, bandwidth) at which time
A database is a collection of data stored in the format of tables: a number of columns and rows.
Here we have an table of the animals measured in an experiment and their weight
id | Weight |
---|---|
1 | 100 |
2 | 40 |
3 | 80 |
The cells is then an analysis looking at the cellular structures
Animal | Type | Anisotropy | Volume |
---|---|---|---|
1 | Cancer | 0.5 | 1.00 |
1 | Healthy | 1.0 | 2.00 |
2 | Cancer | 0.5 | 0.95 |
Relational-databases can store relationships between different tables so the relationship between Animal in table Cells and id in table Animals can be preserved.
SQL (pronounced Sequel) stands for structured query language and is nearly universal for both searching (called querying) and adding (called inserting) data into databases. SQL is used in various forms from Firefox storing its preferences locally (using SQLite) to Facebook storing some of its user information (MySQL and Hive). So refering to the two tables we defined in the last entry, we can use SQL to get information about the tables independently of how they are stored (a single machine, a supercomputer, or in the cloud)
SELECT Volume FROM Cells
\rightarrow \begin{bmatrix} 1,2,0.95\end{bmatrix}
SELECT AVG(Volume) FROM Cells WHERE Type = "Cancer"
\rightarrow 0.975
We could have done these easily without SQL using Excel, Matlab or R
Get the volume of all cells in heavy mice
SELECT Volume FROM Cells WHERE Animal IN
(SELECT id FROM Animal WHERE Weight>80)
Get weight and average cell volume for all mice
SELECT ATable.Weight,CTable.Volume FROM Animals as ATable
INNER JOIN Cells as CTable on (ATable.id=CTable.Animal)
\rightarrow \begin{bmatrix} 1,0.95\end{bmatrix}
If we expand our SQL example to cellular networks with an additional table explicitly describing the links between cells
id1 | id2 | No.Juncs |
---|---|---|
1 | 2 | 800 |
1 | 3 | 40 |
3 | 1 | 300 |
Now to calculate how many connections each cell has
SELECT id,COUNT(*) AS connection_count FROM Cells
INNER JOIN Network ON (id=id1 OR id=id2)
\rightarrow \begin{bmatrix} (1 & 3) \\ (2 & 1) \\ (3 & 2)\end{bmatrix}
Basic networks can be entered and queries using SQL but relatively simple sounding requests can get complicated very quickly
How many cells are within two connections of each cell
SELECT id,COUNT(*) AS connection_count FROM Cells as CellsA
INNER JOIN Network as NetA ON Where (id=NetA.id1)
INNER JOIN Network as NetB ON Where (NetA.id2=NetB.id1)
This is still readable but becomes very cumbersome quickly and difficult to manage
A new generation of database software which extends the functionality of SQL to allow for more scalability (MongoDB) or specificity for problems like networks or graphs called generally Graph Databases
When a ton of heterogeneous is coming in fast.
Performant, scalable, and flexible
10X, 100X, 1000X is the same amount of effort
Director of AMPLab said their rate limiting factor is always enough interesting data
Google ran into 'big data' and its associated problems years ago: Peta- and exabytes of websites to collect and make sense of. Google uses an algorithm called PageRank™ for evaluating the quality of websites. They could have probably used existing tools if page rank were some magic program that could read and determine the quality of a site
for every_site_on_internet
current_site.rank=secret_pagerank_function(current_site)
end
Just divide all the websites into a bunch of groups and have each computer run a group, easy!
While the actual internals of PageRank are not public, the general idea is that sites are ranked based on how many sites link to them
for current_site in every_site_on_internet
current_pagerank = new SecretPageRankObj(current_site);
for other_site in every_site_on_internet
if current_site is_linked_to other_site
current_pagerank.add_site(other_site);
end
end
current_site.rank=current_pagerank.rank();
end
How do you divide this task?
some people claim to have had the idea before, Google is certainly the first to do it at scale
Several engineers at Google recognized common elements in many of the tasks being performed. They then proceeded to divide all tasks into two classes Map and Reduce
Map is where a function is applied to every element in the list and the function depends only on exactly that element \vec{L} = \begin{bmatrix} 1,2,3,4,5 \end{bmatrix} f(x) = x^2 map(f \rightarrow \vec{L}) = \begin{bmatrix} 1,4,9,16,25 \end{bmatrix}
Reduce is more complicated and involves aggregating a number of different elements and summarizing them. For example the \Sigma function can be written as a reduce function \vec{L} = \begin{bmatrix} 1,2,3,4,5 \end{bmatrix} g(a,b) = a+b Reduce then applies the function to the first two elements, and then to the result of the first two with the third and so on until all the elements are done reduce(f \rightarrow \vec{L}) = g(g(g(g(1,2),3),4),5)
They designed a framework for handling distributing and running these types of jobs on clusters. So for each job a dataset ( \vec{L} ), Map-task ( f ), a grouping, and Reduce-task ( g ) are specified
All of the steps in between can be written once in a robust, safe manner and then used for every task which can be described using this MapReduce paradigm. These tasks \langle \vec{L}, f(x), g(a,b) \rangle is refered to as a job.
The initial job was very basic, for more complicated jobs, a new notion of Key-value (KV) pairs must be introduced. A KV pair is made up of a key and value. A key must be comparable / hashable (a number, string, immutable list of numbers, etc) and is used for grouping data. The value is the associated information to this key.
Using MapReduce on a folder full of text-documents.
f(x) = [(word,1) for word in x.split(" ")]
L = ["cat dog car",
"dog car dog"]
\downarrow \textbf{ Map } : f(x)
[("cat",1),("dog",1),("car",1),("dog",1),("car",1),("dog",1)]
\downarrow \textrm{ Shuffle / Group}
"cat": (1)
"dog": (1,1,1)
"car": (1,1)
\downarrow \textbf{ Reduce } : g(a,b)
[("cat",1),("dog",3),("car",2)]
Hadoop is the opensource version of MapReduce developed by Yahoo and released as an Apache project. It provides underlying infrastructure and filesystem that handles storing and distributing data so each machine stores some of the data locally and processing jobs run where the data is stored.
Zaharia, M., et. al (2012). Resilient distributed datasets: a fault-tolerant abstraction for in-memory cluster computing
If we do that, we miss a lot!
Phenotype | Within | Between | Ratio (%) |
---|---|---|---|
Length | 36.97286 | 4.278853 | 864.08349 |
Width | 27.92322 | 4.733648 | 589.88801 |
Height | 25.15456 | 4.636371 | 542.54855 |
Volume | 67.85303 | 12.478975 | 543.73881 |
Nearest Canal Distance | 70.35092 | 333.395326 | 21.10135 |
Density (Lc.Te.V) | 144.40110 | 27.657829 | 522.09844 |
Nearest Neighbors (Lc.DN) | 31.86131 | 1.835211 | 1736.11101 |
Stretch (Lc.St) | 13.98019 | 2.359673 | 592.46289 |
Oblateness (Lc.Ob) | 141.26874 | 18.464618 | 765.07808 |
The results in the table show the within and between sample variation for selected phenotypes in the first two columns and the ratio of the within and between sample numbers
How does this result look visually? Each line shows the mean \pm standard deviation for sample. The range within a single sample is clearly much larger than between
With the ability to scale to millions of samples there is no need to condense. We can analyze the entire dataset in real-time and try and identify groups or trends within the whole data instead of just precalculated views of it.
1276 comma separated text files with 56 columns of data and 15-60K rows
Task | Single Core Time | Spark Time (40 cores) |
---|---|---|
Load and Preprocess | 360 minutes | 10 minutes |
Single Column Average | 4.6s | 400ms |
1 K-means Iteration | 2 minutes | 1s |
We found several composite phenotypes which are more consistent within samples than between samples
Tools built for table-like data data structures and much better adapted to it.
Dozens of major companies (Apple, Google, Facebook, Cisco, …) donate over $30M a year to development of Spark and the Berkeley Data Analytics Stack
Can handle static data or live data coming in from a 'streaming' device like a camera to do real-time analysis. The exact same code can be used for real-time analysis and static code
Projects at AMPLab like Spark and BlinkDB are moving towards approximate results.
mean(volume)
mean(volume).within_time(5)
mean(volume).within_ci(0.95)
For real-time image processing it might be the only feasible solution and could drastically reduce the amount of time spent on analysis.