This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Heatmap of top 20 genes

I am working with a zebrafish dataset with the following columns.

geneid  baseMean    log2FoldChange  lfcSE   stat    pvalue  padj    mir99-1 mir99-2 mir99-3 KDR1    KDR2    KDR3    genename
ENSDARG00000087345  568.9632183 -6.20E+00   2.53E-01    -24.52506073    7.98E-133   1.39E-128   1184.991259 1155.817701 1040.461126 11.89199391 12.79560554 7.821623872 CABZ01059415.2
ENSDARG00000058371  2137.227454 -1.90E+00   1.23E-01    -15.45919908    6.54E-54    5.68E-50    3567.150951 3403.840003 3190.479638 928.7647244 838.1121628 895.0172459 krt5
ENSDARG00000026403  105.7002429 5.94E+00    3.91E-01    15.20933627 3.07E-52    1.77E-48    0.761073384 0   0.803444885 198.5962983 222.8567965 211.1838445 hephl1b
ENSDARG00000006427  307.5980773 -2.56E+00   1.69E-01    -15.1717102 5.44E-52    2.36E-48    571.5661114 502.4356798 515.8116161 84.43315677 85.30403692 86.03786259 fabp2
ENSDARG00000041381  211.673776  2.42E+00    1.77E-01    13.63946377 2.33E-42    8.10E-39    61.64694411 63.6131011  65.88248056 376.976207  345.4813495 356.4425736 arntl2
ENSDARG00000071601  644.7786927 -1.86E+00   1.46E-01    -12.6956589 6.25E-37    1.81E-33    1041.148389 1025.356935 983.4165391 229.5154825 295.3652278 293.8695826 pvalb9
ENSDARG00000054191  248.1707973 -2.73E+00   2.19E-01    -12.46919936    1.10E-35    2.73E-32    340.1998027 445.2917077 524.6495098 44.00037747 53.31502308 81.56836323 pgk1
ENSDARG00000098488  72.01580105 3.62E+00    2.96E-01    12.21415025 2.61E-34    5.67E-31    8.371807225 9.703693388 7.231003964 137.9471294 149.2820646 119.5591078 CABZ01118154.1
ENSDARG00000076129  134.0475054 2.89E+00    2.43E-01    11.89891469 1.20E-32    2.31E-29    14.4603943  42.04933801 30.53090563 241.4074764 236.7187025 239.1182155 si:dkey-108k21.17
ENSDARG00000035438  93.57767025 -3.06E+00   2.64E-01    -11.60017379    4.11E-31    7.14E-28    153.7368236 185.4483625 171.1337605 11.89199391 20.25970877 18.99537226 myhc4
ENSDARG00000010155  279.06936   1.87E+00    1.62E-01    11.54358934 7.95E-31    1.26E-27    107.3113472 115.3661325 126.9442918 468.5445601 436.1168888 420.1329394 abi1a
ENSDARG00000090039  98.78012873 -3.49E+00   3.04E-01    -11.47419245    1.78E-30    2.57E-27    128.6214019 174.666481  252.2816939 10.70279452 8.530403692 17.87799742 reck
ENSDARG00000061547  437.8935997 2.41E+00    2.16E-01    11.13186813 8.78E-29    1.17E-25    82.19592548 109.9751917 195.237107  727.7900273 762.40483   749.7585168 zgc:153409
ENSDARG00000035835  168.2611865 -2.43E+00   2.27E-01    -10.69600198    1.06E-26    1.32E-23    224.5166483 315.9091292 323.7882886 32.10838356 61.84542677 51.39924259 eef2k
ENSDARG00000103760  43.77828583 -4.51E+00   4.23E-01    -10.64650999    1.81E-26    2.10E-23    98.17846654 85.17686418 77.13070895 0   1.066300462 1.117374839 cfhl2
ENSDARG00000094300  162.8101355 -2.46E+00   2.32E-01    -10.61569008    2.52E-26    2.57E-23    306.7125738 264.1560978 268.3505916 23.78398782 49.04982123 64.80774065 NUPR1L
ENSDARG00000101393  196.2144366 -2.00E+00   1.89E-01    -10.62105025    2.38E-26    2.57E-23    344.766243  301.8926832 305.3090563 79.6763592  85.30403692 60.3382413  C6H17orf67
ENSDARG00000026369  559.9441682 -1.62E+00   1.53E-01    -10.53029815    6.26E-26    6.04E-23    881.3229787 852.8468299 816.3000031 217.6234886 293.2326269 298.339082  dbi
ENSDARG00000053990  1908.631378 -1.80E+00   1.72E-01    -10.47582276    1.12E-25    1.02E-22    2722.359495 2682.532128 3564.884954 614.8160852 908.4879932 958.7076117 hmgb2b
ENSDARG00000097615  81.17388891 -2.75E+00   2.65E-01    -10.40897787    2.26E-25    1.93E-22    139.2764293 141.2426482 151.8510832 13.0811933  18.12710785 23.46487161 si:ch211-108d22.2
ENSDARG00000100854  153.9825875 1.99E+00    1.91E-01    10.40561763 2.34E-25    1.93E-22    55.55835704 53.90940771 68.29281522 249.7318721 250.5806085 245.8224645 ago4
ENSDARG00000088330  2277.868137 -1.40E+00   1.36E-01    -10.24819681    1.21E-24    9.52E-22    3229.234369 3438.342024 3284.482689 1035.79267  1355.267887 1324.089184 si:ch211-5k11.2
ENSDARG00000052652  272.3044535 -1.77E+00   1.75E-01    -10.10878024    5.05E-24    3.81E-21    420.112508  368.7403487 486.0841554 105.8387458 129.0223558 124.0286071 fermt1
ENSDARG00000035326  83.09159923 -2.60E+00   2.58E-01    -10.0456011 9.61E-24    6.80E-21    166.6750711 131.5389548 137.3890753 21.40558904 19.19340831 22.34749678 nccrp1
ENSDARG00000035990  273.2937519 1.67E+00    1.66E-01    10.04368368 9.79E-24    6.80E-21    117.2053011 132.617143  132.568406  466.1661613 371.0725606 420.1329394 cited4a
ENSDARG00000001014  405.5070749 1.71E+00    1.71E-01    9.987688328 1.73E-23    1.15E-20    143.0817962 182.2137981 228.9817922 612.4376864 622.7194695 643.6079072 myh9b
ENSDARG00000017261  101.9226375 -2.58E+00   2.62E-01    -9.8202851  9.21E-23    5.71E-20    176.5690251 168.1973521 189.6129928 9.513595128 34.12161477 33.52124516 gdpd1
ENSDARG00000097601  49.84170742 -3.33E+00   3.39E-01    -9.822498879    9.01E-23    5.71E-20    93.61202624 85.17686418 101.2340555 4.756797564 5.331502308 8.93899871  dnajb9b
ENSDARG00000003641  232.8497019 -1.74E+00   1.77E-01    -9.789899787    1.24E-22    7.45E-20    383.5809856 324.5346344 376.0122061 88.00075494 108.7626471 116.2069832 tfg

I want to make the heatmap of the top 20 genes but instead of having Ensembl gene ids in the heatmap. I want to label the heatmap with the genename. The code to generate the heatmap is as follows.

library(pheatmap)
heatmap.data <- counts(dds)[topGenes,]
pheatmap(mat = heatmap.data)
pheatmap(mat = heatmap.data, scale = 'row')
colorScale <- colorRampPalette(c('navy','white','firebrick3'))
colorScale(30)
pheatmap(mat = heatmap.data, scale = 'row',
         color = colorScale(30),
         border_color = 'white',
         fontsize_col = 7,
         fontsize_row = 7,
         cluster_col = F, filename='ag2598_2wk_heatmap.png')
rna-seq

I want to make the heatmap of the top 20 genes but instead of having Ensembl gene ids in the heatmap. I want to label the heatmap with the genename. The code to generate the heatmap is as follows. How to go about it?

refer to labels_row function.

Exactly as cpad said, use labels_row argument within the pheatmap function to specify the column of the dataframe (genename) to use to label the rows of the heatmap. See ?pheatmap for more information.

0 answers

No answers yet.

Log in to answer this question.