Recently I have conducted a microbiological experiment on carriage pattern of bacteria in a certain group of professional people over a week. It would be very helpful for me if somebody suggest which statistical analysis and graphical representation are appropriate for this type of experiment.

Study description: I have included 31 animal farm workers (from eight different farms). I collected samples twice everyday (morning and afternoon) from a Monday morning to the next Monday morning, which comprises 15 samples from each participants. In every sample, I quantified the number of bacteria presence per sample (two separate count for bacteria A and bacteria B). In addition, I have collected data from each participant on everyday working hours, age, sex, years working in the farm, use of face-mask, hand wash, and other related information.

Research question 1. What is the trend of carriage patterns of these two bacteria among the farm workers in relation to everyday working hours over the whole week?

Help need: How can I summarize and graphically represent the every day’s bacterial count in 31 participants including working hours. Any suggestion about heat map using R?

Research question 2. Is there any significant relation in the bacterial carriage pattern with age, sex, or other variables?

Help need: Which statistical analysis is appropriate for this type of data?

Here I have given a google sheet link of a dummy set of data for your understanding. Missing samples are indicated by empty cells. Number of bacterial count at each time point is in sheet1 and other example information are in sheet 2.

Dummy Sheet1:


Dummy Sheet2:


Thank you in advance for your time and help.

  • $\begingroup$ I think that this is a model of how to ask a question here. I was asked to review this because you re a beginner on this site. I don't have an answer for you right now but I commend you for a very clear question. This is the best one I have seen coming from beginners. $\endgroup$ Commented Jan 12, 2017 at 13:01
  • $\begingroup$ Thanks @MichaelChernick for your nice appreciation, This is my first question in this forum. Hoping to get some good suggestions from experts. $\endgroup$
    – Zahir
    Commented Jan 12, 2017 at 13:09
  • 1
    $\begingroup$ If you want to display count against working hours you could plot a separate scatterplot for each participant. If you use the lattice package you can get all 31 on one diagram. If you want to plot count against time you could investigate so-called spaghetti plots (one line per participant). $\endgroup$
    – mdewey
    Commented Jan 12, 2017 at 13:15
  • 1
    $\begingroup$ As far as your analysis is concerned you might like to investigate mixed effect models although I am not absolutely sure they target your scientific hypotheses. $\endgroup$
    – mdewey
    Commented Jan 12, 2017 at 14:05

1 Answer 1


Thank for providing the data with your question. It has been interesting to explore. However, given the lack of answers so far, perhaps your questions are too broad for a good answer.

Now that the bar is lowered, I will try to address the data visualization part of your question and suggest some analysis issues.


First of all, the distribution of your bacteria counts do not follow a Normal distribution.

enter image description here

That's not unusual for count data, but it does make it harder to use simple modeling and visualization techniques. Sometimes applying a Log(x) transformation, or Log(x+1) to avoid Log(0) cases, will make the distribution more "normal" for the sake of analysis and visualization.

enter image description here

It's closer to Normal, but there is still a large group of observations at 0. Those could be analyzed separately or you could use an analysis that includes a zero-inflated model.

Another comment about the count data is that the A and B counts are exactly the same for about 20% of your non-zero observations, which may be something to investigate.

enter image description here

Another possible consideration for analysis is the degree of sharing between observations. For instance, do you expect the count from one day to be dependent on the previous day's count? And how much are farmers on the same farm overlapping?

Finally, regarding the mask variable, there are only 6 observations out of 465 where a mask was worn, so it's doubtful any information can be gained there.


Regarding your visualization question about heat maps, it sounds like you want to show the count versus 3 factors. Heat maps work well for 1 or 2 factors because we can see patterns across rows or columns, but they lose some effectiveness when trying to show more factors. You might try choosing two factors at a time for a heat map. Another option (along the lines of @mdewey's comment) is a small multiples approach. Here are two examples with one graph per farmer and day on the X axis. The first one has log(A count + 1) on the Y axis and uses work hours for the circle size.

enter image description here

This second one has work hours on the Y axis and uses log(A count + 1) for the color. The black dots indicate missing count values.

enter image description here

  • 1
    $\begingroup$ Dear Xan, Thank you for your detail answer. I will try to make visualization plot as you recommended. $\endgroup$
    – Zahir
    Commented Jan 31, 2017 at 13:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.