Rice University logo
 
Top blue bar image
Computer Scientist at the Department of BioSciences, Rice University
 

Simplest biology heatmap in php

April 23rd, 2014 by Boanerges Aleman-Meza

Biology heatmaps are useful to summarize results, such as in this example:

Need: create a heatmap from values in a database table. The table has three fields, one for names of rows, another for names of columns, and value.
Solution:

  • Make a table in HTML
  • Set the background color of each cell depending upon the value of each database record.
  • The color coding preferred by my boss is from blue to black and then to yellow:
  • Find out what the minimum and maximum value are supposed to be. In my case it was 0.9 and 1.1
  • Make a list of colors such as colors.php (if you use this file, rename it from .php.txt to .php, I appended .txt for easy display/view on browser).
  • Use a formula that will get you a given color depending upon an input value.
    • My formula requires to know the ‘start’ value, in this case 0.9; it also needs to know ‘half’ of the heatmap, in this case 0.1
    • Example of getting the index value in php, where $value is the input value:
    • $index = round( ( ( $value ) – $start ) / ( $half * 2 / ( count( $colors ) – 1 ) ) )
    • Then the color to use as background color in each cell would be: $color = $colors[ $index ]
  • Display a ‘legend’ that tells the user the range of colors for given values.
    • My legend is automatically generated using ‘start’ and ‘half’ values, here’s an example for a legend that ranges from -1 to 1
    • Actually, I have it as a file that gets included into the file containing the heatmap. Legend php file: legend.php
    • I should mention that the file containing the heatmap must include the colors.php before including legend.php
  • When things go OK, heatmap should look pretty. Example:
  • Missing values should use a different color, such as gray.
  • Last note: it was not necessary to care about efficiency when displaying the heatmap. One query was used to remember the rows and columns. Then nested loops performed queries to retrieve the value of each cell in the table. That is, for ‘c’ columns and ‘r’ rows, there were c * r queries to the database, which was OK in heatmaps on the range of 100 rows by 20 columns.

Later, the database table had to be updated via a text file. These steps were done to update it:

  • Truncate the existing table
  • Make sure that there is no header line (such as cross1 cross2 value)
  • Since we’re in linux, make sure that end-of-line characters are not an issue (‘vi’ tells me if file is DOS, if so, do: set ff=unix).
  • Load the new file into the table via SQL command: load data local infile ‘heatmap.txt’ into table heatmap
  • Verify the minimum and maximum value in the table so that the heatmap can display colors correctly


Lentils soup (mexican dish ‘sopa de lentejas’)

April 20th, 2014 by Boanerges Aleman-Meza

Ingredients:

  • 5 cups of lentils (1 lbs)
  • 1/3 cup of chopped onion
  • 1 garlic cove
  • 6 cilantros
  • 3 cups of mixed veggies (I normally used one 16 oz. frozen bag)
  • 2 tomatoes (chopped)
  • 4 slices of bacon, chopped in 1/4 inch pieces (alternative ingredient: ham)
  • 3 teaspoon chicken bullion
  • 3 teaspoon salt

Procedure:

  1. Wash the lentils with water and drain the water
  2. Fry the bacon in a big pot with 2 spoons of oil
  3. Add the onion and cook until it gets transparent
  4. Add the tomatoes, the veggies, the lentils and mix them
  5. Add water, chicken bullion, garlic, salt, and cilantro
  6. Mix and cook at middle fire for 30 minutes


Interviewee and interviewer in the same week

March 25th, 2014 by Boanerges Aleman-Meza

tldr; I believe that interviewing people does not improve my technical skills.

The other week I did a phone technical interview with a company that is one of top 5 in its category. Here’s what I consider top tech companies and why, in no particular order:

  1. Google – potential for growth and they still do not do everything well.
  2. Twitter – this company will have an influence for decades to come.
  3. Facebook – they capture family relations better than any one would dream of.
  4. Amazon – they sell stuff but they are going to grow much more in future.
  5. Microsoft – I think they are the underdog now.
  6. Apple – I would like to work in something new they do and ‘secret’ enough that I would not be able to mention it to my partner.

On the same week, I was the interviewer for a handful of candidates for a six-month internship at my workplace. It was clear to me how to prepare for the technical interview. However, I could not give any precise advice on how to prepare for the interview to join our lab. When I reflect back on the interviews, I realize that interviewing people does not improve my technical skills. The people I interviewed are undergrads in biology area. I would think that the person that interviewed me had a chance to improve his/her technical skills because I was asked programming questions. It is likely that the interviewer learned nothing new, but the chance is there.

I did enjoy talking to candidates to the lab where I work. It is good that all have a high level of knowledge and are likely to do well professionally.

The books that I browse for preparing for interview were:

  • 60 seconds and you’re hired (by Robin Ryan). Summary: reply with short answers (no more than 60 seconds)
  • Programming interviews exposed (by John Mongan, et al, 2nd Edition)
  • How would you move mount fiji? (by William Poundstone)


Your January eStatement is available

February 4th, 2014 by Boanerges Aleman-Meza

“Your January eStatement is available” and similar monthly-statments emails are useless notifications in our time.

What does the bank (or other institution) expects me to do? download it, print it, and archive it for my records?

It is not needed! unless you’re applying for mortgage or something like that, it is useless.

In addition, the institutions that send me such emails do not have an option to unsubscribe! It is either get zero emails or get all, and I need other emails, such as the email they send when a check has been cashed.



Missed opportunity on “replies to survey@united.com are not monitored”

January 23rd, 2014 by Boanerges Aleman-Meza

United Airlines has been sending email after each flight, such as: Tell us about your recent flight from Cancun, Mexico to Houston, TX.

My unsolicited suggestions about their approach:

  • Remove the line saying “replies to survey@united.com are not monitored”.
    • It tells me that no one cares. Others have pointed this out: here, and here.
  • Give the option to just reply to message, or answer the structured survey.
    • Imagine a big display on a wall inside United Headquarters that randomly displays such emails for them to see as they walk on a hallway.
    • Such emails could be placed automatically into an internal blog in United, or a forum, so that follow up can be done as needed.
  • It makes no sense that the survey “expires”.
    • After a week long vacation, does United really think that answering their email is the top of the things to do when I get back to home and work?
  • Give some incentive to provide feedback. Example: a chance to win a tablet, or even a chance to win frequent-flier miles.


Writer’s block is not an easy thing to handle

January 13th, 2014 by Boanerges Aleman-Meza

Slightly over 2 months ago, I had a dream that I thought had elements to make a story for a book (or movie).

Since the last two months, every day from that night that I had the dream, I keep thinking about it.
The first two weeks I would think about it in the morning, at lunch and before sleeping at bed. That is, several times a day.
After 2 weeks, it was less often in the day.
After 1 month, it was less often, but always think about it at least once every day.
It is the type of thing where related things remind me about it. For example, when I see a library (because it is related to the dream).
At work, it is easy to ignore it and get back to work.
However, before going to sleep, the story is something that goes on and on in my mind for at least 10 minutes (often a good 1/2 hour). I realized that there’s not much else to do to get distracted because all I want is to fall sleep but I keep on thinking on the story.
I would think of alternative lines to develop the story, or would imagine what a professional would add to the story.

In the past, whenever I hear about “writer’s block”, I would think that it is an exaggeration. When I wrote my PhD thesis I had no trouble.
Now, the issue of writer’s block is clear. It is feeding a bit on what can be called obsessive-compulsive behavior.
Fortunately, it is not unhealthy. It is just annoying at times, for example, I have to remind myself of other things, such as whether I took the trash out, or whether all doors at home are locked.
The story is not great, few people would understand the emotions of it.
However, it has stuck deeply in my heart, likely due to the science-fiction elements.
It is also likely due to the criticism I found myself doing after watching movies.
I believe that if I had grown up in Los Angeles, I would have, at least, tried to be an extra in several movies, and maybe, be involved in the movie-production business, ideally in computer stuff.

The unique thing about writer’s block is that it is a feeling that I go through “alone”. If my wife were a writer, then she would understand it. It is also one of those things that you just do not do conversations about it with friends. Just deal with it on your own.

Last but not least, the dream is as follows:
***As I’m walking in a hallway inside of very big library in Manhattan, I see a few tall big people pass quickly ahead of me.
They are wearing black suits and are armed.
I can see that some have FBI marked vests and others have Homeland Security marked vests.
All of a sudden, two of them push me inside of one of the rooms of the library.
It is a big room with a handful of tables to read and walls with bookshelves everywhere.
There are already a dozen people there.
Four more FBI people (heavily armed) walk inside the room and they lock the door.
The room has windows to the outside but no other door.
The FBI people asks all in the room to pay attention to what she’s going to say and advises us to cooperate.
“We are from the future.” She says.
“We come from year 2137 to attempt to fix an event that changed our world for the worst.”
She explains that in the early 2100’s there was a small war that escalated into nuclear war.
Historians in 2110 were able to trace back a single event that if changed, war would never happened.
It took another 20 years for USSA to develop time-travel capabilities.
In fact, time-travel was already possible since early 2010 but only to go forward in time, not back in time.
A secret agency of USA used time-travel to attempt to detect events of mass destruction.
Apparently there were no big events in all of a century. USA was a safe place.
However, there was nothing they could have done to avoid the wars in 2100’s or at least to be better prepared for it.
One person in the room then interrupted saying that it all is crazy and wants out of the room.
FBI people handle the guy and sedate him.
Then the FBI lady continues by saying that one old chemistry book in the library contains details on how to make a hydrogen-bomb to look like a small nuclear bomb.
Such books were thought to be all confiscated by the government since the 1950’s but this one was ‘lost’ in the big library, as it did not show up in any catalog and no one knew where it was shelved.
The FBI lady says that if they find the book and destroy it, then the planet will stay a safer place to live 100 years from now.
Someone in the room suggest that we search for the book in the shelves right away.
The FBI lady says that it is not in the room.
When asked how does she know that, she says that they suspect that the book is in one of the higher floors of the building because they have a photo of a couple where the book is in the background (among other books) and the window is one of higher floors.
Supposedly, the book has to searched for from floors 4 to 19.
The importance of the room in which we are is that they brought a book from the future, a romance book, which describes a love story that develops inside the library in a period of a week.
The same civilian in the room from before, says that it is such a silly thing to do.
Then the FBI lady explains that in the future all books are digitized and that the FBI has develop computer programs that can map events described in the book to real-life events to determine which books can be a reliable guide of what happened in the past.
The romance book is the only book that describes events inside the library, although such event are just library-related things such as readers-meeting, read-aloud of children books and so on.
The FBI lady says that their goal is to interfere in the smallest way possible to avoid altering the future in other ways.
The example she gives is that if, say a woman in the library, happens to miss a date due to the FBI interference, then it is possible that she never marries and then some key person in the USSA government or research labs does not exist and the ramifications would be unknown.
All civilians in the room look at each other and then an old guy asks “What about us? You already interfered with our lives!”
The FBI lady says that it is a risk they are willing to risk, in fact, they chose the room with the least people in it.
She says that it is known in the future that the whole library was built with a few metal bars of radioactive material, which started to leak only a week ago but was detected weeks later.
90% of the people that visited the library in this month develop lethal cancer and will die within one year.
I am shocked to hear this, but then I see others in the room sobbing already.
I asked the FBI lady if they will die too.
She says that they have the same chances than us, 10% chance of living.
In fact, she says that they are stuck in our timeline because the equipment to send someone in time-travel is of the size of the European particle accelerator.
As she goes on to say that each of the 6 FBI or Homeland Security people in this mission are aware of the risks and that they are doing it to help save the planet, I can only wonder about the complexities of the computer programs that can map events of a book to real-life events.
When the sobbing intensifies for an old lady in the room, the FBI people says that they want us to help them find the chemistry book.
They expect us to spend 9 hours in the library each day, eating inside, and actually bringing food for them because they do not want to interfere with the world outside the library.
Another FBI guy says that they all love the shawarma of around the block of the library.
They say that the mission will take at most 11 weeks if we all participate, and that they will be working on it the whole awake hours.
Even they say that their showers will take place inside a janitor’s room that has a shower head but unfortunately it is cold water.
I fully appreciate their commitment to their mission and for a moment I forget that I’m unemployed and with rent due 10 days from now.
Then, another civilian asks what is in it for us?
The FBI lady says that we will get paid 1,000 cash for each day worked, and that we don’t have to work on weekends but are welcome to do so to get extra money.
She says that the money is in 1000 dollar bills, and that it is clean money.
I am in, and so are 3 more people.
The rest say that they need to sleep over it, worried about the risk of cancer.
The FBI lady explains that the studies of the radioactive metals and medical history of people affected indicate that it was the entrance to the library where the metal was located, and that the risk was no different for someone that entered the building only once versus people that went in the library a every day.
She also says that the risk factor was not found to be different for any race or age group.
At this time, I suspect that the other 3 that said will help also needed the cash.
The FBI lady says that the information desk in the FBI building in Brooklyn pays informants and are trained to exchange 1000 dollar bills with specific number sequences to small change, no question asked.
Supposedly the money we will get has such number sequences, so that no suspicion is found by the banking industry.
However, she advises not to spend it all in one place.
No one laughs.
She says that the best way is to spend cash little by little to avoid suspicion by the IRS.
The example she gives is that of buying an used car for 10,000 without withdrawing such amount from the bank first, or actually depositing big quantities of money.
Her advice is to deposit no more than 2,000 in each month.
“We are going to be dead soon anyways”, some other person says.
The FBI lady replies saying that they have the same risk.
In fact, it was extremely difficult for the FBI of their timeline to find people for this mission because many were dependent on radiation medicines as a result of the nuclear war.
She adds that in their future, half of the population is infertile, hence the importance of the mission.
***

Final notes:

  • In my dream, USSA actually means United Saudi States of America. Supposedly in the future, there was a financial crisis where neither the insurance companies nor China were able to bring cash to avoid financial collapse. The ones that came to the rescue were a group of wealthy Saudi, which had a special request to change the name of the country.


Computer programming in Java doing GUIs, then image processing, then databases, then some PHP

December 20th, 2013 by Boanerges Aleman-Meza

I do lots of computer programming. I like it a lot.

However, switching context is required in my current job. My programming can change, even in the same week, among the following:

  • Graphical user interface in Java
  • Crunching numbers in Java (often via commons-math from Apache.org)
  • Loading data into databases via Java (minor cleaning and validations are the norm)
  • Simple web pages that use PHP to query databases
  • Basic image processing stuff (imageJ is often enough)


Flaws in movies or TV series are likely intentional

December 17th, 2013 by Boanerges Aleman-Meza

I recently watch DVD of Superman (Man of Steel) and also one episode of Gray’s Anatomy.

I was able to find several flaws in each of them. Often, I bring it up and talk about with my wife (as long as we both did watch the movie, or tv-show).

However, I did remember something funny about blogs:

So, my conclusion is that the flaws in movies and TV series are likely intentional. In a way, it also helps in the writing, so that there’s less need to have a 100% perfect story. I can totally imagine the writer leaving flaws or holes in the script.



things I want in a Minivan

December 14th, 2013 by Boanerges Aleman-Meza

We rented a Town and Country minivan the other week. Here’s a list of things I’d like in a minivan (in no particular order), in the event we buy our own minivan:

  • backup camera
  • middle-middle seat with LATCH for carseat
  • power-sliding doors
  • power tailgate (desirable)
  • bluetooth
  • DVD player
  • 115V power outlet
  • The ovious stuff:
    • automatic transmission
    • cruise control
    • remote-entry system


How do you address Arnold Schwarzenegger?

December 13th, 2013 by Boanerges Aleman-Meza

Summary of a dream I had last night:

In my dream, I am working as family counselor. I’m in the living room of a family of a young marriage where is also joining the meeting the mom of the wife. The mom of the wife has a 2 year old daughter.

The little girl is playing around where I am seated and when the meeting is over, she holds my hand as we walk out of the room towards the backyard, which is huge, the house was a mansion. The backyard might has well had been a park. It had its own lake and fountains and there was a big fancy party going on, easily over 200 guests, most of them wearing casual or business attire.

The family asks me to hold the little girl on my arms and they ask a photographer to take a photo of her. Then they say that the father of the girl is coming to take a photo with her. They go get him as he’s talking to some CEO-looking person. As he walks towards where I’m holding the little girl, I recognize him. He’s the governator! Wow, that means that the mom of the little girl is that famous lady that I think is of a political family (not sure of name or anything else). Then, I start to wonder, how to address Arnold Schwarzenegger when he’s right next to me? Do I call him Mr. Schwarzenegger? Do I call him sir? The guy looks just like in the movies, except that he’s wearing shorts and has a big smile as he walks to meet his daughter.

Then I wake up. Anyways, I do not even know if in real life he’s dad of a little kid or not. I conclude that if I ever meet the guy I’ll will call him “sir”. That should do it.