新一代基线资料表R包,10min学会精美可视化结果!
案例1:简单绘制一个Figure
#准备工作
library(funkyheatmap)
library(tidyverse)
#准备输入数据
data("mtcars")
mtcars
# mpg cyl disp hp drat wt qsec vs am gear carb
#Mazda RX4 21.0 6 160.0 110 3.90 2.620 16.46 0 1 4 4
#Mazda RX4 Wag 21.0 6 160.0 110 3.90 2.875 17.02 0 1 4 4
#Datsun 710 22.8 4 108.0 93 3.85 2.320 18.61 1 1 4 1
#Hornet 4 Drive 21.4 6 258.0 110 3.08 3.215 19.44 1 0 3 1
#Hornet Sportabout 18.7 8 360.0 175 3.15 3.440 17.02 0 0 3 2
#Valiant 18.1 6 225.0 105 2.76 3.460 20.22 1 0 3 1
funky_heatmap(mtcars)
#因为表格比较长,所以只是展示部分可视化结果
案例2:进阶一下
#准备工作
library(funkyheatmap)
library(tidyverse)
#准备输入数据
pdata
#ID Sex Age Symptom Cholangitis macroscopic visual end
#1 YFC male 52 bellyache 0 B1 Benign Benign
#2 ZJJ male 78 bellyache 1 B4 Benign Benign
#3 CLL female 29 bellyache 1 B2 Benign Benign
#4 ZYC male 83 Fever 1 B2 Benign Benign
#5 YFL male 51 Icterus 0 B2 Benign Benign
column_info <- tribble(
~group,~geom,~id,~palette,
"Basic information","text","ID",NA,
"Basic information","text","Sex",NA,
"Basic information","bar","Age","Set3",
"Basic information","text","Symptom",NA,
"Basic information","rect","Cholangitis","Blues",
"technology","text","macroscopic",NA,
"technology","text","visual",NA,
"outcome","text","end",NA)
column_groups <- tribble(
~Category,~group,~palette,
"information","Basic information","Set3",
"technology", "technology", "Set3",
"outcome","outcome","Set3",
)
#可视化
funky_heatmap(pdata,
column_info = column_info,
column_groups = column_groups)
微信扫码关注该文公众号作者
戳这里提交新闻线索和高质量文章给我们。
来源: qq
点击查看作者最近其他文章