######Video source: https://ke.biowolf.cn
######??????ѧ??: https://www.biowolf.cn/
######΢?Ź??ںţ?biowolf_cn
######???????䣺biowolf@foxmail.com
######????΢??: 18520221056

#if (!requireNamespace("BiocManager", quietly = TRUE))
#    install.packages("BiocManager")
#BiocManager::install("limma")

#if (!requireNamespace("BiocManager", quietly = TRUE))
    #install.packages("BiocManager")
#BiocManager::install("ConsensusClusterPlus")


#???ð?
library(limma)
library(ConsensusClusterPlus)

workDir="C:\\Users\\LZD\\Desktop\\THCA\\PANoptosis\\32.cluster"     #????Ŀ¼
setwd(workDir)

#??ȡ?????ļ????????????ļ?????????
rt=read.table("risk.all.txt", header=T, sep="\t", check.names=F, row.names=1)
data=rt[,(3:(ncol(rt)-2))]
data=t(data)

#????
maxK=9
results=ConsensusClusterPlus(data,
              maxK=maxK,
              reps=50,
              pItem=0.8,
              pFeature=1,
              title=workDir,
              clusterAlg="km",
              distance="euclidean",
              seed=123456,
              plot="png")

#????????
clusterNum=2         #?ּ??࣬???޸?
Cluster=results[[clusterNum]][["consensusClass"]]
outTab=cbind(rt, Cluster)
outTab[,"Cluster"]=paste0("C", outTab[,"Cluster"])
outTab=rbind(ID=colnames(outTab), outTab)
write.table(outTab, file="cluster.txt", sep="\t", quote=F, col.names=F)


######Video source: https://ke.biowolf.cn
######??????ѧ??: https://www.biowolf.cn/
######΢?Ź??ںţ?biowolf_cn
######???????䣺biowolf@foxmail.com
######????΢??: 18520221056

