当前位置:网站首页>【R】用grafify搞定统计绘图、方差分析、干预比较等!
【R】用grafify搞定统计绘图、方差分析、干预比较等!
2022-08-03 12:28:00 【风度78】
本期推荐一个优质R包grafify,
grafify功能表现在以下几方面:
几行代码绘制高颜值统计图表,支持6大类,19种图表 (见上图);
包含辨识度极高的调色盘,可与ggplot2良好兼容;
支持方差分析 (ANOVA),包括随机区组和重复测量设计;
支持干预前后的变化比较 (post-hoc comparisons);
模拟1-way和2-way ANOVA设计。
grafify调色盘
支持以下调色盘,包含定性配色方案(Qualitative colormaps)如okabe_ito、r4等和顺序配色方案(Sequential colormaps)如grey_conti等。使用方法类似ggplot2,参考 R可视化07|ggplot2图层-标度图层(scale layer)-颜色盘篇
plot_grafify_palette(palette = "kelly") #查看kelly调色盘所有颜色色值号

grafify:::graf_palettes #输出grafify所有调色盘色值

grafify绘制统计图
统计图对应的实现方法都在下图红框
里了,需要那类图,使用图上方函数即可,下面简单举例,说明grafify的使用:
demo0
plot_4d_scatterbar()
实现3或4个分类变量bar图,
plot_4d_scatterbar(data_2w_Tdeath,
Genotype,
PI,
Time,
Experiment,
b_alpha = 0.7,
ColPal = "vibrant")+
scale_colour_manual(values = c("black", "grey20"))+
labs(title = "2way/RM, bars/SD",
subtitle = "(shapes = randomised blocks)")

demo1
绘制一个组合图:bar图+散点图+SD,plot_scatterbar_sd()
可轻松搞定
library('grafify') # 导入包
plot_scatterbar_sd(data = data_doubling_time,#使用内置数据集data_doubling_time
xcol = Student, # 指定X轴变量
ycol = Doubling_time, # 指定Y轴变量
SingleColour = "r4_1")+ # 指定颜色,这里取子调色盘r4
labs(title = "Scatter+bar+SD") # 设置标题

demo2
QQ图:使用plot_qqline()
即可,
plot_qqline(data_t_pratio,
log(Cytokine),
Genotype)+
labs(title = "QQ plot with plot_qqline()")

demo3
临床连线图:SCI文章中常用连线图比较一样本在干预前后的变化,grafify中plot_befafter_colours()
可轻松实现,
plot_befafter_colours(data = data_t_pdiff,
xcol = Condition,
ycol = Mass,
match = Subject,
symsize = 5,
ColPal = "r4",
ColRev = T)+
labs(title = "TBefore-after with plot_befafter_colours")

demo4
plot_xy_NumGroup()
plot_xy_NumGroup(dplyr::filter(diamonds, cut == "Premium" & clarity == "SI1"),
depth,
price,
carat,
s_alpha = .5,
ColPal = "grey_conti")+ #colschem
labs(title = "plot_xy_NumGroup()")

grafify方差分析
该部分不详细介绍,主要支持以下几类ANOVA:
Simple linear models
: One-way ANOVA, Two-way ANOVAMixed effects models
: One-way ANOVA & randomised blocks,Two-way ANOVA & randomised blocks,Two-way ANOVA, repeated-measures & randomised blocksPosthoc comparisons
:posthoc_Pariwise, posthoc_Levelwise, posthoc_vsRef
参考:https://github.com/ashenoy-cmbi/grafify
往期精彩回顾
适合初学者入门人工智能的路线及资料下载(图文+视频)机器学习入门系列下载机器学习及深度学习笔记等资料打印《统计学习方法》的代码复现专辑机器学习交流qq群955171419,加入微信群请扫码
边栏推荐
- fastposter v2.9.0 程序员必备海报生成器
- Chapter 15 Source Code File REST API Introduction
- -树的高度-
- 论文理解:“Gradient-enhanced physics-informed neural networks for forwardand inverse PDE problems“
- 为冲销量下探中低端市场,蔚来新品牌产品定价低至10万?
- R语言ggplot2可视化:使用patchwork包的plot_layout函数将多个可视化图像组合起来,ncol参数指定行的个数、byrow参数指定按照行顺序排布图
- How can I get a city's year-round weather data for free?Precipitation, temperature, humidity, solar radiation, etc.
- TiKV & TiFlash 加速复杂业务查询丨TiFlash 应用实践
- 安全自定义 Web 应用程序登录
- Autumn recruitment work
猜你喜欢
fastposter v2.9.0 programmer must-have poster generator
After completing the interview and clearance collection of Alibaba, I successfully won the 15th Offer this year
什么是分布式锁?几种分布式锁分别是怎么实现的?
期货公司开户关注的关键点
基于php网上零食商店管理系统获取(php毕业设计)
为什么越来越多的开发者放弃使用Postman,而选择Eolink?
Feature dimensionality reduction study notes (pca and lda) (1)
长城简漫·暑期安全篇⑤ 这个强,不能逞
Station B responded that "HR said that core users are all Loser": the interviewer was persuaded to quit at the end of last year and will learn lessons to strengthen management
第4章 搭建网络库&Room缓存框架
随机推荐
查看GCC版本_qt版本
信创建设看广州|海泰方圆亮相2022 信创生态融合发展论坛
PolarFormer: Multi-camera 3D Object Detection with Polar Transformers 论文笔记
R language ggplot2 visualization: use the patchwork bag plot_layout function will be more visual image together, ncol parameter specifies the number of rows, specify byrow parameters configuration dia
From the physical level of the device to the circuit level
Apache APISIX 2.15 版本发布,为插件增加更多灵活性
The Yangtze river commercial Banks to the interview
第4章 搭建网络库&Room缓存框架
7月份最后一篇博客
Filebeat 如何保持文件状态?
第5章 实现首页Tab数据展示
自律成就自己
可重入锁详解(什么是可重入)
基于php校园医院门诊管理系统获取(php毕业设计)
Take you understand the principle of CDN technology
__unaligned修饰指针
B站回应“HR 称核心用户都是 Loser”:该面试官去年底已被劝退,会吸取教训加强管理
3年软件测试经验,不懂自动化基础...不知道我这种测试人员是不是要被淘汰了?
想学自动化测试网课哪个好?过了人告诉你:适合自己的才是最重要
使用工作队列管理器(四)