# Clear the workspace rm(list = ls()) # Load required packages library(corrplot) scoreFile = "score.txt" # Score file immFile = "ssGSEA.result.txt" # ssGSEA result file # Read m6A score file score = read.table(scoreFile, header = T, sep = "\t", check.names = F, row.names = 1) colnames(score) = "score" # Read immune cell file immune = read.table(immFile, header = T, sep = "\t", check.names = F, row.names = 1) library(tidyverse) rownames(immune) = str_replace_all(rownames(immune), "na", "") immune = t(immune) # Merge data sameSample = intersect(row.names(score), row.names(immune)) data = cbind(score[sameSample,,drop=F], immune[sameSample,,drop=F]) # Calculate the correlation matrix M = cor(data) res1 = cor.mtest(data, conf.level = 0.95) # Create a correlation plot pdf(file = "cor.pdf", width = 8, height = 8) corrplot(M, order = "original", method = "circle", type = "upper", tl.cex = 0.8, pch = T, p.mat = res1$p, insig = "label_sig", pch.cex = 1.6, sig.level = 0.05, number.cex = 1, col = colorRampPalette(c("yellow", "white", "red"))(50), tl.col = "black") dev.off()