Introduction to Biological Data Analysis


TP 3: Graphics and data.frames

Prof. Patrick Meyer

BioSys Lab - Université de Liège

Simple graphics

  1. pairs(CO2[,-1])

    Watch explanation:

  2. pdf("myfirstplot.pdf")
    plot(CO2$conc,CO2$uptake)
    title("Uptake in function of the concentration in CO2")
    lines(c(30,1000),c(5,45),col="green",lty=3)
    dev.off()
    

    Watch explanation:

    And for the pdf:

data.frame

  1. write.table(CO2,file="mydata.txt",sep=",")
    mydata <- read.table("mydata.txt",sep=",",header=T)
    

    Watch explanation:

  2. sum(CO2$Type=="Quebec" & CO2$uptake>35 & CO2$Treatment=="chilled")

    Watch explanation:

  3. index <- which(CO2$conc==min(CO2$conc))
    which(CO2$uptake==max(CO2$uptake[index]))
    

    Watch explanation:


  4. maxuptake <- function(nameplant){
      max(CO2$uptake[CO2$Plant==nameplant])
    }
    maxvec <- sapply(levels(CO2$Plant),maxuptake)
    

    Watch explanation:

Advanced graphics

  1. minuptake <- function(nameplant){
      min(CO2$uptake[CO2$Plant==nameplant])
    }
    minmaxmat <- rbind(sapply(levels(CO2$Plant),minuptake),maxvec)
    barplot(minmaxmat,beside=T,col=c("red","blue"),main="minima and maxima of uptakes by plant")
    

    Watch explanation:

  2. uptakemat <- matrix(CO2$uptake,nr=7)
    rownames(uptakemat) <- CO2$conc[1:7]
    colnames(uptakemat) <- unique(CO2$Plant)
    heatmap(uptakemat,Rowv=NA,Colv=NA)
    

    Watch explanation:

  3. par(mfrow=c(1,2))
    plot(CO2$conc,CO2$uptake)
    barplot(minmaxmat,beside=T,col=c("red","blue"),main="minima and maxima of uptakes by plant")
    

    Watch explanation:


<--- BACK