ID r1 r2 r3
1 68.46 65.86 65.08
2 38.89 37.61 39.09
3 59.2 63.34 28.33
4 27.3 20.33 24.11
5 15.24 18.77 1.79
6 66.97 35.46 0
7 62.94 56.82 79.53
8 32.49 25.61 0.53
9 57.69 36.33 20.36
10 26.6 17.58 39.25
11 17.4 15.62 1.47
12 37.26 51.14 67.65
13 12.52 19.26 11.97
源数据一共是31行34列,现在是想除了第一列之外,剩下的33列排列组合选取两列作图,比如1、2、3或者1、2、4等,我试着用1、3、5列画图:
- data<-read.csv('C:/Users/elain/Desktop/ZDW_MET_1.csv',header=T)
- #calculate Correlation coefficient
- data1<-data[,-1]
- cormat <- round(cor(data1,use="pairwise.complete.obs"),2)
- # plot
- test<-data[,c(1,3,5)]
- test<-melt(test,id.vars = "ID",variable.name = "region",value.name = "methy")
- test<-rename(test,c(ID="sample"))
- test<-rename(test,c(variable="region"))
- test<-rename(test,c(value="methy"))
- test =na.omit(test)
- labels = paste("P_value=",cormat[2,4])
- ggplot(test, aes(x=sample, y=methy,colour=region)) +
- geom_point() +
- stat_smooth(method=lm,se=FALSE) +
- theme_classic() +
- annotate("text",x=-Inf,y=Inf,label=labels,hjust=-.2,vjust=2)
- ggsave('C:/Users/elain/Desktop/r2_r4.png')