# plot data being output from the quartet.pl Perl script data <- read.table("quartet.out", sep = "\t", header = TRUE) # number of lines lines <- length(data$bin) # find out about the maximum count for haplomaternal ymax <- max(data$haplomaternal) # define a vector of colours colours <- c("red", "yellow", "green", "blue") # make an empty plot plot(0, type = "n", xlim = c(0, lines), ylim = c(0, ymax), ylab = "Counts", xlab = "Bin") # plot the data for (i in (1:lines)) { # identify the column with the maximum value using the # function which.max() xmax = which.max(c(data$identical[i], data$haplopaternal[i], data$haplomaternal[i], data$nonidentical[i])) # plot the line lines(c(i, i), c(0, data[i, xmax + 1]), col = colours[xmax], lw = 1) }