Make a Heatmap on R Studio

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
okay hi um so today we're going to show you how to make a heat map in art mm-hmm so this is assuming you already have some basics basic knowledge of our and you've already installed it on your computer you can get it both on Mac and PC um so um I have some sample data so we're going to go through how to make a heat map so there's many kinds of heat maps you can make the one we're going to do comes from the package called G plots so in order to use that package we need to first download it so I'm going to install the package okay so here we go install G plots doing that a pack hmm faster let's be good no so I guess it's downloading again um I might have already had it that's why okay so this installed it so if you want to check which packages you have installed already you can check so you should see it down here on the console G plots here we are it's right here and it doesn't need any compilation you don't need to compile so that's what it says no um okay and then a good thing to remember every time you want to use this package G plots you need to bring it up to into your library so you have to have this command library G plots every time you restart our studio you need to do this so that you have it ready to go um and so I'll have a note okay and you can check what directory directory we're in I think we're in the right directory okay so yeah so there's two ways you can download your data um can either import the data set or you can do it by command line um so I'll just do it that way so okay okay that's the name of my file and I'm going to do something called dot check names to prevent my to prevent our from replacing the spaces in my row names with periods so if I do it without and I check what it looks like um it's actually good but sometimes they replace the spaces right here with periods uh so you want to do Chuck names in a situation okay and so you can upload your data like this or there's an easier way you can do just upload it like normally and you can tell it that you want the header to be saved just calm not I'd show you they went okay yeah so now we're going to convert a two data matrix okay and also data matrix and now we can make the heat map so if you want to know what how to use this function just have a question mark and heat map dot - and right here it will tell you how to use this so it tells you what kind of parameters and needs um what kind of colors you want to use yeah and so now we're going to use it okay okay so main is where you put your title so title or whatever title you want and then trace trace you'll see it's optional well put we'll just put none okay and you can set the margin so the margins are important um I'm going to do 10 tall because I know that's what works I'll do margin of 10 and 12 um and something yeah okay so here's your heat map it's right here as you can see it doesn't really scrunched up right here and it didn't keep the names of my species so I think I need to upload the data again so let me try not okay so this is the data okay so now let me see if it couldn't do okay that's good it actually this time I saved my real names so I mean you probably just want to import data set it's a lot easier so heat map that to not jeans so now sorry okay okay there we go now has all the names so it's still really hard to read so I'm going to change the font size so you can do that using cex zero okay that's better it's a little bit smaller let's change so it's a lot of just trial and error see what works cosmetically and just a couple other functions you can change so you can say you can remove the dendrogram so if you look there's these there's this clustering sometimes you don't want clustering so I'm going to remove clustering from the rows and columns so I'll do okay now there's no dendrograms so there's no clustering either they go together okay so now what I just did was I removed the key I didn't want it there so I just said key equals false and so it takes away the color key on histogram but it often gives you a warning but don't worry about that um so you also might want to personalize your colors so that's a really good thing to know how to do by default the colors are red and yellow and if you have the key up tells you what each color means so here yellow was supposed to mean the highest percentages red was the lowest so say I want to change it to something more friendly to those who are colorblind so I'll do yellow and blue so YB was just a name I decided to designate my color palette so color ramp palette so I think if this isn't a library so you may want to download this library here um so color ramp palette so I'm going to make a color palette and you make a vector that consists of which colors you want to use so here I want to use yellow as an indicator for low percentages and I want to use blue for high okay so now I can run the heatmap command again this time my color that's actually Cole Cole equals Y V and now it's a blue and yellow and you can even designate like a middle color to like white so that might be a little bit more attractive and there's actually if you look online if you look up color palettes and are there's lots of different kinds of color names you can choose from I don't know if I have any good examples but I think you can be like dark blue if that works yeah so you get a darker blue there's many colors to choose from and so once you make your heat map and you've modified it in all the ways you like take away the key maybe have a better title okay then you want to export so you can either save as an image or you can save as a PDF okay yeah so here it is and that's how you make your heat map
Info
Channel: HowToDataViz
Views: 86,942
Rating: 4.6654806 out of 5
Keywords: RStudio, gplots, heatmap.2
Id: QD3XAla94rQ
Channel Id: undefined
Length: 13min 14sec (794 seconds)
Published: Sat Feb 06 2016
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.