To check our data, we need to take a closer look at the control values first. In order to do that, calculate the mean expression for every gene in the control treatment and store these values in an object called chk.

You can use the function colMeans() to quickly calculate the mean of every column in a matrix, data frame or tibble. Keep in mind that the function colmeans() only works if you have exclusively numeric variables in your dataset.

 

   replicate      id treatment    Gene1    Gene2    Gene3    Gene4    Gene5    Gene6    Gene7   ...
1          1 ID 9239   control 29.60523 20.84956 27.11910 19.30535 18.37085 18.35265 22.95577
2          2 ID 9239   control 20.39603 24.55238 19.88842 20.21842 19.94912 32.39009 25.84113
3          3 ID 9239   control 24.94694 20.98351 21.90802 14.96396 31.19226 31.77084 18.06114
4          4 ID 9239   control 24.96139 26.71594 17.64886 18.79438 20.76621 25.87369 22.74943
5          5 ID 9239   control 22.28186 19.15017 25.28507 14.05407 24.59658 27.22024 20.01675
6          1 ID 7057   control 24.59369 22.23258 18.49725 10.12569 20.10379 17.09188 17.45587
7          2 ID 7057   control 26.17200 21.02197 23.42640 16.01828 14.09717 16.30789 27.77393
8          3 ID 7057   control 23.38154 24.85749 29.31398 15.06018 20.64261 15.16328 22.61038
9          4 ID 7057   control 18.89204 16.88536 24.14300 12.35423 15.68445 23.80580 38.25066
10         5 ID 7057   control 15.35030 18.42504 27.78034 10.71458 20.86934 25.98996 27.03204