mkatari-bioinformatics-august-2013-clustering
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| mkatari-bioinformatics-august-2013-clustering [2014/12/15 12:03] – mkatari | mkatari-bioinformatics-august-2013-clustering [2015/06/17 13:26] (current) – mkatari | ||
|---|---|---|---|
| Line 4: | Line 4: | ||
| ====== Clustering rna-seq data ====== | ====== Clustering rna-seq data ====== | ||
| continuation from [[mkatari-bioinformatics-august-2013-deseq|DESeq]] | continuation from [[mkatari-bioinformatics-august-2013-deseq|DESeq]] | ||
| + | |||
| + | [[https:// | ||
| + | [[https:// | ||
| + | |||
| + | In case you didn't get DESeq to work download and load the files above | ||
| + | |||
| + | < | ||
| + | resSig = read.table(" | ||
| + | normalized = read.table(" | ||
| + | |||
| + | </ | ||
| Get the significant genes | Get the significant genes | ||
| Line 12: | Line 23: | ||
| Get the normalized values for the significant genes | Get the normalized values for the significant genes | ||
| < | < | ||
| - | sigGenes.normalized = normalized[sigGenes, | + | sigGenes.normalized = normalized[as.character(sigGenes),] |
| </ | </ | ||
| Line 90: | Line 101: | ||
| < | < | ||
| - | SigGenes.kmeans.2 = kmeans(t(scaledSigGenes), 2, nstart=25) | + | SigGenes.kmeans.2 = kmeans(scaledSigGenes, |
| </ | </ | ||
| Line 107: | Line 118: | ||
| | | ||
| for (i in 2:20) { | for (i in 2:20) { | ||
| - | | + | |
| - | | + | #alternate way of looking at proportion of ss that is provided by between groups. |
| - | + | #kmeans_ss[i] = kmeans_tmp$betweenss/ | |
| + | |||
| + | # | ||
| + | | ||
| + | | ||
| + | |||
| } | } | ||
| return(kmeans_ss) | return(kmeans_ss) | ||
| Line 125: | Line 142: | ||
| + | The code below plots k-means clustering results. You simply have to provide the k-means output and the labels. | ||
| + | |||
| + | < | ||
| + | plotClusterCenters< | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | mycolors=c(" | ||
| + | centersdim = dim(kmeansres$centers) | ||
| + | plot(kmeansres$centers[1, | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | axis(1, at=c(1: | ||
| + | | ||
| + | for (i in 2: | ||
| + | lines(kmeansres$centers[i, | ||
| + | } | ||
| + | | ||
| + | } | ||
| + | |||
| + | |||
| + | plotClusterCenters(SigGenes.kmeans.2) | ||
| </ | </ | ||
| Line 132: | Line 179: | ||
| < | < | ||
| + | install.packages(" | ||
| library(gplots) | library(gplots) | ||
| </ | </ | ||
| Line 151: | Line 199: | ||
| < | < | ||
| pdf(" | pdf(" | ||
| - | heatmap.2(sigGenes.normalized, | + | heatmap.2(as.matrix(sigGenes.normalized), |
| col=redgreen(75), | col=redgreen(75), | ||
| hclustfun=hclust2, | hclustfun=hclust2, | ||
mkatari-bioinformatics-august-2013-clustering.1418644987.txt.gz · Last modified: by mkatari
