How to create a heatmap in R with geom_tile and geom_text from ggplot2 (CC105)

Поділитися
Вставка
  • Опубліковано 11 гру 2024

КОМЕНТАРІ • 52

  • @meronghirmay4960
    @meronghirmay4960 4 місяці тому +1

    Three years since this video was posted, and here I am too making a nice figure. And this is not the only video that has helped me. Thank you very much, Dr Schloss.

    • @Riffomonas
      @Riffomonas  4 місяці тому

      Hah! Thanks so much for watching. I'm glad you're finding my videos helpful 🤓

  • @CalvinTeddy
    @CalvinTeddy 24 дні тому

    Without your videos some of our research work wouldn't have been easy to explain Dr Schloss., Thank you a tone

    • @Riffomonas
      @Riffomonas  23 дні тому

      My pleasure! Thanks for watching 🤓

  • @alba-2460
    @alba-2460 Рік тому +1

    Two years since this video was posted and here i am trying to make a descent figure for my thesis. Thank you Dr Schloss

  • @coralpardo8825
    @coralpardo8825 3 роки тому +3

    It is so true, a heatmap ends up being a table... But with colors, so its prettier? lol. Loving code club, as a beginner this is so helpful

    • @Riffomonas
      @Riffomonas  3 роки тому +1

      Thanks, Coral - glad to have you following along!

  • @nakitacally4612
    @nakitacally4612 2 роки тому

    This video is amazing! I have very little experience with R - only 2.5 courses throughout my degree, so this video has helped me so much in understanding easily what each function is helping me to achieve. I feel like I have the power to control my graphs visually now and this is such a great feeling! Thank you, Pat. 🙏

    • @Riffomonas
      @Riffomonas  2 роки тому

      My pleasure! Thanks for watching 🤓

  • @teunvandenbrand1324
    @teunvandenbrand1324 3 роки тому +3

    I like the dual-hue colour gradients, it encodes the value from light to dark (so colourblind friendly) and from one hue to another. The colorspace and colorbrewer packages have some nice multi-hue sequential palettes.

  • @RasmusKirkegaard
    @RasmusKirkegaard 3 роки тому +1

    Yet another great episode 😁👍

  • @smethyyyy
    @smethyyyy 6 місяців тому

    Great video as always

    • @Riffomonas
      @Riffomonas  6 місяців тому

      Thanks for tuning in!

  • @kunalkunde7744
    @kunalkunde7744 3 роки тому +1

    Great tutorial!

  • @hwbtafrsca
    @hwbtafrsca 3 роки тому +1

    The true power of heatmaps is only realized when they are combined with clustering approaches. This is more relevant when the data you are working with has a greater number of features/conditions to visualize.

    • @Riffomonas
      @Riffomonas  3 роки тому +1

      Hi Stephen - thanks for the comment. Great point! I do wonder though if that makes it better for a data exploration than presentation mode. Granted, not all heat maps with dendrograms are created equal. I've seen too many radial dendrograms recently with heat maps as circles around the dendrograms. There's so many wedges and lack of structure to the data that I'm left thinking, "pretty! but what does it say?" I appreciate your comment - I'll come back to rectangle heat maps and will show how to order the rows/columns with dendrograms

  • @TheBpnrml
    @TheBpnrml 3 роки тому +1

    The start... Poetry!!!

    • @Riffomonas
      @Riffomonas  3 роки тому

      HAHA! Thanks for watching ;)

  • @ptfdasdcasr
    @ptfdasdcasr 2 роки тому +1

    How do you pass-by (#) multiple lines simultaneously like you did at 4:53?

    • @Riffomonas
      @Riffomonas  2 роки тому +1

      Pressing cmd enter runs lines and pipelines. I think it also skips over comment chunks

    • @ptfdasdcasr
      @ptfdasdcasr 2 роки тому

      @@Riffomonas Brilliant, thanks for that

  • @saadalhumaid3959
    @saadalhumaid3959 2 роки тому +1

    V useful thank u

  • @askingsimplequestionswhat8894
    @askingsimplequestionswhat8894 3 роки тому +1

    I believe I have an exception to the rule. I'll tag you on Twitter when our paper comes out (still a work in progress) to see if one of our supplemental figures changes your mind! 😉

    • @Riffomonas
      @Riffomonas  3 роки тому

      Awesome - please do!

    • @wanluouyang
      @wanluouyang 2 роки тому

      Wow, I am really interested in your figs! Would you mind sharing the doi or link here, if it is published or posted?

  • @aas401
    @aas401 Рік тому

    That was really helpful thank you so much!
    Question, why did you set the maximum abundance less than 3%? why 3%?
    Thank you!

  • @Irene-dw7qt
    @Irene-dw7qt 3 роки тому +1

    Hi Pat, thanks for your videos they are really helpful I am plotting my microbiome data using your videos and I am a newbie coder and a newbie in the microbiome world. I was wondering what you thought about "Blanks" and including these in plots. I replicated this heat map with my data: two "sample_types" with a "disease status" either positive or negative" and my blank. Had to use coord_cartesian instead to allow, scale="free_x" inside the facet_grid but it worked!

    • @Riffomonas
      @Riffomonas  3 роки тому

      That's an interesting idea. You mean as a way to show that things in a negative control weren't what you found in your samples?

    • @Irene-dw7qt
      @Irene-dw7qt 3 роки тому +1

      @@Riffomonas Blanks/controls that you include alongside your sample extractions and may indicate the "potential" level of contamination.

  • @KN-tx7sd
    @KN-tx7sd 3 роки тому +1

    Hi Pat, not sure if I'm asking the right question. Will it be possible to represent heatmaps as chord diagrams with different layers, say one layer with heat map, second layer as box plot etc? And also by showing their correlation inside the chord diagram. I have seen packages like 'circlize' which are not user-friendly, but the way you explain is so easy to follow. Thanks

    • @Riffomonas
      @Riffomonas  3 роки тому

      I’m sure there is - it’s not something I’ve done. I’m not a big fan of circles 😂

  • @nakitacally4612
    @nakitacally4612 2 роки тому +1

    The only improvement I might ask for is to put data in only some of the squares rather than all of them i.e. for anything that has significance, you could add * , ** , or "***" (or even the number) - how would you do this?

    • @Riffomonas
      @Riffomonas  2 роки тому +1

      Interesting idea! I'm not a fan of *s, but if you only wanted to show the abundances for where there were significant differences, you could use geom_text to plot the values and for those where there wasn't a significant difference you could replace the number with an empty string

    • @nakitacally4612
      @nakitacally4612 2 роки тому

      @@Riffomonas thank you!

  • @mukhtarabdi824
    @mukhtarabdi824 2 роки тому +1

    Hi Prof, the code related to this heatmap tutorial cannot be found in the accompanying blog post.
    When I click the link, the code available in there is the code for the Grouped stacked barchart tutorial.
    Could you fix this and put the code the right code in the blog post, please?
    Thank you

    • @Riffomonas
      @Riffomonas  2 роки тому +1

      Thanks for watching! Yeah I think that was the code at the start of the episode. You’ll have to watch along with the video to get the code for the heatmap

  • @jennifergrinder2602
    @jennifergrinder2602 2 роки тому +1

    I'm getting an error message: "could not find function "ggsave". I went to install it but it is not an option. I have the newest version of R and R studio. Any advice would be greatly appreciated!

    • @Riffomonas
      @Riffomonas  2 роки тому

      Are you sure you ran library(tidyverse)? You should also double check that you don’t have other errors earlier in the script. Ggsave comes from ggplot2 so if you’re missing ggsave you should be missing other stuff too

  • @sarahzekovich7656
    @sarahzekovich7656 3 роки тому +1

    Does anyone know how you would change the font size of the phylum on the heat map?

    • @Riffomonas
      @Riffomonas  3 роки тому

      You can use the theme function with the axis labels y argument

  • @dhanushka1461
    @dhanushka1461 2 роки тому +1

    which package do i need to download for the heat map

    • @Riffomonas
      @Riffomonas  2 роки тому

      Thanks for watching. It’s all ggplot2 which you can get when you install the tidyverse

  • @freistein6596
    @freistein6596 Рік тому

    Great video! what I cannot seem to figure out is how to change the order of my variables on the y-axis. I reordered them according to their taxonomic class but when I plot them the default stack them right back to alphabetic order. So first how can I prevent this from happening and is there a way to link the order to the information in a different dataframe? Anyone got an idea? Would be awesome!

  • @mcdonald6284
    @mcdonald6284 2 роки тому +1

    Error in library(ggtext) : there is no package called ‘ggtext’

    • @Riffomonas
      @Riffomonas  2 роки тому

      Make sure you install it first

  • @cristianjaviermena6955
    @cristianjaviermena6955 Рік тому

    Genius!!!

  • @wanluouyang
    @wanluouyang 2 роки тому +1

    Very helpful! Really appreciate. I also learned some unexpected tips about how to handle the long item names in ggplot 😁BTW, have you compared the geom_tile and heatmap functions? I googled the answers, and they are not quite clear to me.

    • @Riffomonas
      @Riffomonas  2 роки тому

      I used heatmap and heatmap2 a long time ago and found them pretty limiting. I always had to rewrite the underlying heatmap code to do what I wanted. I like how geom_tile works well with ggplot2 stuff 🤷‍♂️