图片alt
#http://www.bioconductor.org/packages/release/bioc/html/ConsensusClusterPlus.html
BiocManager::install("ConsensusClusterPlus")
library(tidyverse)
library(ConsensusClusterPlus)
library(survival)
library(survminer)
matrix <- read_tsv("Cluster/tumor.tsv")
res <- ConsensusClusterPlus(as.matrix(matrix),
maxK=8,
reps=50,
pItem=0.8,
pFeature=1,
title="Cluster/fenxing",
clusterAlg="km",
distance="euclidean",
seed=123456,
plot="png")
cluster <- res[[2]][["consensusClass"]]
cluster_factor <- factor(cluster,levels = c(1,2,3),labels = c("cluster1","cluster2","cluster3"))
df <- data.frame(cluster_factor) |> rownames_to_column("samlpe")
write_tsv(df, file="Cluster/res_df.tsv")
cluster_df <- df %>%
mutate(patient_id = stringr::str_sub(samlpe, 1, 12),
tissue_type_id = stringr::str_sub(samlpe, 14, 15))
clinical <- read_tsv("Cluster/clinical.tsv")
View(clinical)
cluster_df_clinical <- inner_join(cluster_df, clinical,by="patient_id")
write_tsv(cluster_df_clinical, file="Cluster/cluster_df_clinical.tsv")
fit <- surv_fit(Surv(futime_year,fustat) ~ cluster_factor, data = cluster_df_clinical)
ggsurvplot(fit, conf.int=F, pval=T, risk.table=F,
legend.title='',
risk.table.height = 0.3,data = cluster_df_clinical)
图片alt
图片alt
图片alt
图片alt
图片alt
cluster_df_clinical <- inner_join(cluster_df, clinical,by="patient_id")