-
Notifications
You must be signed in to change notification settings - Fork 0
/
step2_immune.R
1781 lines (1527 loc) · 72.1 KB
/
step2_immune.R
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
###immune cell algorithm1####
standarize.fun <- function(indata=NULL, halfwidth=NULL, centerFlag=T, scaleFlag=T) {
outdata=t(scale(t(indata), center=centerFlag, scale=scaleFlag))
if (!is.null(halfwidth)) {
outdata[outdata>halfwidth]=halfwidth
outdata[outdata<(-halfwidth)]= -halfwidth
}
return(outdata)
}
hmdat <- read.csv("/t8a/2022backup/xuzijun/vip39/huitu/FigureYa230immunelandscape/easy_input.csv",row.names = 1,check.names = F,stringsAsFactors = F,header = T)
type <- read.csv("/t8a/2022backup/xuzijun/vip39/huitu/FigureYa230immunelandscape/easy_input_type.csv", row.names = 1)
head(type)
table(rownames(sub)%in%rownames(hmdat))
comsam <- rownames(sub)
hmdat <- hmdat[comsam,]
risk <- sub[comsam,,drop = F]
dim(hmdat)
# 拆分不同算法结果,获得类的名字
#immMethod <- sapply(strsplit(colnames(hmdat),"_",fixed = T),"[",2) #用easy_input.csv列名里的算法信息
immMethod <- type$Methods # 用easy_input_type.csv的算法那一列
library(ComplexHeatmap)
# 最新版ComplexHeatmap好像有一些bug,使用里面的pheatmap函数会报错
# 因此我们从脚本直接加载pheatmap函数
source("/t8a/2022backup/xuzijun/vip39/huitu/FigureYa230immunelandscape/pheatmap_translate.R") # 位于当前文件夹,出自ComplexHeatmap_2.7.9.tar.gz
ht_opt$message = FALSE
# 创建注释
annCol <- data.frame(
Subtype = risk$Cluster,
row.names = rownames(risk),
stringsAsFactors = F)
annRow <- data.frame(row.names = colnames(hmdat),
Methods = factor(immMethod,levels = unique(immMethod)),
stringsAsFactors = F)
annColors <- list(
"Subtype" = c("C1"="#BC3C29FF", "C2"="#0072B5FF","C3"="#E18727FF","C4"="#7876B1FF"))
# 数据标准化
indata <- t(hmdat)
indata <- indata[,colSums(indata) > 0] # 确保没有富集全为0的细胞
plotdata <- standarize.fun(indata,halfwidth = 2)
# 样本按risk score排序
samorder <- c(rownames(sub)[sub$Cluster=="C1"],rownames(sub)[sub$Cluster=="C2"],
rownames(sub)[sub$Cluster=="C3"],rownames(sub)[sub$Cluster=="C4"])
# 拆分各算法的结果
plotdata1 <- plotdata[rownames(annRow[which(annRow$Methods == "TIMER"),,drop = F]),]
plotdata2 <- plotdata[rownames(annRow[which(annRow$Methods == "CIBERSORT"),,drop = F]),]
plotdata3 <- plotdata[rownames(annRow[which(annRow$Methods == "CIBERSORT-ABS"),,drop = F]),]
plotdata4 <- plotdata[rownames(annRow[which(annRow$Methods == "QUANTISEQ"),,drop = F]),]
plotdata5 <- plotdata[rownames(annRow[which(annRow$Methods == "MCPCOUNTER"),,drop = F]),]
plotdata6 <- plotdata[rownames(annRow[which(annRow$Methods == "XCELL"),,drop = F]),]
plotdata7 <- plotdata[rownames(annRow[which(annRow$Methods == "EPIC"),,drop = F]),]
# 分别画7次热图(参数基本同pheatmap里的pheatmap)
hm1 <- pheatmap(mat = as.matrix(plotdata1[,samorder]),
border_color = NA,
#color = bluered(64),
cluster_rows = F,
cluster_cols = F,
show_rownames = T,
show_colnames = F,
annotation_col = annCol[samorder,,drop = F],
annotation_colors = annColors,
cellwidth = 0.8,
cellheight = 10,
gaps_col = c(92,259,333,516),
name = "TIMER") # 为子热图的图例命名
hm2 <- pheatmap(mat = as.matrix(plotdata2[,samorder]),
border_color = NA,
color = greenred(64),
cluster_rows = F,
cluster_cols = F,
show_rownames = T,
show_colnames = F,
cellwidth = 0.8,
cellheight = 10,
gaps_col = c(92,259,333,516),
name = "CIBERSORT")
hm3 <- pheatmap(mat = as.matrix(plotdata3[,samorder]),
border_color = NA,
color = blueyellow(64),
cluster_rows = F,
cluster_cols = F,
show_rownames = T,
show_colnames = F,
cellwidth = 0.8,
cellheight = 10,
gaps_col = c(92,259,333,516),
name = "CIBERSORT-ABS")
hm4 <- pheatmap(mat = as.matrix(plotdata4[,samorder]),
border_color = NA,
color = bluered(64),
cluster_rows = F,
cluster_cols = F,
show_rownames = T,
show_colnames = F,
cellwidth = 0.8,
cellheight = 10,
gaps_col = c(92,259,333,516),
name = "QUANTISEQ")
hm5 <- pheatmap(mat = as.matrix(plotdata5[,samorder]),
border_color = NA,
color = inferno(64),
cluster_rows = F,
cluster_cols = F,
show_rownames = T,
show_colnames = F,
cellwidth = 0.8,
cellheight = 10,
gaps_col = c(92,259,333,516),
name = "MCPCOUNTER")
hm6 <- pheatmap(mat = as.matrix(plotdata6[,samorder]),
border_color = NA,
color = viridis(64),
cluster_rows = F,
cluster_cols = F,
show_rownames = T,
show_colnames = F,
cellwidth = 0.8,
cellheight = 10,
gaps_col = c(92,259,333,516),
name = "XCELL")
hm7 <- pheatmap(mat = as.matrix(plotdata7[,samorder]),
border_color = NA,
color = magma(64),
cluster_rows = F,
cluster_cols = F,
show_rownames = T,
show_colnames = F,
cellwidth = 0.8,
cellheight = 10,
gaps_col = c(92,259,333,516),
name = "EPIC")
pdf("immune heatmap by ComplexHeatmap met.pdf", width = 10,height = 20) # 保存前请注意RGUI里不能有任何显示的图像,否则不会pdf打不开
draw(hm1 %v% hm2 %v% hm3 %v% hm4 %v% hm5 %v% hm6 %v% hm7, # 垂直连接子热图
heatmap_legend_side = "bottom", # 热图注释放底部
annotation_legend_side = "bottom") # 顶部注释放底部
invisible(dev.off())
save(sub,file="Sdeath_sub.rds")
##fig280
setwd("../")
#fig
####immune gene #####
type <- fread("/t8a/2022backup/xuzijun/vip39/data/immunegene5type.csv",header = T,data.table=F)
hmdat <- as.data.frame(t(KIRC_mRNA_fpkm[rownames(type),sub$Sample]))
head(type)
table(type$Gene%in%rownames(KIRC_mRNA_fpkm))
table(rownames(sub)%in%rownames(hmdat))
type$Gene <- rownames(type)
type <- type[type$Gene%in%rownames(KIRC_mRNA_fpkm),]
type <- type[!duplicated(type$Gene),]
rownames(type) <- type$Gene
type <- type[-1]
head(type)
head(hmdat)
comsam <- rownames(sub)
hmdat <- hmdat[comsam,]
risk <- sub[comsam,,drop = F]
dim(hmdat)
head(hmdat[,1:5])
# 拆分不同算法结果,获得类的名字
#immMethod <- sapply(strsplit(colnames(hmdat),"_",fixed = T),"[",2) #用easy_input.csv列名里的算法信息
immMethod <- type$Methods # 用easy_input_type.csv的算法那一列
library(ComplexHeatmap)
# 最新版ComplexHeatmap好像有一些bug,使用里面的pheatmap函数会报错
# 因此我们从脚本直接加载pheatmap函数
source("/t8a/2022backup/xuzijun/vip39/huitu/FigureYa230immunelandscape/pheatmap_translate.R") # 位于当前文件夹,出自ComplexHeatmap_2.7.9.tar.gz
ht_opt$message = FALSE
# 创建注释
annCol <- data.frame(
Subtype = risk$Cluster,
row.names = rownames(risk),
stringsAsFactors = F)
annRow <- data.frame(row.names = colnames(hmdat),
Methods = factor(immMethod,levels = unique(immMethod)),
stringsAsFactors = F)
annColors <- list(
"Subtype" = c("C1"="#BC3C29FF", "C2"="#0072B5FF","C3"="#E18727FF","C4"="#7876B1FF"))
# 数据标准化
indata <- t(hmdat)
indata <- indata[,colSums(indata) > 0] # 确保没有富集全为0的细胞
plotdata <- standarize.fun(indata,halfwidth = 2)
# 样本按risk score排序
samorder <- c(rownames(sub)[sub$Cluster=="C1"],rownames(sub)[sub$Cluster=="C2"],
rownames(sub)[sub$Cluster=="C3"],rownames(sub)[sub$Cluster=="C4"])
# 拆分各算法的结果
###进行差异分析
## 用前面的自定义函数计算组间统计差异
setwd("/home/aim/Desktop/TCGA_work/vip33new/Sdeath_project/result/heatmap_gene")
head(Subtype)
Subtype <- data.frame(Subtype=sub$Cluster)
rownames(Subtype) <- sub$Sample
plotdata <- plotdata[,rownames(Subtype)]
comprTab <- cross_subtype_compr(expr = plotdata, # 或log2(mygene_data + 1),如果用参数检验,请注意对数转化;若非参均可
subt = Subtype,
#two_sam_compr_method = "wilcox", # 两组"t.test", "wilcox"
multi_sam_compr_method = "kruskal", # 多组"anova", "kruskal"
res.path = ".")
# 用全部基因来画
n.show_top_gene <- nrow(plotdata)
# 或者取top 20个基因来画
#n.show_top_gene <- 20
# 按分组排序
subt.order <- Subtype[order(Subtype$Subtype),,drop = F]
indata <- mygene_data[comprTab$gene[1:n.show_top_gene],rownames(subt.order)]
# 开始画图
# 数据标准化和边界设置
# plotdata <- t(scale(t(indata)))
# plotdata[plotdata > 2] <- 2
# plotdata[plotdata < -2] <- -2
# 调整行名
blank <- " " # 行名和p值之间的间隔
p.value <- comprTab$adjusted.p.value[1:n.show_top_gene]
table(comprTab$gene==rownames(plotdata))
head(comprTab)
head(type)
sig.label <- ifelse(p.value < 0.001,"****",
ifelse(p.value < 0.005,"***",
ifelse(p.value < 0.01,"**",
ifelse(p.value < 0.05,"*",""))))
rownames(plotdata) <- paste0(rownames(plotdata)," ",sig.label)
plotdata1 <- plotdata[rownames(annRow[which(annRow$Methods == "chemokine"),,drop = F]),]
plotdata2 <- plotdata[rownames(annRow[which(annRow$Methods == "chemokine_receptor"),,drop = F]),]
plotdata3 <- plotdata[rownames(annRow[which(annRow$Methods == "MHC"),,drop = F]),]
plotdata4 <- plotdata[rownames(annRow[which(annRow$Methods == "Immunoinhibitor"),,drop = F]),]
plotdata5 <- plotdata[rownames(annRow[which(annRow$Methods == "Immunostimulator"),,drop = F]),]
plotdata1 <- plotdata[rownames(annRow[which(annRow$Methods == "chemokine"),,drop = F]),]
rownames(plotdata1) <- paste0(rownames(plotdata1)," ",sig.label[which(annRow$Methods == "chemokine")])
plotdata2 <- plotdata[rownames(annRow[which(annRow$Methods == "chemokine_receptor"),,drop = F]),]
rownames(plotdata2) <- paste0(rownames(plotdata2)," ",sig.label[which(annRow$Methods == "chemokine_receptor")])
plotdata3 <- plotdata[rownames(annRow[which(annRow$Methods == "MHC"),,drop = F]),]
rownames(plotdata3) <- paste0(rownames(plotdata3)," ",sig.label[which(annRow$Methods == "MHC")])
plotdata4 <- plotdata[rownames(annRow[which(annRow$Methods == "Immunoinhibitor"),,drop = F]),]
rownames(plotdata4) <- paste0(rownames(plotdata4)," ",sig.label[which(annRow$Methods == "Immunoinhibitor")])
plotdata5 <- plotdata[rownames(annRow[which(annRow$Methods == "Immunostimulator"),,drop = F]),]
rownames(plotdata5) <- paste0(rownames(plotdata5)," ",sig.label[which(annRow$Methods == "Immunostimulator")])
# 分别画7次热图(参数基本同pheatmap里的pheatmap)
library(RColorBrewer)
library(circlize)
library(ggsci)
library(gplots)
library(viridis)
library(oompaBase)
hm1 <- pheatmap(mat = as.matrix(plotdata1[,samorder]),
border_color = NA,
#color = bluered(64),
cluster_rows = F,
cluster_cols = F,
show_rownames = T,
show_colnames = F,
annotation_col = annCol[samorder,,drop = F],
annotation_colors = annColors,
cellwidth = 0.8,
cellheight = 12,
gaps_col = c(92,259,333,516),
name = "chemokine") # 为子热图的图例命名
hm2 <- pheatmap(mat = as.matrix(plotdata2[,samorder]),
border_color = NA,
color = greenred(64),
cluster_rows = F,
cluster_cols = F,
show_rownames = T,
show_colnames = F,
cellwidth = 0.8,
cellheight = 12,
gaps_col = c(92,259,333,516),
name = "chemokine_receptor")
hm3 <- pheatmap(mat = as.matrix(plotdata3[,samorder]),
border_color = NA,
color = blueyellow(64),
cluster_rows = F,
cluster_cols = F,
show_rownames = T,
show_colnames = F,
cellwidth = 0.8,
cellheight = 12,
gaps_col =c(92,259,333,516),
name = "MHC")
hm4 <- pheatmap(mat = as.matrix(plotdata4[,samorder]),
border_color = NA,
color = bluered(64),
cluster_rows = F,
cluster_cols = F,
show_rownames = T,
show_colnames = F,
cellwidth = 0.8,
cellheight = 12,
gaps_col = c(92,259,333,516),
name = "Immunoinhibitor")
hm5 <- pheatmap(mat = as.matrix(plotdata5[,samorder]),
border_color = NA,
color = inferno(64),
cluster_rows = F,
cluster_cols = F,
show_rownames = T,
show_colnames = F,
cellwidth = 0.8,
cellheight = 12,
gaps_col = c(92,259,333,516),
name = "Immunostimulator")
pdf("immune heatmap by ComplexHeatmap gene RNAmodify.pdf", width = 10,height = 30) # 保存前请注意RGUI里不能有任何显示的图像,否则不会pdf打不开
draw(hm1 %v% hm2 %v% hm3 %v% hm4 %v% hm5, # 垂直连接子热图
heatmap_legend_side = "bottom", # 热图注释放底部
annotation_legend_side = "bottom") # 顶部注释放底部
invisible(dev.off())
###pericyte to endothail vessel normalization score######
rownames(plotdata)
sub$PtoEscore <- scale(as.numeric(plotdata["Cancer associated fibroblast_XCELL",sub$Sample]/plotdata["Endothelial cell_XCELL",sub$Sample]))
compaired <- list(c("C1", "C2"),
c("C1", "C3"),
c("C1", "C4"),
c("C2", "C3"),
c("C2", "C4"),
c("C3", "C4")) #设置比较组别
library(ggsci)
#colnames(df.merge)
colnames(sub)
col_1<-pal_nejm()(8)
sub$PtoEscore[sub$PtoEscore > 1] <- 1
sub$PtoEscore[sub$PtoEscore < -1] <- -1
ggboxplot(sub, x="Cluster", y="PtoEscore",color = "Cluster",
palette = c("#BC3C29FF","#0072B5FF","#E18727FF","#20854EFF"), add = "jitter")+
### 添加多组比较的统计学结果
stat_compare_means(label.y = max(sub$PtoEscore))+
### 添加每个两两比较的显著性标记位置信息
stat_compare_means(comparisons=compaired, method = "wilcox.test",
label ="p.value")
ggsave(filename = "vessel_normalization_score.pdf",height = 5,width = 5)
###more signal from IOBR ####
library(IOBR)
names(sig_group)
signature_collection
length(signature_collection)
names(signature_collection)
###免疫 以及immune score####
#各种评分
##TIP
##CIBERSORT
##ssGSEA
##IOBR
##CYT
#fig163
###两个subtype cor heatmap####
#fig97 gene and immune cor
#fig277 immune gene subtype
library(ChAMPdata) # 用于提供甲基化注释文件
library(genefu) # 用于获取乳腺癌PAM50分型
#data("pam50.robust")
data("probe.features")
Sys.setenv(LANGUAGE = "en") #显示英文报错信息
options(stringsAsFactors = FALSE) #禁止chr转成factor
# 设置热图颜色
heatmap.BlWtRd <- c("#1F66AC", "#75AFD3", "grey90", "#FAB99B", "#B2192B")
# 设置感兴趣基因集
immunomodulator <- read.table("/t8a/2022backup/ssy088_202210/ssy088/tutulaile/FigureYa277Immunomodulator/immunomodulator.txt",sep = "\t",row.names = 1,check.names = F,stringsAsFactors = F,header = T)
# 数据处理 #
# 该部分是为产生最终用于绘图的文件
## 表达谱
expr <- read.table("TCGA.BRCA.sampleMap-HiSeqV2.gz",sep = "\t",row.names = 1,check.names = F,stringsAsFactors = F,header = T)
expr <- tpms
is.element(rownames(immunomodulator),rownames(tpms)) # 所有基因都在表达谱内
# pam50pred <- molecular.subtyping(sbt.model = "pam50",
# data = t(expr),
# annot = data.frame(Gene.Symbol = rownames(expr)),
# do.mapping = FALSE)
# subtype <- as.character(pam50pred$subtype)
#
# sinfo <- data.frame(row.names = colnames(expr),
# pam50 = subtype,
# subtype = sapply(subtype, switch,
# "Basal" = "C1",
# "Her2" = "C2",
# "LumB" = "C3",
# "LumA" = "C4",
# "Normal" = "C5"))
sinfo <- data.frame(row.names=sub$Sample,
subtype =sub$Cluster)
head(sinfo)
rownames(sinfo)<- paste0(rownames(sinfo),"A")
table(sinfo$subtype)
expr <- tpms[rownames(immunomodulator),]
colnames(expr) <- paste0(colnames(expr),"A")
## 甲基化谱
meth <- fread("/t8a/vip39database/database/UCSC_TCGA/TCGA_methylation450/TCGA-KIRC.methylation450.tsv.gz", sep = "\t",check.names = F,stringsAsFactors = F,header = T,data.table = F)
meth[1:4,1:4]
rownames(meth) <- meth$`Composite Element REF`; meth <- meth[,-1]
meth <- as.data.frame(na.omit(meth))
probeOfInterest <- probe.features[which(probe.features$gene %in% rownames(immunomodulator)),]
probeOfInterest <- probeOfInterest[intersect(rownames(probeOfInterest), rownames(meth)),]
is.element(rownames(immunomodulator), probeOfInterest$gene) # 有些基因没有对应的甲基化探针
meth <- meth[rownames(probeOfInterest),]
meth$gene <- probeOfInterest$gene
meth <- as.data.frame(apply(meth[,setdiff(colnames(meth), "gene")], 2, function(x) tapply(x, INDEX=factor(meth$gene), FUN=median, na.rm=TRUE)))
## 拷贝数变异 (-2,-1,0,1,2: 2 copy del, 1 copy del, no change, amplification, high-amplification)
cna <- read.table("/home/aim/Desktop/urology/Urinary_data/kidney/KIRC_DATA/TCGA.KIRC.sampleMap_Gistic2_CopyNumber_Gistic2_all_thresholded.by_genes.gz",sep = "\t",row.names = 1,check.names = F,stringsAsFactors = F,header = T)
cna$gene <- sapply(strsplit(rownames(cna),"|",fixed = T),"[",1)
cna <- cna[!duplicated(cna$gene),]; cna <- cna[,setdiff(colnames(cna),"gene")]
is.element(rownames(immunomodulator),rownames(cna)) # 有些基因没有对应的拷贝数结果
cna <- cna[intersect(rownames(cna),rownames(immunomodulator)),]
cna[cna > 1] <- 1 # 统一扩增
cna[cna < -1] <- -1 # 统一缺失
## 提取共同样本
comsam <- intersect(colnames(expr), colnames(meth))
colnames(cna) <- paste0(colnames(cna),"A")
comsam <- intersect(comsam, colnames(cna))
comsam <- intersect(comsam, rownames(sinfo))
head(sinfo)
sinfo <- sinfo[comsam,,drop = F]
expr <- expr[,comsam]
meth <- meth[,comsam]
cna <- cna[,comsam]
setwd("./figya277/")
head(sinfo)
write.table(sinfo[,"subtype",drop = F], file = "easy_input_subtype.txt",sep = "\t",row.names = T,col.names = NA,quote = F)
write.table(expr, file = "easy_input_expr.txt",sep = "\t",row.names = T,col.names = NA,quote = F)
write.table(meth, file = "easy_input_meth.txt",sep = "\t",row.names = T,col.names = NA,quote = F)
write.table(cna, file = "easy_input_cna.txt",sep = "\t",row.names = T,col.names = NA,quote = F)
# 读取数据 #
sinfo <- read.table(file = "easy_input_subtype.txt",sep = "\t",row.names = 1,check.names = F,stringsAsFactors = F,header = T)
expr <- read.table(file = "easy_input_expr.txt",sep = "\t",row.names = 1,check.names = F,stringsAsFactors = F,header = T)
meth <- read.table(file = "easy_input_meth.txt",sep = "\t",row.names = 1,check.names = F,stringsAsFactors = F,header = T)
cna <- read.table(file = "easy_input_cna.txt",sep = "\t",row.names = 1,check.names = F,stringsAsFactors = F,header = T)
sinfo <- sinfo[,"subtype",drop = F]
head(sinfo)
# 亚型数目(注意,亚型必须以C1,C2,C3...等命名)
(n.subt <- length(unique(sinfo$subtype))) # 获取亚型数目
subt <- unique(sinfo$subtype) # 获取亚型名
# 初始化绘图矩阵
expMat <- as.data.frame(t(expr[rownames(immunomodulator),]))
expMat$subtype <- sinfo[rownames(expMat), "subtype"]
expMat <- as.data.frame(t(apply(expMat[,setdiff(colnames(expMat), "subtype")], 2,
function(x)
tapply(x,
INDEX = factor(expMat$subtype),
FUN = median,
na.rm = TRUE)))) # 对同一亚型内的样本取中位数
corExpMeth <- ampFreq <- delFreq <-
as.data.frame(matrix(NA,
nrow = nrow(immunomodulator),
ncol = n.subt,
dimnames = list(rownames(immunomodulator),
unique(sinfo$subtype))))
## 表达谱与甲基化的相关性
for (i in rownames(immunomodulator)) {
if(!is.element(i, rownames(expr)) | !is.element(i, rownames(meth))) { # 如果存在任意一方有缺失的基因
corExpMeth[i,] <- NA # 则保持矩阵为NA
} else { # 否则取出亚型样本,做表达和甲基化的相关性
for (j in subt) {
sam <- rownames(sinfo[which(sinfo$subtype == j),,drop = F])
expr.subset <- as.numeric(expr[i, sam])
meth.subset <- as.numeric(meth[i, sam])
ct <- cor.test(expr.subset, meth.subset, method = "spearman") # 这里采用speaman相关性
corExpMeth[i, j] <- ct$estimate
}
}
}
## 扩增/缺失频率
for (i in rownames(immunomodulator)) {
if(!is.element(i, rownames(cna))) { # 同理,如果存在拷贝数中缺失某基因,则保持NA
ampFreq[i,] <- NA
delFreq[i,] <- NA
} else { # 否则
# 计算i在总样本中的频率
ampFreqInAll <- sum(as.numeric(cna[i,]) == 1)/ncol(cna) # 总样本中扩增的数目除以总样本数
delFreqInAll <- sum(as.numeric(cna[i,]) == -1)/ncol(cna) # 总样本中缺失的数目除以总样本数
for (j in subt) {
# 计算i在亚型j中的频率
sam <- rownames(sinfo[which(sinfo$subtype == j),,drop = F])
cna.subset <- cna[, sam]
ampFreqInSubt <- sum(as.numeric(cna.subset[i,]) == 1)/length(sam) # 该亚型中扩增的数目除以该亚型样本数
delFreqInSubt <- sum(as.numeric(cna.subset[i,]) == -1)/length(sam) # 该亚型中缺失的数目除以该亚型样本数
ampFreqInDiff <- ampFreqInSubt - ampFreqInAll # 根据原本,用亚型特异性扩增比例减去总扩增比例
delFreqInDiff <- delFreqInSubt - delFreqInAll # 同理
ampFreq[i, j] <- ampFreqInDiff
delFreq[i, j] <- delFreqInDiff
}
}
}
write.table(expMat,"expMat.txt",sep = "\t",row.names = T,col.names = NA,quote = F)
write.table(corExpMeth,"corExpMeth.txt",sep = "\t",row.names = T,col.names = NA,quote = F)
write.table(ampFreq,"ampFreq.txt",sep = "\t",row.names = T,col.names = NA,quote = F)
write.table(delFreq,"delFreq.txt",sep = "\t",row.names = T,col.names = NA,quote = F)
# 创建列注释
annCol <- data.frame(subtype = subt,
row.names = subt)
annCol <- annCol[order(annCol$subtype),,drop = F] # 按照亚型排序
annColors <- list()
annColors[["subtype"]] <- c("C1" = "red",
"C2" = "yellow",
"C3" = "green",
"C4" = "cyan"
#"C5" = "blue"
)
top_anno <- HeatmapAnnotation(df = annCol,
col = annColors,
gp = gpar(col = "grey80"), # 每个单元格边框为灰色
simple_anno_size = unit(3.5, "mm"), # 注释高3.5毫米
show_legend = F, # 不显示亚型的图例,因为一目了然
show_annotation_name = F, # 不显示该注释的名称
border = FALSE) # 不显示注释的外边框
# 创建行注释
annRow <- immunomodulator
annRow[which(annRow$Category == "Co-stimulator"),"Category"] <- "Co-stm" # 这里字符少一些,不会挤在一起,可以后期AI
annRow[which(annRow$Category == "Co-inhibitor"),"Category"] <- "Co-ihb"
annRow[which(annRow$Category == "Cell adhesion"),"Category"] <- "Cell\nadhesion" # 这里换行,不会挤在一起,可以后期AI
annRow[which(annRow$Category == "Antigen presentation"),"Category"] <- "Antigen\npresentation"
annRow$Category <- factor(annRow$Category, levels = c("Co-stm","Co-ihb","Ligand","Receptor","Cell\nadhesion","Antigen\npresentation","Other")) # 由于行需要按照类分割,所以需要定义因子顺序,否则按照字母表
annRow$ICI <- factor(annRow$ICI, levels = c("Inhibitory","N/A","Stimulatory"))
annRowColors <- list("ICI" = c("Inhibitory" = "black","N/A" = "#888888","Stimulatory" = "#E59E02"))
left_anno <- HeatmapAnnotation(df = annRow[,"ICI",drop = F],
which = "row", # 这里是行注释(默认为列)
gp = gpar(col = "grey80"), # 每个单元格边框为灰色
col = annRowColors,
simple_anno_size = unit(3.5, "mm"), # 注释宽3.5毫米
show_annotation_name = F,
border = F)
## 绘制表达谱热图(参数下同)
col_expr <- colorRamp2(seq(min(na.omit(expMat)), max(na.omit(expMat)), length = 5), heatmap.BlWtRd) # 创建热图颜色(将热图输入矩阵的最大最小值取5个点,分配颜色红蓝色板;注意矩阵中可能存在的NA值)
hm.expr <- Heatmap(matrix = as.matrix(expMat),
col = col_expr,
border = NA, # 无热图外边框
rect_gp = gpar(col = "grey80"), # 热图单元格边框为灰色
cluster_rows = F, # 行不聚类
cluster_columns = F, # 列不聚类
show_row_names = T, # 显示行名
row_names_side = "left", # 行名显示在左侧
row_names_gp = gpar(fontsize = 10), # 行名字号为10
show_column_names = F, # 不显示列名(可后期在颜色内AI使得亚型一目了然)
column_names_side = "top", # 列名显示在顶部
row_split = annRow$Category, # 行按照Category进行分割(因子顺序)
top_annotation = top_anno, # 热图顶部注释
left_annotation = left_anno, # 热图左侧注释
name = "mRNA\nExpression", # 热图颜色图例的名称
width = ncol(expMat) * unit(4, "mm"), # 热图单元格宽度(稍大于高度,因为所有注释都放在底部,平衡图形纵横比)
height = nrow(expMat) * unit(3.5, "mm")) # 热图单元格高度
col_corExprMeth <- colorRamp2(seq(min(na.omit(corExpMeth)), max(na.omit(corExpMeth)), length = 5), heatmap.BlWtRd)
hm.corExprMeth <- Heatmap(matrix = as.matrix(corExpMeth),
col = col_corExprMeth,
border = NA,
rect_gp = gpar(col = "grey80"),
cluster_rows = F,
cluster_columns = F,
show_row_names = F,
row_names_side = "left",
row_names_gp = gpar(fontsize = 10),
show_column_names = F,
column_names_side = "top",
row_split = annRow$Category,
row_title = NULL,
top_annotation = top_anno,
name = "Expression\nvs. Methylation",
width = ncol(expMat) * unit(4, "mm"),
height = nrow(expMat) * unit(3.5, "mm"))
col_ampFreq <- colorRamp2(seq(min(na.omit(ampFreq)), max(na.omit(ampFreq)), length = 5), heatmap.BlWtRd)
hm.ampFreq <- Heatmap(matrix = as.matrix(ampFreq),
col = col_ampFreq,
border = NA,
rect_gp = gpar(col = "grey80"),
cluster_rows = F,
cluster_columns = F,
show_row_names = F,
row_names_side = "left",
row_names_gp = gpar(fontsize = 10),
show_column_names = F,
column_names_side = "top",
row_split = annRow$Category,
row_title = NULL,
top_annotation = top_anno,
name = "Amplification\nFrequency",
width = ncol(expMat) * unit(4, "mm"),
height = nrow(expMat) * unit(3.5, "mm"))
col_delFreq <- colorRamp2(seq(min(na.omit(delFreq)), max(na.omit(delFreq)), length = 5), heatmap.BlWtRd)
hm.delFreq <- Heatmap(matrix = as.matrix(delFreq),
col = col_delFreq,
border = NA,
rect_gp = gpar(col = "grey70"),
cluster_rows = F,
cluster_columns = F,
show_row_names = F,
row_names_side = "left",
row_names_gp = gpar(fontsize = 10),
show_column_names = F,
column_names_side = "top",
row_split = annRow$Category,
row_title = NULL,
top_annotation = top_anno,
name = "Deletion\nFrequency",
width = ncol(expMat) * unit(4, "mm"),
height = nrow(expMat) * unit(3.5, "mm"))
pdf(file = "complexheatmap of immunomodulator.pdf", width = 8,height = 12)
draw(hm.expr + hm.corExprMeth + hm.ampFreq + hm.delFreq, # 水平衔接各个子热图
heatmap_legend_side = "bottom") # 热图颜色图例显示在下方
invisible(dev.off())
#fig248 突变高级热图
#fig136 fgsea
#fig76 gene corrlation
#fig282 CMAP_XSum
#fig238 corRiskMut
#fig161 stemness
###fig152 immune tow cor####
#tipcor
#C3 单独作为一组
setwd("./fig152/")
stepscore[1:4,1:4]
tcga_gsva1 <- stepscore[,sub$Sample[sub$Cluster=="C4"]]
tcga_gsva1[1:3,1:3]
tcga_gsva1 <- as.data.frame(t(tcga_gsva1))##列为细胞或者通路分数
tcga_gsva2 <- stepscore[,sub$Sample[sub$Cluster!="C4"]]
tcga_gsva2[1:3,1:3]
tcga_gsva2 <- as.data.frame(t(tcga_gsva2))
#这里将计算每列之间的相关性
#如果要计算行之间的相关性就运行下面这行转置(把行变成列,列变成行)
#tcga_gsva <- t(tcga_gsva)
# 计算相关系数
cor_r <- cor(tcga_gsva1)
cor_r[1:3,1:3]
write.csv(cor_r, "easy_input_R1.csv", quote = F)
cor_r <- cor(tcga_gsva2)
cor_r[1:3,1:3]
write.csv(cor_r, "easy_input_R2.csv", quote = F)
# 计算p value
tcga_gsva <- tcga_gsva1
cor_p <- matrix(0, nrow = ncol(tcga_gsva), ncol = ncol(tcga_gsva))
rownames(cor_p) <- colnames(tcga_gsva)
colnames(cor_p) <- colnames(tcga_gsva)
for (i in 1:ncol(tcga_gsva)){
for (j in 1:ncol(tcga_gsva)){
p <- cor.test(tcga_gsva[,i],tcga_gsva[,j])
cor_p[i,j] <- p$p.value
}
}
write.csv(cor_p, "easy_input_P1.csv", quote = F)
tcga_gsva <- tcga_gsva2
cor_p <- matrix(0, nrow = ncol(tcga_gsva), ncol = ncol(tcga_gsva))
rownames(cor_p) <- colnames(tcga_gsva)
colnames(cor_p) <- colnames(tcga_gsva)
for (i in 1:ncol(tcga_gsva)){
for (j in 1:ncol(tcga_gsva)){
p <- cor.test(tcga_gsva[,i],tcga_gsva[,j])
cor_p[i,j] <- p$p.value
}
}
write.csv(cor_p, "easy_input_P2.csv", quote = F)
#KICH是C4 KIRC是其他的
KICHR <- read.csv("easy_input_R1.csv", row.names = 1)
KICHR[1:3,1:3]
KICHP <- read.csv("easy_input_P1.csv", row.names = 1)
KICHP[1:3,1:3]
KIRCR <- read.csv("easy_input_R1.csv", row.names = 1)
KIRCP <- read.csv("easy_input_P1.csv", row.names = 1)
## 合并相关系数的数据
datR <- KICHR
for(i in 1:nrow(datR)){
datR[i,1:i] <- KIRCR[i,1:i]
}
datR[1:3,1:3]
## 合并P值的数据
datP <- KICHP
for (i in 1:nrow(datP)) {
datP[i,1:i] <- KIRCP[i,1:i]
}
datP[1:3,1:3]
# P>= 0.05时,把相关系数设为NA
datR[datP > 0.05] <- NA
## 定义左右两个不同相关系数图的颜色
# 定义右上部分图形的颜色
colCorRight <- circlize::colorRamp2(c(-1, 0, 1), c("green", "white", "#ef3b2c"))
# 定义左上部分图形的颜色
colCorLeft <- circlize::colorRamp2(c(-1, 0, 1), c("yellow", "white", "#762a83"))
## 绘制基本图形
p1 <- Heatmap(datR, rect_gp = gpar(type = "none"),
show_heatmap_legend = F,
cell_fun = function(j, i, x, y, width, height, fill) {
grid.rect(x = x, y = y, width = width, height = height,
gp = gpar(col = "grey", fill = NA))
if(i == j) {
grid.circle(x = x, y = y, r = 0.5 * min(unit.c(width, height)), gp = gpar(fill = "grey", col = NA))
}else if(i > j) {
grid.circle(x = x, y = y, r = abs(datR[i, j])/2 * min(unit.c(width, height)),
gp = gpar(fill = colCorLeft(datR[i, j]), col = NA))
} else {
grid.circle(x = x, y = y, r = abs(datR[i, j])/2 * min(unit.c(width, height)),
gp = gpar(fill = colCorRight(datR[i, j]), col = NA))
}
},
cluster_rows = FALSE, cluster_columns = FALSE,
show_row_names = T, show_column_names = T,
row_names_side = "right",
row_names_rot = 45,
row_names_gp = gpar(fontsize = 8),
column_names_gp = gpar(fontsize = 8)
)
p1
## 绘制两个不同不同相关的图例
lgdRight <- Legend(col_fun = colCorRight, title = "KICH",
direction = "horizontal")
lgdLeft <- Legend(col_fun = colCorLeft, title = "KIRC",
direction = "horizontal")
pd = list(lgdRight, lgdLeft)
## 最后出图
pdf("DouleCorPlot.pdf", width = 5, height = 5.5)
draw(p1, annotation_legend_list = pd,
annotation_legend_side = "top")
dev.off()
#fig158 MutationPattern
#fig227 boxdensity drug AUC
#fig292 HCCsubtype 和其他分型比较
#fig168 legoplot 突变位点
####immune cohort####
#进行聚类 或者NTP算法 进行再次分析
#Cancer cell
#javalin
#GSE
##免疫推测 TIDE submap
###immune violion cluster####
###gene and immune cell cor####
### 用ssGSEA来量化浸润水平
### 1.加载marker
load(file = "/t8a/2022backup/xuzijun/vip39/data/cellMarker_ssGSEA.Rdata")
### 2.加载表达量
#load(file = "tcga_panmRNA_expr.Rdata")
expr <- tpms[,sub$Sample]
expr[1:5,1:5]
expr <- as.matrix(expr)
library(GSVA)
### 挺耗时间的,调用了12个线程,17:12开始, 17:37结束
gsva_data <- gsva(expr,cellMarker, method = "ssgsea")
gsva_data[1:4,1:4]
tcga_gsva <- as.data.frame(t(gsva_data))
tcga_gsva[1:4,1:4]
tcga_expr <- tpms[,sub$Sample]
gene <- gene_list
immuscore <- function(gene){
y <- as.numeric(tcga_expr[gene,])
colnames <- colnames(tcga_gsva)
do.call(rbind,lapply(colnames, function(x){
dd <- cor.test(as.numeric(tcga_gsva[,x]), y , method="spearman")
data.frame(gene=gene,immune_cells=x,cor=dd$estimate,p.value=dd$p.value )
}))
}
#以FOXP3为例,测试一下函数
immuscore("OXSM")
genelist <- gene_list
data <- do.call(rbind,lapply(genelist,immuscore))
head(data)
data$pstar <- ifelse(data$p.value < 0.05,
ifelse(data$p.value < 0.01,"**","*"),
"")
data$pstar[1:20]
ggplot(data, aes(immune_cells, gene)) +
geom_tile(aes(fill = cor), colour = "black",size=1)+
scale_fill_gradient2(low = "#2b8cbe",mid = "white",high = "#e41a1c")+
geom_text(aes(label=pstar),col ="black",size = 5)+
theme_minimal()+# 不要背景
theme(axis.title.x=element_blank(),#不要title
axis.ticks.x=element_blank(),#不要x轴
axis.title.y=element_blank(),#不要y轴
axis.text.x = element_text(angle = 45, hjust = 1),# 调整x轴文字
axis.text.y = element_text(size = 8))+#调整y轴文字
#调整legen
labs(fill =paste0(" * p < 0.05","\n\n","** p < 0.01","\n\n","Correlation"))
setwd("./ssgsea_cor/")
tcga_gsva[1:4,1:4]
tcga_gsva <- as.data.frame(t(tcga_gsva))
tcga_gsva1 <- tcga_gsva[,sub$Sample[sub$Cluster=="C4"]]
tcga_gsva1[1:3,1:3]
tcga_gsva1 <- as.data.frame(t(tcga_gsva1))##列为细胞或者通路分数
tcga_gsva2 <- tcga_gsva[,sub$Sample[sub$Cluster!="C4"]]
tcga_gsva2[1:3,1:3]
tcga_gsva2 <- as.data.frame(t(tcga_gsva2))
#这里将计算每列之间的相关性
#如果要计算行之间的相关性就运行下面这行转置(把行变成列,列变成行)
#tcga_gsva <- t(tcga_gsva)
# 计算相关系数
cor_r <- cor(tcga_gsva1)
cor_r[1:3,1:3]
write.csv(cor_r, "easy_input_R1.csv", quote = F)
cor_r <- cor(tcga_gsva2)
cor_r[1:3,1:3]
write.csv(cor_r, "easy_input_R2.csv", quote = F)
# 计算p value
tcga_gsva <- tcga_gsva1
cor_p <- matrix(0, nrow = ncol(tcga_gsva), ncol = ncol(tcga_gsva))
rownames(cor_p) <- colnames(tcga_gsva)
colnames(cor_p) <- colnames(tcga_gsva)
for (i in 1:ncol(tcga_gsva)){
for (j in 1:ncol(tcga_gsva)){
p <- cor.test(tcga_gsva[,i],tcga_gsva[,j])
cor_p[i,j] <- p$p.value
}
}
write.csv(cor_p, "easy_input_P1.csv", quote = F)
tcga_gsva <- tcga_gsva2
cor_p <- matrix(0, nrow = ncol(tcga_gsva), ncol = ncol(tcga_gsva))
rownames(cor_p) <- colnames(tcga_gsva)
colnames(cor_p) <- colnames(tcga_gsva)
for (i in 1:ncol(tcga_gsva)){
for (j in 1:ncol(tcga_gsva)){
p <- cor.test(tcga_gsva[,i],tcga_gsva[,j])
cor_p[i,j] <- p$p.value
}
}
write.csv(cor_p, "easy_input_P2.csv", quote = F)
#KICH是C4 KIRC是其他的
KICHR <- read.csv("easy_input_R1.csv", row.names = 1)
KICHR[1:3,1:3]
KICHP <- read.csv("easy_input_P1.csv", row.names = 1)
KICHP[1:3,1:3]
KIRCR <- read.csv("easy_input_R1.csv", row.names = 1)
KIRCP <- read.csv("easy_input_P1.csv", row.names = 1)
## 合并相关系数的数据
datR <- KICHR
for(i in 1:nrow(datR)){
datR[i,1:i] <- KIRCR[i,1:i]
}
datR[1:3,1:3]
## 合并P值的数据
datP <- KICHP
for (i in 1:nrow(datP)) {
datP[i,1:i] <- KIRCP[i,1:i]
}
datP[1:3,1:3]
# P>= 0.05时,把相关系数设为NA
datR[datP > 0.05] <- NA
## 定义左右两个不同相关系数图的颜色
# 定义右上部分图形的颜色
colCorRight <- circlize::colorRamp2(c(-1, 0, 1), c("green", "white", "#ef3b2c"))
# 定义左上部分图形的颜色
colCorLeft <- circlize::colorRamp2(c(-1, 0, 1), c("yellow", "white", "#762a83"))
## 绘制基本图形
p1 <- Heatmap(datR, rect_gp = gpar(type = "none"),
show_heatmap_legend = F,
cell_fun = function(j, i, x, y, width, height, fill) {
grid.rect(x = x, y = y, width = width, height = height,
gp = gpar(col = "grey", fill = NA))
if(i == j) {
grid.circle(x = x, y = y, r = 0.5 * min(unit.c(width, height)), gp = gpar(fill = "grey", col = NA))
}else if(i > j) {
grid.circle(x = x, y = y, r = abs(datR[i, j])/2 * min(unit.c(width, height)),
gp = gpar(fill = colCorLeft(datR[i, j]), col = NA))
} else {
grid.circle(x = x, y = y, r = abs(datR[i, j])/2 * min(unit.c(width, height)),
gp = gpar(fill = colCorRight(datR[i, j]), col = NA))
}
},
cluster_rows = FALSE, cluster_columns = FALSE,
show_row_names = T, show_column_names = T,
row_names_side = "right",
row_names_rot = 45,
row_names_gp = gpar(fontsize = 8),
column_names_gp = gpar(fontsize = 8)
)
p1
## 绘制两个不同不同相关的图例
lgdRight <- Legend(col_fun = colCorRight, title = "KICH",
direction = "horizontal")
lgdLeft <- Legend(col_fun = colCorLeft, title = "KIRC",
direction = "horizontal")
pd = list(lgdRight, lgdLeft)
## 最后出图
pdf("DouleCorPlotssgea.pdf", width = 5, height = 5.5)
draw(p1, annotation_legend_list = pd,
annotation_legend_side = "top")
dev.off()
###immune signature boxplot####
#多组间分数比较 标注多个p值!
RNA_stemness <- fread("/t8a/2022backup/xuzijun/vip39/data/pancancer/StemnessScores_RNAexp_20170127.2.tsv.gz",data.table = F)
#会有RNAss EREG.EXPss两个分数
RNA_stemness <- as.data.frame(t(RNA_stemness))
head(RNA_stemness)
colnames(RNA_stemness) <- RNA_stemness[1,]
RNA_stemness <- RNA_stemness[-1,]
head(RNA_stemness)
rownames(RNA_stemness) <- str_replace_all(rownames(RNA_stemness),"\\.","\\-")
table(rownames(sub)%in%rownames(RNA_stemness))
# FALSE TRUE
# 17 499