You are here: AU PhD  Graduate Schools Science and Technology Courses and how to sign up Scientific courses Introduction to Programming for Animal Sciences (spring 2016)

Introduction to Programming for Animal Sciences (spring 2016)

ECTS credits:


Course parameters:
Language: English
Level of course: PhD course
Time of year: Spring 2016, Two week course, 29 March – 12 April/2016
No. of contact hours/hours in total incl. preparation, assignment: 72 hours (30 hours of lectures + 42 hours of assignments)
Capacity limits: 20 participants


Objectives of the course:
The main objective is to teach students the basic logics of algorithms and programming structure.


Learning outcomes and competences:
At the end of the course, the student should be able to:

  1. Identify the detailed logical steps involved in solving simple programming task
  2. Devise algorithms to solve simple programming tasks
  3. Implement simple algorithms in their language of choice
  4. Deconstruct a problem into small and manageable sub-problems
  5. Assess in an empirical way and compare the performance of different ways of solving a particular problem


Compulsory programme:
Course participation and completion of assignments


Course contents:

Module 1 – Introduction

  1. Introduction to course: motivation;
  2. Constructs vs. algorithms;
  3. Variable/objects classification: understand the differences between integer, real, double,

logical and character;

  1. Comparing values according to type;
  2. Conversion between types;
  3. Introduce vectors (concept and usage) and factors (R type)
  4. Boolean operators and statements;
  5. Subset data given a Boolean statement.


Module 2 – Loops I

  1. Simple loops (‘for’ loops): limited number iterations;
  2. Iterative computation;
  3. Nested loops.


Module 3 – Loops II/Conditions

  1. Many operations inside a loop, logical order that operations should take place;
  2. Loops determined by some criteria (‘while’ loops);
  3. ‘If/else’ statements: write ‘if/else’ flowcharts, predict the outcome of ‘if/else’ statements;
  4. Use of ‘if/else’ statements inside loops.


Module 4 – Reading and writing files

  1. Files paths: working directory, absolute vs. relative paths;
  2. Opening files: reading, writing, appending;
  3. Regular and formatted output;
  4. Reading formatted data;
  5. Processing one line at a time;
  6. Reading directories;
  7. Closing errors;
  8. Error checking.


Module 5 – Matrices and vectors

  1. Basic operations with vectors and matrices:, adding, dot product, matrix product;
  2. Handling data frames: read and write.


Module 6 – Mathematical issues

  1. Missing values;
  2. Mathematical operations that are of indeterminate form: problems and solutions;
  3. Rounding;
  4. Differences between large numbers;
  5. Random numbers and seed.


Module 7 – Strings

  1. What is a string;
  2. Comparing strings;
  3. Strings replacements;
  4. Splitting and joining strings.


Module 8 – Functions

  1. Code reuse;
  2. Create functions;
  3. Function elements: name, arguments, body, return value;
  4. Within function variables and global variables;
  5. Returning success/error;
  6. Using functions inside a loop;
  7. Recursion.


Module 9 – Optimization and debugging

  1. Assessing the performance of a program;
  2. Tools to reduce running time;
  3. Memory cost of copying;
  4. Improving loops;
  5. Debugging.


Module 10 – Sorting algorithms and final considerations

  1. What is sorting;
  2. A naïve sorting algorithm;
  3. Developing and implementing sorting algorithms;
  4. Final considerations: the importance of comments, indentation and organization in a code.


Basic knowledge of matrix algebra


Name of lecturers:
Beatriz Cuyabano and Bernt Guldbrandtsen


Type of course/teaching methods:
Two week intensive course including lectures, computer exercises and assingments




Course homepage:


Course assessment:
Satisfactory completion of assignments


Center for Quantitative Genetics & Genomics (QGG), Dept. of Molecular Biology and Genetics, Aarhus University


Special comments on this course:
You need to bring your own laptop with R, Rstudio installed and Eduroam working.



29 March – 12/April 2016


  • March 29: Module 1 and 2, Meeting Room 3
  • March 30: Assignment
  • March 31: Module 3 and 4, Meeting Room 3
  • April 1: Assignment
  • April 4: Module 5 and 6, Meeting Room 4
  • April 5: Assignment
  • April 6: Module 7 and 8, Meeting Room 3
  • April 7: Assignment
  • April 8: Module 9 and 10, Meeting Room 4
  • April 11: Assignment
  • April 12: Assignment



  •  March 29: Meeting Room 3
  • March 31: Meeting Room 3
  • April 4: Meeting Room 4
  • April 6: Meeting Room 3
  • April 8: Meeting Room 4
  • Registration:For registration: By e-mail to Deadline 14 March 2016.

When registering, please indicate level of programming experience (none, minor, some experience, intermediate).

If you have any questions, please contact Beatriz Cuyabano (

Comments on content: 
Revised 05.11.2018