Chi-squared test: Investigating fruit flies attraction to different colours I have a few questions about the Chi-squared test. First of all, this is what I was investigating:
H0: Fruit flies show no difference in attraction to light of different colours
Protocol:
20 fruit flies put in tube. Tube is marked into 3 equal sections along its length. 
Tube shaken so flies collect at bottom. LED of chosen color shone at the top of the tube for 1.5 mins, and number of flies in each section counted.
6 different colors used.
Results:
I was told to use the chi-squared test for each color. This is how I used the test for Red (value came out as 4.03): 

The expected frequency is 6.67 because there were 20 flies in each tube and three equal sections, so 20/3.
Questions
How many degrees of freedom were there? 6 Different colors used so should it be 6-1= 5 degrees?
Or since there were only 3 sections in each tube, would it be 3-1 = 2 degrees?
A second question: I used the Chi squared test for each of the 6 colours. If the chi squared values for a few colors were below the table values and not statistically significant e.g. Red and Green, but the other colors were, can I reject the null hypothesis? 

Update
Repeat 1:
        Layer
Color     bottom  middle  top
  white        1       2   17
  blue         5       1   14
  red          5       3   12
  orange       5       3   12
  yellow       4       2   14
  green        8       0   12


Does this look ok?
Update 2
Is it possible to avoid three way contingency tables by just adding up the results from my three repeats? Also the critical value, taking p = 0.05 and df=10 is 18.3  - quite a lot smaller than the value I got below, so am I doing the maths wrong here?

 A: Gung's test is a test of independence in the two-way classification table. Additional tests are possible, as described in Wicken's book Multiway Contingency Tables Analysis for the Social Sciences, one of the last, great treatments of this topic before the advent of tensor models. As Wickens notes:

There are three different experimental procedures that generate
  two-way tables of frequencies. These lead to different models for the
  population of scores, although the actual tests are the same. The
  three null hypotheses are referred to as hypotheses of homogeneity, of
  independence and of unrelated classification...one way to distinguish
  among the three descriptions is to look at the roles of the marginal
  frequency distributions (p.22)

In the OP's case, a test of homogeneity seems most appropriate. It is one in which the characteristics of the population are embodied in the row conditional probabilities. Using Gung's table setup, the expected counts for each color by layer cell are conditioned on the "Sum" column:

The null hypothesis tested here is that the distributions of the
  responses across the populations are the same...Thus, one speaks of
  this as a test of the homogeneity of the populations. More
  abstractly, the probabilistic structure underlying these data is a
  pair of binomial distributions (p. 23)

This test differs from the test of independence in that a single, fixed marginal is being used -- as opposed to the combined row and column marginals in the test of independence. 
The test for unrelatedness involves fixed row and column marginals and isn't appropriate for this data (i.e., all marginals would sum to 20).
