deep house cat

Another great podcast: deep house cat. Comes with a great mix of house music to relax and dance. For free!

The best thing about Itunes

I am an Ipod user since a few months now, but what me amazes more is Itunes. For people who don’t know about all this or hate everything where Apple is ivolved: Itunes is downloadable for free and can be used without Ipod. It is also available on Windows – so even if you are a Mac-hater, you can still take advantage of it ;-)!

Itunes is… a music library management software. You can convert all your CD’s and DVD’s to mp3 with it (called import) and you can buy and download music. From there you can always burn music on CD – so if you don’t have an Ipod, you can still use Itunes to buy music and play it on your old-style HIFI devices.

But Itunes is more than that, and the best thing it offers are podcasts. A podcast is – in the most simple style – a recorded audio show that is released periodically. You can subscribe to podcasts via the Itunes store for free! And there are a lot of podcasts in every genre you can imagine. I have subscribed to two podcasts so far: Dave’s lounge and Indifeed alternative. Both of them deliver music from independent artists, artists who are not bound to a contract with some music industry company. I mean the industry that pushes nobodies through idol shows on TV and makes money out of the hype that follows these bad shows. And the industry that introduces DRM and copyrights to protect intelectual property, which they buy from artists and resell to the majority of people who happily pay for it. Yes, the music industry that gives maybe 1,- USD per sold CD to the author while feeding the remainder to themselves for ages now…

But as we see with podcasts and Itunes (and other delivery channels like cdbaby or myspace), there are other ways for artists to gain popularity and for consumers to get great music. Music that is not pushed by a greedy industry and is as it is – sometimes really just great. Both, Dave’s lounge and indiefeed do a great job in making good artists popular, for free. And you can buy most of the titles in Itunes – with the important fact that most of the money will go to the authors themselves.

Detect spots on a 2D electrophoresis gel

It’s been a long time since I posted the last time. Meanwhile I am 30 now and used to the Mac OSx. Things normalize again ;-).

I work for The Mathworks almost four months now and naturally I am becoming a MATLAB specialist. Part of my work is the development of demo applications to demonstrate ML capabilities in computational biology and Life Sciences. Of course it is helpful for people in this area to see what they can do with MATLAB and moreover how easy this is. Not all of the demos but some of them are also suited for posting on something like a private Blog – and there is one in the pipeline now. Why not post it and let people know what cool things they can do with MATLAB ;-)? Watch out. The picture is from an online publication at this link: http://www.fao.org/docrep/008/y5970e/y5970e07.htm

Gel_Detect – detect and cluster spots on an 2D SDS gel

This demo shows how the image processing toolbox together with matrix operations and statistics toolbox can be used to process an SDS page gel. SDS -> sodium dodecyl sulfate polyacrylamid gel. SDS is an anionic detergent that denatures secondary structure of proteins. It is incubated with the protein sample so that the propagation of each protein just dependends on its molecular mass. In 2D electrophoresis, proteins are separated here in two dimensions, once by their isoelectric point and once by their mass/charge ratio.

The challenge in analysing the gel images is in the first instance to find out which spots are interesting resp. important and secondly to map spots to proteins. Sometimes this is just done with an overlay, to compare two samples or one sample with a known reference mix. This demo shows how we can determine the spots automatically and build clusters of them. The mapping has been left out – but could easily be done in addition.

Contents
Read the image, convert it to grayscale
gelGrayOrig = rgb2gray(imread('gel.tif'));
figure, imshow(gelGrayOrig), title('original image');
gel_detect_03.png
Let the user crop the image

Here the user can define the borders of the image. This is important for later measurements of the spot distances in pH gradient and SDS migration (size of the molecule)

gelGray = imcrop;
figure, imshow(gelGray), title('cropped image');
gel_detect_05.png
Create a spot mask

Pixels with an intensity value above a certain threshold can be set to zero. With this mechanism we can determine a mask that contains only the spots on the gel. First, copy the image, then zero out all values that are too “white”.

The sensitivity to spots depends heavily on the choosen threshold and also on the contrast of the image. It might be necessary to sharpen the picture and/or let the user choose the threshold manually and interactively. This can be achieved by wrapping the whole program in a GUI (easily possible with ML GUI building facilities), creating a slider for the threshold which has a callback that overlays the spot mask with the image for the actually chosen threshold.

gelMask = gelGray;
wTheta = 160;
gelMask(gelGray > wTheta) = 0;
gelIntens = gelMask;                % keep the intensities.
                                    % We want to refer to them later
gelMask(gelGray <= wTheta) = 255;
gelMask = im2bw(gelMask);           % convert to binary image
figure, imshow(gelMask), title('spot mask (gelMask)');
gel_detect_06.png
Label the spots in the image.

This is helpful for detection of different spots. Each connected area in the image (area of adjacent one’s) is labeled with a different number. The number of distinct labels equals the number of putative spots.

gelMaskLabel = bwlabel(gelMask);
figure, imshow(label2rgb(gelMaskLabel)), title('labeled gel mask (gelMaskLabel)');

gel_detect_07.png

Count the number of spots in the Gel
nSpots = max(max(gelMaskLabel));
disp(['Total number of spots: ' num2str(nSpots)]);
Total number of spots: 232
Get region properties: centroid, bounding box and area

The regionprops function returns several properties of labeled images, which can be defined as named arguments.

gelRegionProps = regionprops(gelMaskLabel, 'Area', 'BoundingBox', ...
    'Centroid', 'MajorAxisLength', 'MinorAxisLength');
Fetch centroids (mass centers) and bounding boxes of the spots

The bounding box contains the elements upper left corner of the spot (x y coordinates) and width (x y)

gelSpotCentroids = [gelRegionProps.Centroid];
gelSpotBBox = [gelRegionProps.BoundingBox];
Work with spot centroids, sizes and intensities

At this point we have a lot of spots with eventually different sizes, intensities and positions. The task is now to find the “interesting” spots – e.g. the ones that represent the protein we are looking for or the ones that show important facts about the sample. Eventually, this can be achieved with pattern recognition approaches. As important factors we would consider the bounding box (as a measure of spot size), the major/minor axis length (as a measure of spot extension), the area, the position and the intensity. Good factors would be ratios of area/bbox, area/(major,minor axis length).

Prepare spot data for clustering

Goal is a matrix that describes several spot properties. This can be used for some further analysis.

% compute bounding box diagonals
spotBBdiag = zeros(nSpots, 1);
j = 1;
for i = 3:4:length(gelSpotBBox)
    spotBBdiag(j) = sqrt(gelSpotBBox(i)^2 + gelSpotBBox(i+1)^2);
    j = j + 1;
end% get average intensities for each spot
spotAvgIntens = zeros(nSpots, 1);
for i = 1:nSpots
    spotAvgIntens(i) = mean(gelGray(find(gelMaskLabel == i)));
end
clear i j;

% create spot properties matrix. The rows are:
% Area Intensity MajorAxis MinorAxis BoundingBoxDiagonal
spotProperties = [[gelRegionProps.Area]' spotAvgIntens ...
    [gelRegionProps.MajorAxisLength]' ...
    [gelRegionProps.MinorAxisLength]' spotBBdiag];
spotPropNames = {'Area' 'Average Intensity' 'Major axis' 'Minor axis' 'Bounding box'};
Get and display spot clusters via kmeans

We initiate to 5 clusters. It could be more or less, and the best number of clusters is to be determined… With clustering we can find spots with a similar size and shape – as well as spots that are around a certain geometrical position, which determines the isoelectric point of the proteins they belong to and their size. Here we care about the size and shape.

[kIdx kCenter] = kmeans(spotProperties, 5);
gelClusters = gelMaskLabel;for i = 1:nSpots
    gelClusters(find(gelMaskLabel == i)) = kIdx(i);
end
figure, imshow(label2rgb(gelClusters, 'jet')), title('Spot Clusters in the gel');

gel_detect_08.png

Overlay spot clusters with original image

We use an indexed image of the original gray gel image to overlay with the clusters.

[gelGrayInd gelGrayMap] = gray2ind(gelGray,  128);
gelClustersOverlay = gelGrayInd;

% create 5 more colors in the original map
myExtMap = [1 0 0; 0 1 0; 0 0 1; 1 1 0; 1 0 1; 0 1 1];
theNewMap = [gelGrayMap; myExtMap];
for i = 1:nSpots
    gelClustersOverlay(find(gelMaskLabel == i)) = 128 + kIdx(i);
end
figure, imshow(gelClustersOverlay, theNewMap), title('Spot Clusters overlay');

gel_detect_09.png