[R] Question: how to obtain the clusters of genes (basically the ones in the row dendrograms) from an object obtained by heatmap.2 function

Michael Bedward michael.bedward at gmail.com
Fri Sep 17 08:32:45 CEST 2010


Hello Sunny,

Defining groups at a given height can be done with the cut function
(see ?cut.dendrogram).

Unfortunately, cut doesn't give you the option of specifying a number
of clusters rather than a height in the way that cutree does for
"hclust" objects. Perhaps someone else here knows of a package that
includes a function to do this (I did a quick sos search but didn't
find anything obvious).  Otherwise you could examine the cut function
and try to hack a version that takes number of groups as an argument.
You can see the function's code with the command getS3method("cut",
"dendrogram").

Sorry I can't help more. Being a simple soul I find hclust objects so
much easier to deal with !

Michael


On 17 September 2010 11:30, Sunny Srivastava <research.baba at gmail.com> wrote:
> Hello R-Helpers,
> I have a question about extracting the clusters of genes after we make the
> heatmap (say ht4) using the heatmap.2 function. Basically, I want to get the
> clusters which are shown as row dendrogram in the heatmap.
>
> I understand that ht4$rowDendrogram is an object of dendrogram and it
> containes details of all the nodes and branches, but lets say I want to know
> the number of clusters and the genes in each cluster if I terminated the
> tree (dendrogram) at a particular height. Also, if I know that I want 12
> clusters, how do I know which height I should terminate the tree (or
> branching structure)
>
> I am sorry if I am not clear. Please let me know if you need any further
> clarifications. Thanks in advance for your help.
>
> Best Regards,
> S.
>
> PS: I had posted this question on the Bioconductor mailing list, but no one
> responded with the answer about my problem (some suggested to use other
> package). Probably this is more related to R, so I am reposting here.
>
>
>
> Below is the dump of the matrix *row.scaled.fc2* and the object *ht4* which
> was obtained by using the heatmap.2 function.
>
> -------------------------------------------------------------------------------------------------------------------------------------------------
> Dump of the matrix row.scaled.fc2 of dimension 47X4 for which I need to get
> the cluster
> -------------------------------------------------------------------------------------------------------------------------------------------------
> row.scaled.fc2 <-
>    structure(c(1.28370586906697, 0.045882176168387, -1.36708804887146,
>                0.521861081643557, 0.931917365795697, -1.26811754842825,
> -0.72130612803134,
>                0.997233560332114, 1.10914280037357, 0.906822512746599,
> 0.124305385892705,
>                0.243716750638903, -0.81506628597585, 0.9281945227055,
> -1.02514155647985,
>                -0.0148828263869010, 0.610771143828774, -1.31512789127346,
> -1.03419747081316,
>                -1.37364737258546, 1.25426184614502, -0.901983912371582,
> 1.39208493297302,
>                1.46330419386939, 1.46904838309704, 1.33893188130515,
> 1.19407808189758,
>                1.2218547353343, 1.19698274357976, 1.18155526998177,
> 0.841732283108634,
>                0.747807260442244, 0.714318042078153, -1.33532716080095,
> -0.313607205847584,
>                0.355541486307312, -0.116351310506438, 0.77912190137299,
> 1.19372966187956,
>                -1.46614749631243, 1.05871763558761, -0.943184299406566,
> 1.03714731356991,
>                1.25047276064487, 0.851530489918317, 0.97326112450597,
> 0.776853817614179,
>                0.254354524536168, 1.31978778177031, 1.03174081073449,
> 1.03284070831524,
>                0.653353551741362, -0.215733545477378, -0.966047927590969,
> 0.652368565446036,
>                0.536560120952493, 0.807139899513123, 1.26763097889282,
> 1.28335333872251,
>                1.45704025225707, 0.57691754078049, 1.07113369815538,
> 0.610158458070122,
>                -0.762088920575592, 1.00819322156949, 1.14148232415467,
> 0.297815716619546,
>                0.143195107796418, -0.0065855621849476, 0.062650188298147,
> -0.177601977084224,
>                -0.437288024655434, 0.178377570495840, 0.447251122498145,
> 0.400521563178456,
>                0.441487949431983, 0.465093691295555, 0.754248218272813,
> 0.657576754588525,
>                0.832332574891687, -0.194585070239614, 1.09572866565514,
> 1.04256940502540,
>                0.583290457043162, 0.947182223637108, 0.453501818870319,
> 0.362539212141846,
>                0.64658837487362, 0.778492522245523, 0.406650195058153,
> -0.113538768459753,
>                0.596257630693658, 0.652082611403661, 0.731202922578465,
> -0.540351240198989,
>                -0.280636135117373, 0.0957282195118376, -0.301771114678491,
> -0.319287162711085,
>                0.392333008215492, 0.595799016736027, -0.493631246722725,
> -0.570129842719142,
>                -0.687622802632555, -0.243797611378268, -0.510913960310597,
> -0.263387651214153,
>                -0.172495725682589, 0.609736001727743, 0.809229072877685,
> 1.08430415610192,
>                0.475088705288397, 0.503896215545131, 0.0658502505817462,
> -0.235112572720005,
>                1.39599392995549, -0.73223360450103, -0.661334598551208,
> -0.759202304177765,
>                -0.86894723087327, -0.9372047007794, -0.93488345268835,
> -0.941766151100918,
>                -0.949595224394993, -1.27181485347646, -1.41712359913304,
> -1.32146222297309,
>                0.698917086441383, 0.444155476463272, -0.0629413619565949,
> 0.892855986235108,
>                -0.809524028729025, -0.903176468889435, 0.786326226622549,
> -0.793466237636563,
>                0.945708813261833, -0.123281411659495, 0.0548777607029143,
> -0.0638457887809093,
>                -1.20425833446000, -1.35599301451107, -0.997709153404147,
> -1.08503382282132,
>                0.239619018625132, -1.25293067528031, -1.26598375482597,
> 1.09151808569014,
>                1.09155503888627, -1.15597087905543, -1.07557307860692,
> -1.02633960962716,
>                -1.14813875340725, -1.01615612905082, -0.378586315067078,
> -1.33261633780340,
>                -0.655728143403281, -1.40450470456092, -0.932986379355095,
> -0.168154035584431,
>                -0.611181068886636, 1.00998140538417, -1.16234438122143,
> -0.487424455398969,
>                -0.722501516770135, -0.624367618233957, -0.272558054263839,
> -0.648362220927723,
>                -0.704124503616327, -0.687492845824406, -0.696704541910826,
> -0.697053736882326,
>                -0.324165647904986, 0.0117395841022768, -0.225188393996755,
> 0.830995144599174,
>                -1.22627693627083, -1.33516952937611, -1.35979513277183,
> -0.91678009628107,
>                -0.744055011860442, 0.317282057548041, -0.911839772824668,
> -0.78101703610078,
>                -1.32051609696858, -1.19181175288804, -1.38394233183106,
> -0.421085401449625,
>                -0.152063725681571), .Dim = c(47L, 4L), .Dimnames =
> list(c("pSysX_130",
>                                                        "pSysX_48",
> "pSysX_49", "pSysX_50", "sll0108", "sll0327", "sll0685",
>                                                        "sll0735",
> "sll0781", "sll0783", "sll0788", "sll0789", "sll0790",
>                                                        "sll1130",
> "sll1450", "sll1507", "sll1621", "sll1694", "sll1695",
>                                                        "sll1796",
> "sll1814", "sll1891", "slr0041", "slr0042", "slr0043",
>                                                        "slr0044",
> "slr0144", "slr0145", "slr0146", "slr0147", "slr0737",
>                                                        "slr0749",
> "slr0750", "slr0853", "slr0898", "slr1236", "slr1251",
>                                                        "slr1603",
> "slr1634", "slr1675", "slr1930", "slr1984", "smr0003",
>                                                        "ssl2148",
> "ssl2245", "ssr0390", "ssr1251"), c("l1", "d1", "l13",
>
>                          "d13")))
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list