Collapse and average the microarray data
Entering edit mode
4.8 years ago
grayapply2009 ▴ 240

I have a microarray data set. The format is like this:

a   12  13  14
b   15  16  17
a   21  22  23
b   24  25  26

Now I want to collapse and average all rows and columns based on the gene name (the 1st line). The desired results:

a  16.5  17.5  18.5
b  19.5  20.5  21.5

The awk code I found:

awk '
        arr[$1]   += $2
        count[$1] += 1
        for (a in arr) {
            print a "\t" arr[a] / count[a]

Question: This code only works on the first column. How do I expand this code to multiple columns? Say I have 100 columns.

awk microarray average • 764 views
Entering edit mode

Hello grayapply2009!

We believe that this post does not fit the main topic of this site.

This is a programming question (Microarray data plays next to no role here). Please ask stackoverflow.

For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.

If you disagree please tell us why in a reply below, we'll be happy to talk about it.


Entering edit mode

This is a valid question - arguably every bioinformatics question is a programming question after all. Microarray data is certainly bioinformatics data so any action on it is some sort of bioinformatics analysis even if the OP did not mention that.

I think it is fine to comment and suggest that the OP ask on a different forum or direct them to an more appropriate resource, but I find it premature to close this post.

In general my take on all post closings is that the overwhelming majority of them are not warranted and a much more positive effect could be achieved by simply commenting on the post rather than taking this negative action of closing the post.

I guarantee no mod would ever close a post if they felt what a poster feels when someone closes their post. More empathy would go a long way.

Entering edit mode

You are correct - I do not know how it feels like to have my post closed (I am glad I have never had to face that, be it because of more lenient mods or that my initial questions were worded and researched better). I do know how it feels to be shut out of a conversation/community, and it is not remotely a pleasant or even neutral feeling.

I sincerely do not hold others to standards I cannot live up to, but I will try and be more lenient in the future. Maybe what new users are doing to posts, I am doing to moderation - I got to learn to do it better.


Login before adding your answer.

Traffic: 1272 users visited in the last hour
Help About
Access RSS

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6