[R] How to plot dendogram based on samples ID

David Carlson dc@r|@on @end|ng |rom t@mu@edu
Sat Jun 8 21:19:05 CEST 2019


Neither ContigID nor sampleID are defined in your example. The default
is to plot by the row names. You can get the manual page for the
dendrogram plot using the command ?plot.hclust. The second argument
lets you specify the labels.

David L Carlson, retired
Department of Anthropology
Texas A&M University


On Sat, Jun 8, 2019 at 4:48 AM Yogesh Gupta <nabiyogesh using gmail.com> wrote:
>
> Hi,
>
> I do have RNAseq  FPKM count and interested in dendrogram for samples
> cluster.
>
> I used below code but it generate dendogram based on ContigID instead of
> sampleID.
>
> > countMatrix = read.table("Trinity_trans.counts.matrix.txt",header=T,sep='\t',check.names=F,row.names=1)
> > dim(countMatrix)
> [1] 142686      6
> > head(countMatrix)
>
>                           AS_0DAP AS_4DAP AS_8DAP NMK_0DAP NMK_4DAP NMK_8DAP
>
> TRINITY_DN17944_c0_g1_i11   14.32   24.63    8.21     4.54       20     8.49
>
> TRINITY_DN7591_c0_g1_i1      0.00    0.00    1.00     3.00        3     0.00
>
> TRINITY_DN28918_c0_g1_i1     1.00    2.00    1.00     0.00        2     0.00
>
> TRINITY_DN14082_c2_g2_i5     6.00    5.00    1.00     0.00        1     0.00
>
> TRINITY_DN31994_c0_g1_i1     1.00    2.00    0.00     0.00        0     3.00
>
> TRINITY_DN19560_c0_g1_i1     1.00    3.00    0.00     0.00        1     1.00
> > rv <- rowVars(countMatrix)
> > summary(rv)
>
>      Min.   1st Qu.    Median      Mean   3rd Qu.      Max.
>
> 0.000e+00 1.000e+00 1.500e+01 3.570e+05 5.180e+02 4.122e+09
>
> > (q75 <-quantile(rowVars(countMatrix), .75))
>      75%
>
> 518.3202
> > m2 <- countMatrix[rv >q75, ]
> > dim(m2)
> [1] 35672     6
> > summary(rowVars(m2))
>
>      Min.   1st Qu.    Median      Mean   3rd Qu.      Max.
>
> 5.180e+02 1.670e+03 6.677e+03 1.428e+06 4.101e+04 4.122e+09
> > d <- dist(m2, method="euclidean")
> > h <-hclust(d, method="complete")
> > plot(h)
>
> Kind Regards
> Yogesh
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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