Last data update: 2014.03.03

R: Function to do k-means cluster analysis
kmeansMdeR Documentation

Function to do k-means cluster analysis

Description

This is a function to do k-means clustering analysis for objects of class maigesDEcluster.

Usage

kmeansMde(data, group=c("C", "R")[1], distance="correlation",
          method="complete", sampleT=NULL, doHier=FALSE, sLabelID="SAMPLE",
          gLabelID="GeneName", idxTest=1, adjP="none", nDEgenes=0.05, ...)

Arguments

data

object of class maigesDEcluster.

group

character string giving the type of grouping: by rows 'R' or columns 'C' (default).

distance

char string giving the type of distance to use. Here we use the function Dist and the possible values are 'euclidean', 'maximum', 'manhattan', 'canberra', 'binary', 'pearson', 'correlation' (default) and 'spearman'.

method

char string specifying the linkage method for the hierarchical cluster. Possible values are 'ward', 'single', 'complete' (default), 'average', 'mcquitty', 'median' or 'centroid'

sampleT

list with 2 vectors. The first one specify the first letter of different sample types to be coloured by distinct colours, that are given in the second vector. If NULL (default) no colour is used.

doHier

logical indicating if you want to do the hierarchical branch in the opposite dimension of clustering. Defaults to FALSE.

sLabelID

character string specifying the sample label ID to be used to label the samples.

gLabelID

character string specifying the gene label ID to be used to label the genes.

idxTest

numerical index of the test to be used to sort the genes when clustering objects of class maigesDEcluster.

adjP

string specifying the method of p-value adjustment. May be 'none', 'Bonferroni', 'Holm', 'Hochberg', 'SidakSS', 'SidakSD', 'BH', 'BY'.

nDEgenes

number of DE genes to be selected. If a real number in (0,1) all genes with p.value <= nDEgenes will be used. If an integer, the nDEgenes genes with smaller p-values will be used.

...

additional parameters for Kmeans function.

Details

This function implements the k-means clustering method for objects resulted from differential analysis. The method uses the function Kmeans from package amap. For the adjustment of p-values in the selection of genes differentially expressed, we use the function mt.rawp2adjp from package multtest.

Value

This function display the heatmaps and return invisibly a list resulted from the function Kmeans.

Author(s)

Gustavo H. Esteves <gesteves@vision.ime.usp.br>

See Also

Kmeans from package amap. mt.rawp2adjp from package multtest. somM and hierM for displaying SOM and hierarchical clusters, respectively.

Examples

## Loading the dataset
data(gastro)

## Doing bootstrap from t statistic test fot 'Type' sample label, k=1000
## specifies one thousand bootstraps
gastro.ttest = deGenes2by2Ttest(gastro.summ, sLabelID="Type")

## K-means cluster with 2 groups adjusting p-values by FDR, and showing all genes
## with p-value < 0.05
kmeansMde(gastro.ttest, sLabelID="Type", adjP="BH", nDEgenes=0.05, centers=2)

## K-means cluster with 3 groups adjusting p-values by FDR, and showing all genes
## with p-value < 0.05
kmeansMde(gastro.ttest, sLabelID="Type", adjP="BH", nDEgenes=0.05, centers=3)

dev.off()

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(maigesPack)
Loading required package: convert
Loading required package: Biobase
Loading required package: BiocGenerics
Loading required package: parallel

Attaching package: 'BiocGenerics'

The following objects are masked from 'package:parallel':

    clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
    clusterExport, clusterMap, parApply, parCapply, parLapply,
    parLapplyLB, parRapply, parSapply, parSapplyLB

The following objects are masked from 'package:stats':

    IQR, mad, xtabs

The following objects are masked from 'package:base':

    Filter, Find, Map, Position, Reduce, anyDuplicated, append,
    as.data.frame, cbind, colnames, do.call, duplicated, eval, evalq,
    get, grep, grepl, intersect, is.unsorted, lapply, lengths, mapply,
    match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, rank,
    rbind, rownames, sapply, setdiff, sort, table, tapply, union,
    unique, unsplit

Welcome to Bioconductor

    Vignettes contain introductory material; view with
    'browseVignettes()'. To cite Bioconductor, see
    'citation("Biobase")', and for packages 'citation("pkgname")'.

Loading required package: limma

Attaching package: 'limma'

The following object is masked from 'package:BiocGenerics':

    plotMA

Loading required package: marray
Loading required package: graph
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/maigesPack/kmeansMde.Rd_%03d_medium.png", width=480, height=480)
> ### Name: kmeansMde
> ### Title: Function to do k-means cluster analysis
> ### Aliases: kmeansMde
> ### Keywords: hplot
> 
> ### ** Examples
> 
> ## Loading the dataset
> data(gastro)
> 
> ## Doing bootstrap from t statistic test fot 'Type' sample label, k=1000
> ## specifies one thousand bootstraps
> gastro.ttest = deGenes2by2Ttest(gastro.summ, sLabelID="Type")
> 
> ## K-means cluster with 2 groups adjusting p-values by FDR, and showing all genes
> ## with p-value < 0.05
> kmeansMde(gastro.ttest, sLabelID="Type", adjP="BH", nDEgenes=0.05, centers=2)
> 
> ## K-means cluster with 3 groups adjusting p-values by FDR, and showing all genes
> ## with p-value < 0.05
> kmeansMde(gastro.ttest, sLabelID="Type", adjP="BH", nDEgenes=0.05, centers=3)
> 
> dev.off()
null device 
          1 
> 
> 
> 
> 
> 
> dev.off()
Error in dev.off() : cannot shut down device 1 (the null device)
Execution halted