Last active
June 17, 2022 19:55
-
-
Save LeahBriscoe/e5eabfd5a0618e8bdd7d31bdcab66e0e to your computer and use it in GitHub Desktop.
Tutorial on how to create a heat map on RStudio
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| install.packages("gplots") | |
| installed.packages() | |
| library(gplots) # perform each time you start up RStudio | |
| getwd() | |
| x <- read.csv("NodGenes.csv", check.names=FALSE) | |
| y <- data.matrix(NodGenes) | |
| y | |
| ?heatmap.2 | |
| heatmap.2(y, main = "Sample", trace= "none", margins = c(10,12), cexRow=0.5, Rowv=FALSE,Colv=FALSE, key) | |
| ?colorRampPalette | |
| yb <- colorRampPalette(c("yellow","white","darkblue")) | |
| heatmap.2(y, col= yb, main = "BetterTitle", trace= "none", margins = c(8,12), cexRow=0.5, Rowv=FALSE,Colv=FALSE, key=FALSE) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello,

I need help, I'm new to Rstudio and have built a heatmap but I can't seem to set up groups next to the rows and columns. Please I want something like this heatmap
Thanks for your help
#Design of the data as an example
#------------------------------------
Data <- data.frame(replicate(6,sample(0:1,6,rep=TRUE)))
row.names(Data) <- c('Gene1','Gene2','Gene3','Gene4','Gene5','Gene6')
colnames(Data) <- c("Strain1", "Strain2", "Strain3", "Strain4", "Strain5", "Strain6")
pheatmap(Data, color=colorRampPalette(c("#FFE4B5","#708090"))(2),
legend_breaks = c(1, 0),
legend_labels = c("Presence", "Absence"),
border_color = "black", display_numbers = FALSE,
number_color = "black",
fontsize_number = 8)
#Now I want to create Groups (Row) ##To designate that they are part of the same antibiotic family##
#Groupe1 "Gene3 and Gene6"
#Groupe2 "Gene1 and Gene5"
#Groupe3 "Gene2 and Gene4"
#How can I do this?
#Same question if I want to create Groupes for column ##To designate that they are part of the same bacterial genus#
#Band1 "Strain1" and "Strain3"
#Band2 "Strain4" and "Strain5"
#Band3 "Strain2" and "Strain6"