# practical03

# Read a table with counts
countTab <- read.table("https://cei.bio.ed.ac.uk/exRNA_Bioinformatics/data/ev_exp/EV_experiment1.txt")
head(countTab)

# this will not work because it is a data.frame
#barplot(countTab)

# step 1: convert to matrix
countMat <- as.matrix(countTab)

# define the colours I want
colors <- rainbow(6)
colors <- c(4,5,3,7,2,8)

# make the barplot
barplot(as.matrix(countTab), col=colors, space=0.5, las=2,
        main="Sequencing counts by annotation", legend.text=TRUE)

# convert to percentage
percMat <- sweep(countMat, MARGIN=2, STATS=colSums(countMat), FUN="/") * 100
percMat

barplot(percMat, col=colors, space=0.5, las=2,
        main="Sequencing counts by annotation (as percent)", legend.text=TRUE)

barplot(cbind(percMat,NA,NA), col=colors, space=0.5, las=2,
        main="Sequencing counts by annotation (as percent)", legend.text=TRUE)

x <- 1:5
plot(x)

myFiles <- c("file1", "file2", "file3")

for (myFile in myFiles) {
  # read the file in
  # normalize it to a percentage
  # remove rRNA
  # generate a plot
}














