Loading...
 

Profile_r_heatmaps_test

Below you should see a heatmap produced if everything (Tiki, R, PluginR, and the required R packages) are successfuly instaled and configured.
You can edit this page to tweak some parameters by hand if you wish or needed.

{RR(loadandsave="1", echo="1", svg="1", pdf="1")}
      1. Chunk 1: Installation of easyHeatMap package and dependencies

          1. NOTE:
  1. * You need a few packages: install the ones you are missing in the central server location for R packages.
  2. * In this example we install them with this params: lib="/usr/lib/R/site-library", repos="http://ftp.heanet.ie/mirrors/cran.r-project.org/"
  3. but adapt the server paths or urls to your specific case
  4. * Remember you can install packages:
  5. * from the terminal with some command like:
  6. R CMD INSTALL /home/foo/myPackage.tar.gz --library="/usr/lib/R/site-library"
  7. * or from an R session with something like:
  8. install.packages(pkgs="/home/foo/myPackage.tar.gz", lib="/usr/lib/R/site-library", repos="http://ftp.heanet.ie/mirrors/cran.r-project.org/")

cat("Cheacking dependencies:\n")
if (is.na(match("gplots", installed.packages()))) {
install.packages("gplots", repos="http://ftp.heanet.ie/mirrors/cran.r-project.org/")
} else {
cat(" Package gplots is already installed. OK.\n")
}
if (is.na(match("gtools", installed.packages()))) {
install.packages("gtools", repos="http://ftp.heanet.ie/mirrors/cran.r-project.org/")
} else {
cat(" Package gtools is already installed. OK.\n")
}
if (is.na(match("gdata", installed.packages()))) {
install.packages("gdata", repos="http://ftp.heanet.ie/mirrors/cran.r-project.org/")
} else {
cat(" Package gdata is already installed. OK.\n")
}
if (is.na(match("caTools", installed.packages()))) {
install.packages("caTools", repos="http://ftp.heanet.ie/mirrors/cran.r-project.org/")
} else {
cat(" Package caTools is already installed. OK.\n")
}
if (is.na(match("easyHeatMap", installed.packages()))) {
##### Install the package "easyHeatMap"
### for the time being you can fetch it from:
### https://ueb.ir.vhebron.net/files/easyHeatMap_1.18.tar.gz
### or
### http://dl.dropbox.com/u/24830595/easyHeatMap_1.18.tar.gz
cat("Attempting to download easyHeatMaps from http://ueb.ir.vhebron.net/files/easyHeatMap_1.18.tar.gz \n")
download.file("http://ueb.ir.vhebron.net/files/easyHeatMap_1.18.tar.gz", "./easyHeatMap_1.18.tar.gz")
cat("Attempting to install package easyHeatMaps \n")
install.packages(pkgs="easyHeatMap_1.18.tar.gz")
if (is.na(match("easyHeatMap", installed.packages()))) {
cat(" Something must have gone wrong, since the package didn't get successfully installed for some reason")
} else {
cat(" Package easyHeatMaps successfully installed. \n You can now proceed to create some <a href=\"tiki-index.php?page=HeatMaps&cookietab=2\">HeatMaps</a>")
}
} else {
cat(" Package easyHeatMap is already installed. OK.\n")
cat("\n You can now proceed to create some <a href=\"tiki-index.php?page=HeatMaps&cookietab=2\">HeatMaps</a>\n")
}


      1. Chunk 2: R commands to generate the required files server-side from BioConductor
      2. "expres.filtered.ALL.txt", "expres.selected.ALL.txt" and "colorsForColumns.txt"

          1. A few packages are required from Bioconductor to produce HeatMaps with real data
  1. source("http://www.bioconductor.org/biocLite.R")
  2. biocLite("ALL", lib="/usr/lib/R/site-library")
  3. biocLite("genefilter", lib="/usr/lib/R/site-library")
  4. biocLite("hgu95av2.db", lib="/usr/lib/R/site-library")

  1. require(ALL)
  2. require(genefilter)
  3. require(hgu95av2.db)

  1. The ALL package contains a sample "ExpressionSet" with expression values form
  2. 128 samples and 12625 genes
  3. ("features =probesets, remembering there may be more than one probeset per gene")
  4. The dataset contains five different genotypes
  5. ALL1/AF4 BCR/ABL E2A/PBX1 NEG NUP-98 p15/p16
  6. 10 37 5 74 1 1
  7. The two example datasets keep only samples from the first and second groups
  8. To use a small number of genes two standard 'filtering approaches' are tested
  9. 1) Non specific filtering
  10. Only most variables are kept. Their expressions are stored in file "expres.filtered.ALL.txt"
  11. 2) Specific filtering
  12. We retain genes according to a test comparison between two groups.
  13. Their expressions are stored in file "expres.selected.ALL.txt"
  14. 1- Selecting genes by non-specific filtering
  15. require(ALL)
  16. data(ALL)
  17. require(genefilter)
  18. filtered095 <- nsFilter (ALL, var.cutoff=0.95)
  19. filtered099 <- nsFilter (ALL, var.cutoff=0.99)
  20. esetSel095<-filtered095$eset
  21. esetSel099<-filtered099$eset
  22. esetSel <- esetSel099
  23. esetSel<- esetSel[,pData(esetSel)$mol.bio No value assigned c("ALL1/AF4", "BCR/ABL")]
  24. colnamesesetSel<- paste("X", colnamesesetSel, sep="")
  25. write.exprs(esetSel, file="expres.filtered.ALL.txt")
  26. 2- Selecting genes by specific filtering
  27. require ("ALL")
  28. data("ALL")
  29. eset <- ALL, ALL$mol.biol No value assigned c(%22BCR/ABL%22, %22ALL1/AF4%22)
  30. library("limma")
  31. f <- factor(as.character(eset$mol.biol))
  32. design <- model.matrix(~f)
  33. fit <- eBayes(lmFit(eset,design))
  34. selected05 <- p.adjust(fit$p.value, 2) <0.05
  35. selected01 <- p.adjust(fit$p.value, 2) <0.01
  36. esetSel <- eset selected05,
  37. colnamesesetSel<- paste("X", colnamesesetSel, sep="")
  38. write.exprs(esetSel, file="expres.selected.ALL.txt")

  1. #
  2. # I per crear l'arxiu amb un color diferent per cada grup (basat en la columna "mol.biol")
  3. #
  4. write.table(cbind(paste("X",rownames(pData(esetSel)),sep=""),
  5. as.integer(pData(esetSel)$mol.biol)+1), sep="\t",
  6. row.names=FALSE, col.names=c("Column", "Group"), quote=FALSE,
  7. file="colorsForColumns.txt")


#
  1. #
  2. # Això és un exemple del que voldríem haver capturat a través del formulari
  3. # COMPTE perque, en aquesta versió, no considerem la possibilitat de treure
  4. # - Ni, com paràmetre, la possibilitat d'enviar els gràfics a un arxiu PDF
  5. # --> toPDF es deixa a FALSE
  6. # - Ni un arxiu amb els gens de cada cluster
  7. # --> numClusters es deixa a 0
  8. # - Ni un arxiu/gràfic amb els perfils de cada cluster
  9. # --> plotProfiles es deixa a FALSE
  10. #

      1. Chunk 3: Call to easyHeatMap functions

require(easyHeatMap)
download.file("http://ueb.ir.vhebron.net/dl220", "./expres.filtered.ALL.txt")
download.file("http://ueb.ir.vhebron.net/dl221", "./colorsForColumns.txt")

clustPar<-newClustPar(expres = NULL , # We'll give it a file attached to the tracker item
expresFileName ="expres.filtered.ALL",
# For a file "foo.txt", you have to indicate here "foo" (without extension)
fileType = "txt",
comparisonName = "ALL",
Title = "My Plot: BCR/ABL vs ALL1/AF4",
numClusters = 0, # Confirm that with zero nothing is done
plotProfiles=FALSE,
rowDistance = 'cor',
colDistance = 'euclidean',
RowVals = TRUE,
ColVals = TRUE,
escala = "row",
colorsSet = redblue(64), #colors,
colsForGroups = NULL,
colsForGroupsFileName="colorsForColumns",
densityInfo = "density",
cexForColumns = 0.8,
cexForRows = 0.8,
outputDir=".",
toPDF = FALSE,
)

  1. HeatMap generation
hm.ALL <- doHMAnalysis(clustPar)

  1. Now it is easy to change paramters and re-draw the heatmap

    1. We can use a different colorset
  1. clustPar$colorsSet <- heat.colors(64)
  2. hm.ALL <- doHMAnalysis(clustPar)

    1. We can change the distance function for rows and/or columns
  1. clustPar$rowDistance = 'cor'
  2. clustPar$colDistance = 'minkowski'
  3. hm.ALL <- doHMAnalysis(clustPar)

    1. We can use a different dataset
  1. clustPar$expresFileName="expres.selected.ALL"
  2. hm.ALL <- doHMAnalysis(clustPar)



      1. Optional change 1: PDF generation server side
  1. # Imprimim a pdf
  2. # COMPTE: els arxius s'anomenen per defecte
  3. # el del heatmap: paste(paste("HM", comparisonName, sep=""),"pdf", sep=".")
  4. # el dels perfils: paste(paste("plotProfiles", comparisonName, sep=""),"pdf", sep=".")
  5. # el dels gens als clusters: paste(paste("genesInClusters", comparisonName, sep=""),"txt", sep=".")
  6. # Això es important de cara a descarregar-los des de l'aplicatiu web
  7. clustPar$toPDF<-TRUE
  8. clustPar$plotProfiles <-TRUE
  9. hm.ALL <- doHMAnalysis(clustPar)

      1. Optional change 2: Changingthecolour palette
  1. clustPar$toPDF<-FALSE
  2. clustPar$plotProfiles <-FALSE
  3. # We can try with other colour palettes
  4. colores1 <- heat.colors(64) # Veure a RColorBrewer altres formes
  5. colores2 <- redblue(64) # Veure a RColorBrewer altres formes
  6. colores3 <- greenred(16) # Veure a RColorBrewer altres formes
  7. colores4 <- topo.colors(64) # Veure a RColorBrewer altres formes
  8. colores5 <- terrain.colors (64)
  9. colores6 <- colorpanel(36, "green", "white", "red")
  10. colores7 <- rainbow(36)
  11. clustPar$toPDF<-FALSE
  12. clustPar$plotProfiles <-FALSE
  13. clustPar$colorsSet <-colores2
  14. hm.ALL <- doHMAnalysis(clustPar)

{RR}