本期素材来源还是上期NC
中的图,因为图比较一般,就不放在CNS
绘图系列了,简单介绍一下ggbiplot
的用法即可。
❝「Title:」Molecular determinants of response to PD-L1 blockade across tumor types
「DOI:」https://doi.org/10.1038/s41467-021-24112-w
❞
绘制
# 安装和载入包
library(devtools)
install_github("vqv/ggbiplot")
library(ggbiplot)
# 使用内置数据演示
data(wine)
head(wine)
# PCA分析
wine.pca <- prcomp(wine, scale. = TRUE)
# 可视化
ggbiplot(wine.pca, # PCA结果
choices = c(1,2), # 主成分选择
obs.scale = 1, # 标准化观测值
var.scale = 1, # 标准化变量
var.axes = TRUE, #为变量画箭头
groups = wine.class,
ellipse = TRUE, # 置信椭圆
ellipse.prob = 0.95, # 置信区间,默认0.68
circle = F) + # 画相关圈(仅适用于当scale = TRUE和var.scale = 1时调用prcomp)
scale_color_manual(values = c('#fb9b8e','#00ac4c','#70abd8'))+
theme_bw() +
theme(legend.direction = 'horizontal',
legend.position = 'top',
legend.text = element_text(size = 14),
legend.title = element_text(size = 16))
ggsave('pca.pdf',width = 5, height = 5)
❝不带箭头即为文章中的图。
❞
示例数据和代码领取
点赞
、在看
本文,分享至朋友圈集赞20个
并保留30分钟
,截图发至微信mzbj0002
领取。
「木舟笔记2022年度VIP可免费领取」。
木舟笔记2022年度VIP企划
「权益:」
「2022」年度木舟笔记所有推文示例数据及代码(「在VIP群里实时更新」)。
data+code 木舟笔记「科研交流群」。
「半价」购买
跟着Cell学作图系列合集
(免费教程+代码领取)|跟着Cell学作图系列合集。
「收费:」
「99¥/人」。可添加微信:mzbj0002
转账,或直接在文末打赏。