1.为什么画出来的PCA图完全与教程颠倒?
为什么你画的Seurat包PCA图与别人的方向不一致? | 生信菜鸟团
可能是随机种子的原因
set.seed(5)
rnorm(5)
[1] -0.84085548 1.38435934 -1.25549186 0.07014277 1.71144087
set.seed(5)
rnorm(5)
[1] -0.84085548 1.38435934 -1.25549186 0.07014277 1.71144087
随机数是一样的,不管我们在序列中走了多远,它们都是一样的。
Tip:在运行模拟时使用set.seed函数,以确保所有结果、图形等都是可复制的。
经过初步探索,发现将seed设置为NULL就可以与文章中的图一致
总之,如果你发现自己在使用Seurat包重复某一文章或者别人的教程还是官网的示例时,发现自己画出来的图与原有的方向呈镜像或者上下颠倒,可以试着改一下这个随机种子。
set.seed(NULL)
> print(pbmc[["pca"]], dims = 1:5, nfeatures = 5)
PC_ 1
Positive: MALAT1, LTB, IL32, CD2, ACAP1
Negative: CST3, TYROBP, LST1, AIF1, FTL
PC_ 2
Positive: CD79A, MS4A1, TCL1A, HLA-DQA1, HLA-DRA
Negative: NKG7, PRF1, CST7, GZMA, GZMB
PC_ 3
Positive: HLA-DQA1, CD79A, CD79B, HLA-DQB1, HLA-DPB1
Negative: PPBP, PF4, SDPR, SPARC, GNG11
PC_ 4
Positive: HLA-DQA1, CD79A, CD79B, HIST1H2AC, HLA-DQB1
Negative: VIM, S100A8, S100A6, S100A4, S100A9
PC_ 5
Positive: GZMB, FGFBP2, NKG7, GNLY, PRF1
Negative: LTB, VIM, AQP3, PPA1, MAL
> set.seed(42)
> print(pbmc[["pca"]], dims = 1:5, nfeatures = 5)
PC_ 1
Positive: MALAT1, LTB, IL32, CD2, ACAP1
Negative: CST3, TYROBP, LST1, AIF1, FTL
PC_ 2
Positive: CD79A, MS4A1, TCL1A, HLA-DQA1, HLA-DRA
Negative: NKG7, PRF1, CST7, GZMA, GZMB
PC_ 3
Positive: HLA-DQA1, CD79A, CD79B, HLA-DQB1, HLA-DPB1
Negative: PPBP, PF4, SDPR, SPARC, GNG11
PC_ 4
Positive: HLA-DQA1, CD79A, CD79B, HIST1H2AC, HLA-DQB1
Negative: VIM, S100A8, S100A6, S100A4, S100A9
PC_ 5
Positive: GZMB, FGFBP2, NKG7, GNLY, PRF1
Negative: LTB, VIM, AQP3, PPA1, MAL
> set.seed(2)
> print(pbmc[["pca"]], dims = 1:5, nfeatures = 5)
PC_ 1
Positive: MALAT1, LTB, IL32, CD2, ACAP1
Negative: CST3, TYROBP, LST1, AIF1, FTL
PC_ 2
Positive: CD79A, MS4A1, TCL1A, HLA-DQA1, HLA-DRA
Negative: NKG7, PRF1, CST7, GZMA, GZMB
PC_ 3
Positive: HLA-DQA1, CD79A, CD79B, HLA-DQB1, HLA-DPB1
Negative: PPBP, PF4, SDPR, SPARC, GNG11
PC_ 4
Positive: HLA-DQA1, CD79A, CD79B, HIST1H2AC, HLA-DQB1
Negative: VIM, S100A8, S100A6, S100A4, S100A9
PC_ 5
Positive: GZMB, FGFBP2, NKG7, GNLY, PRF1
Negative: LTB, VIM, AQP3, PPA1, MAL
设置随机数后并没有任何变化。