Hi,

I am thinking about using the Python Imaging Library to display the life cycle of a hair follicle gene. This life cycle is divided into four main stages:
1. Anagen
2. Catagen
3. Telogen
4. Exogen

Gene name and corresponding life cycle stage will be stored in a csv – file or Excel Spreadsheet column.

In a picture of this life cycle, the corresponding gene stage should be highlighted in some way.

The enclosed picture is a rough draft, but should give an idea how the life cycle will look like.

Is it possible to do this with a Python script? Will I have to store different 'versions' of the life cylce, each one highlighting another stage?

As I am merely learning Python at the moment, it would be great to receive tips regarding my project, thanks!

Cheers
Juergen

Recommended Answers

All 4 Replies

Hi juergenkemeter,

You want to set up some kind of GUI window that displays the main hair follicle life cycle image, such that when you click the mouse (or press the space key, or enter some other input) a new layer pops up, with maybe a tinted, transparent shape over the relevant stage, and also a list of genes which are differentially expressed at that stage. And you want to set this up so that each input takes you to the next stage of the life cycle. Right?

I don't know how to do any of that! Well, maybe I know how to set up the GUI window and the main image, but I have never played with the Python imaging library. If we took a time machine back two years ago, my past self could probably have showed you how to do all this stuff with Java/Swing, but sadly, I have long since forgotten my Java roots.

The actual reason for my response is pedantic: I don't think it is correct to say "the life cycle of a hair follicle gene." Genes are not alive and they do not have "life cycles" in any conventional sense of the term (though an argument could be made for genes that undergo VDJ recombination, I suppose). A more exact way of phrasing what you mean (I think) is: "I want to display the life cycle of a hair follicle and show the differential gene expression at each phase transition."

Is this what you are trying to do?

Hi,
I thought about two ways to do that.

1. One basic image, which has accurate basic detail level, but no highlighting so far.
(e.g. form of a ‘6’)

2. Provide a fixed placeholder in the Sheepgenomics webpage, or provide another means to display the graphics, e.g. through clicking a Hyperlink which calls the Python imaging function, creating a corresponding image regarding the gene data
o This Python script should take the basic image, alter it according to a RULESET (accessing table gene data, i.e. in which stage the gene is at the moment), and then display the gene stage in the basic image.
o OR, if there should only be a fixed number of stages highlighted, store 4, 5, 6 different-looking images (different stages already highlighted), and then display the corresponding picture according to the underlying, stored stage data of the gene

Please read the next answer I have written, as I was too late to modify my previous response:

Hi,

The main aim would be to display a highlighted graphic. It is not necessary to provide gene information, too.

There will be a fixed number of stages. Therefore perhaps store various different-highlighted basic images, and then display the corresponding picture according to the gene data

I have given some thought to a suitable diagram. One option would be to use a diagram similar which you can see on page:
http://photobucket.com/albums/a19/juergenkemeter/

The diagram represents follicle development in the foetal skin (stages 0 to 8) and then the 4 main stages of the follicle growth cycle in the adult (anagen, catagen, telogen and proanagen). It has lists of the main processes involved at each stage.

The diagram is quite large which will be an issue - maybe it would have to open as a separate window.

Also, is there a possibility to underlay a highlighted section of an image with hyperlinks referencing original experiment data?

Cheers
Juergen

Take a look at these two PIL examples and see if you can apply them to your task ...

# using the PIL Python Image Library:
# get a region of an image

import Image

# open an image file (.bmp,.jpg,.png,.gif) you have in the working folder
im1 = Image.open("Donald.gif")

# set up a 100x100 pixel tuple-box(ulcX, ulcY, lrcX, lrcY)
# coordinate ulcX = upper left corner X ...
box = (30, 30, 130, 130)

# now crop that region and assign to im2
im2 = im1.crop(box)

# brings up the modified image in a viewer, simply saves the image as
# a bitmap to a temporary file and calls viewer associated with .bmp
im2.show()
# using the PIL Python Image Library:
# insert a small image into a larger image

import Image

def watermark(image, thumb):
    """inserts thumb into image, modified image is returned"""
    imageX, imageY = image.size
    thumbX, thumbY = thumb.size
    if thumbX < imageX and thumbY < imageY:
        point1 = imageX - (thumbX + 10)
        point2 = imageY - (thumbY + 10)
        point3 = imageX - 10
        point4 = imageY - 10
        image.paste(thumb, (point1, point2, point3, point4))
    
if __name__ == '__main__':
    # load two images, pick something you have
    # thumb1 should be smaller in size than image1
    image1 = Image.open('Audi.jpg')
    thumb1 = Image.open('Audi2.jpg')
    watermark(image1, thumb1)
    image1.show()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.