HeatmapCluster: Heatmap of cluster based on top cluster specific genes

Usage Arguments Examples

Usage

1
HeatmapCluster(obj, top)

Arguments

obj

The list objective from the function getClusterGene

top

The number of gene which showed top cluster specificity

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
data(melanoma)
melanoma1=as.matrix(melanoma[,2:dim(melanoma)[2]])
row.names(melanoma1)=melanoma[,1]
res=ModalFilter(data=melanoma1,geneK=10,cellK=10)
res=GeneFilter(obj=res)
res=getMarker(obj=res,MNN=200,MNNIndex=20)
res=SCcluster(obj=res)
res=getClusterGene(obj=res,method="Seurat")
HeatmapCluster(obj=res,top=10)
## The function is currently defined as
HeatmapCluster<-function(obj,top,scale="none"){
    feature=obj$clustergene
    topmarker=as.data.frame(feature 
    topmarker=topmarker[order(topmarker$clusts),]
    method=obj$method
    if (method=="Seurat"){
        cluster=obj$seuratCluster
    }else if (method=="dbscan"){
        cluster=obj$dbscanCluster
    }
    clustertype=levels(factor(cluster))
    genemean=c()
    for (i in clustertype){
        cell=names(cluster[cluster==i])
        subdata=obj$rawdata[topmarker$gene,cell]
        genemean=cbind(genemean,apply(subdata,1,mean))
    }
    row.names(genemean)=topmarker$gene
    colnames(genemean)=clustertype
    
    mat_col <- data.frame(cluster=levels(factor(cluster)))
    row.names(mat_col) <- levels(factor(cluster))
    mat_colors <- list(cluster=rainbow(length(clustertype)))
    names(mat_colors$cluster)=levels(factor(cluster))
    pheatmap(genemean,cluster_cols = F,scale=scale,cluster_rows = F,show_colnames=F,annotation_col = mat_col,annotation_colors = mat_colors)
}


{ ~kwd1 }
{ ~kwd2 }

Fang0828/SCMarker documentation built on May 13, 2019, 12:51 p.m.