R语言作图——Split violin plot

跟着Molecular Cancer学作图 -- 分半小提琴图 从这个系列开始,师兄就带着大家从各大顶级期刊中的Figuer入手,从仿照别人的作图风格到最后实现自己游刃有余的套用在自己的分析数据上!这一系列绝对是高质量!还不赶紧,学起来!话不多说,直接上图! 阅读详情

原创:黄小仙

最近小仙同学在好几篇文献里看到了这种小提琴图,暂时就肤浅地认为这是作者为了更好地比较对照组与实验组的差别,所以将同一个基因的小提琴图各画了一半,放在一起。为了跟上可视化的潮流,小仙也来尝试画一下这个没查到正经名字的图。

Step1. 绘图数据的准备

首先要把你想要绘图的数据调整成R语言可以识别的格式,建议大家在excel中保存成csv格式。
作图数据格式如下:

Step2. 绘图数据的读取

data<-read.csv(“your file path”, header = T)
#注释:header=T表示数据中的第一行是列名,如果没有列名就用header=F

Step3.

数据可视化——R语言ggplot2包绘制精美的小提琴图(并箱线图或误差条图组合) 数据可视化——R语言ggplot2包绘制精美的小提琴图(并箱线图或误差条图组合) 概述:R语言使用ggplot2工具包绘制小提琴图,为了使数据表达更加丰富,同时将小提琴图与箱线图和误差条图相结合。另外,当每个组别有两个属性变量时,分半的小提琴图可节省绘图空间,同时更美观。为了突出小提琴图表达数据的优越性,常规的条形图结合误差条图也被绘制。 小提琴图(Violin Plot)用于显示数据分布及其概率... 阅读详情

相关推荐

ggplot扩展包--gghalves

gghalves包 描述 这里主要介绍这个包中的geom_half_violin()函数,它相当于geom_violin()函数的变体,因为这个函数主要作用就是展示一半的小提琴图,然后与其他图形组合。 实用 geom_half_violin(mapping = NULL, data = NULL, stat = "half_ydensity", position = "dodge", ..., side = "l", nudge = 0, draw_quantiles = NULL, trim =

bioprogrammer 3535

R语言可视化小提琴图(violin plot)、使用vioplot包的vioplot函数可视化分组分离的小提琴图(split a violin plot)

R语言可视化小提琴图(violin plot)、使用vioplot包的vioplot函数可视化分组分离的小提琴图(split a violin plot)

statistics+insight+vista+power 1170

R语言可视化小提琴图(violin plot)、使用vioplot包的vioplot函数可视化分组分离的水平小提琴图(split a horizontal violin plot)

R语言可视化小提琴图(violin plot)、使用vioplot包的vioplot函数可视化分组分离的水平小提琴图(split a horizontal violin plot)

statistics+insight+vista+power 361

9、数据可视化:半小提琴图与山脊图

本文介绍了两种高效的数据可视化方法:半小提琴图和山脊图。半小提琴图通过简化图形结构并与其他图形组合,能够在有限空间中传达更多信息,适用于数据分组对比和信息整合。山脊图则通过叠加密度图展示多组数据分布差异,突出趋势变化,适用于多组观测值的比较。文章分别使用R语言和Python实现图形绘制,并探讨了应用场景及常见问题的解决方法。

bert9linguist的博客 154

R语言可视化小提琴图(violin plot)、使用vioplot包的vioplot函数可视化分组分离的小提琴图(split a violin plot)、使用legend参数自定义图例文本标签内容

R语言可视化小提琴图(violin plot)、使用vioplot包的vioplot函数可视化分组分离的小提琴图(split a violin plot)、使用legend参数自定义图例文本标签内容

statistics+insight+vista+power 1073

R语言可视化小提琴图(violin plot)、使用vioplot包的vioplot函数可视化分组分离的小提琴图(split a violin plot)、使用cex参数自定义图例框的大小

R语言可视化小提琴图(violin plot)、使用vioplot包的vioplot函数可视化分组分离的小提琴图(split a violin plot)、使用cex参数自定义图例框的大小

statistics+insight+vista+power 403

R语言可视化小提琴图(violin plot)、使用vioplot包的vioplot函数可视化分组分离的小提琴图(split a violin plot)、使用fill参数自定义图例标签的颜色与可视化

R语言可视化小提琴图(violin plot)、使用vioplot包的vioplot函数可视化分组分离的小提琴图(split a violin plot)、使用fill参数自定义图例标签的颜色与可视化图像一致

statistics+insight+vista+power 199

科研绘图系列:R语言分割小提琴图(Split-violin)

科研绘图系列:R语言分割小提琴图(Split-violin)

专注生信领域 1467

R语言plotly可视化:plotly可视化分裂的分组小提琴图、每个小提琴图内部分为两组数据、每个分组占小提琴图的一半、自定义设置小提琴图的调色板、抖动数据点jitter

R语言plotly可视化:plotly可视化分裂的分组小提琴图、每个小提琴图内部分为两组数据、每个分组占小提琴图的一半、自定义设置小提琴图的调色板、抖动数据点jitter

data+scenario+science+insight 436

R语言绘制小提琴图geom_violin,如何添加额外的点geom_point?geom_violin + geom_boxplot + geom_point组合使用

下面展示的是Yeo 7网络的梯度分布,并添加额外的点(红色三角形)的小提琴图,先看一下效果图 第一步:先加载R语言包 rm(list = ls()) library(magrittr) library(tidyverse) library(dplyr) library(ggplot2) library(ggridges) 第二步:加载数据 #加载数据 network_mean_gradient <- read.csv('E:\\R_Code\\plot_heat_map\\data\\networ

从事脑科学核磁共振方法学研究,在Nature communications等权威期刊发表研究论文,熟练掌握磁共振处理方法和统计学方法,欢迎大家和我交流。 1901

R语言作图:小提琴图

它结合了箱线图和核密度估计图的特点,能够展示数据的分布形态、中位数、四分位数、极值等统计信息,同时也展示了数据的密度估计,帮助我们更好地理解数据的分布情况。小提琴图的优点在于它能够同时展示多个分组的数据分布情况,并提供了更多的统计信息。运行以上代码,我们将得到一个展示了三个分组数据分布的小提琴图。图中的每个小提琴表示一个分组,其形状展示了该分组数据的分布情况。小提琴的宽度可以表示数据在该位置的密度,较宽的部分表示密度较高的区域。总结起来,小提琴图是一种强大的数据可视化工具,适用于展示定量数据的分布情况。

ByteNinja的博客 1241

不同分组的半边小提琴图比较:使用R语言设置split参数

使用R语言中的ggplot2包可以轻松创建半边小提琴图来比较不同分组的数据分布。通过设置split参数,我们可以将数据按照分组进行分割,并在同一图中进行比较。在上述代码中,data参数指定了要使用的数据框,aes函数用于设置x和y轴的变量。首先,我们需要准备包含要比较的数据的数据框。在上述代码中,fill参数设置了填充颜色为浅蓝色,color参数设置了轮廓颜色为深蓝色,alpha参数设置了透明度为0.5。在创建半边小提琴图之前,我们需要安装并加载ggplot2包,这是一个用于数据可视化的强大工具。

DevGlider的博客 486

小白学习微信小程序的图像识别和文字识别技术

其中,type参数指定了识别的类型,imageUrl参数指定了图片的地址,success回调函数用于处理识别成功的结果,fail回调函数用于处理识别失败的情况。其中,type参数指定了识别的类型,imageUrl参数指定了图片的地址,success回调函数用于处理识别成功的结果,fail回调函数用于处理识别失败的情况。下面,我们来实现一个文字识别的应用案例,可以识别一张图片中的文字,并将识别结果显示到小程序的页面上。在小程序中,也可以使用微信提供的文字识别接口,实现文字识别的功能开发。

qq_67153941的博客 1649

FPGA DMA IP核使用指南

数据传输:支持从源地址到目标地址的数据传输。中断管理:提供中断信号,便于CPU处理传输完成事件。传输控制:支持传输大小、方向和暂停/恢复控制。

weixin_66634995的博客 2433

无线网卡选购指南:哪些型号支持Kali Linux的监听模式?附免驱动网卡推荐

本文详细解析了如何在Kali Linux下选购支持监听模式的无线网卡。核心在于选择兼容的芯片组,如Atheros AR9271和Ralink RT3070等经典型号,并提供了免驱动网卡推荐与实战配置指南,帮助安全研究人员和爱好者快速搭建无线测试环境。

wind6的博客 1587

【KBrowser】基于 Kiwi/chromium 制作全新外壳,将 chromium 代码当作 webview 使用,实现可控核替换

chromium 其实只需几步巧妙的架构,就能拿来“换核”,甚至可以插件化,实现类似webview.apk 的效果。重新设计界面,不再是差不多的回声。而 Kiwi 基于 chrome 77 ,只有 50 MB。优势是兼容好、可安装扩展。

sinat_27171121的博客 2039

Windows音效增强设置详解:从系统开关到专业EQ调音

声音信号在Windows系统中需要经过混音器、声卡驱动与APO效果器等多层处理链路,最终才到达耳机或音箱。系统自带的响度均衡、低音增强、虚拟环绕等音频增强选项,本质上是对动态范围和频响的干预,理解其原理才能避免盲目开启导致声音发闷或失真。空间音效与采样率的正确配置,可减少SRC重采样带来的音质损失,而Win11的音频增强开关和通信设置也常被忽视。无论是板载声卡还是USB解码耳放,合理利用系统增强和Equalizer APO等工具,都能显著改善听感体验。本文结合场景给出设置建议,帮助用户告别声音浑浊,获得干净

weixin_31155097的博客 458

基于ESP32-C3的便携式血氧仪硬件与算法实现

血氧饱和度(SpO₂)监测是生理参数无创检测的核心技术之一,其原理基于光电容积脉搏波(PPG)信号中红光与红外光吸收比值的动态变化。该技术依赖高精度模拟前端、稳定光学激励及实时数字信号处理能力,在消费级健康设备中面临功耗、体积与测量鲁棒性的多重约束。ESP32-C3凭借集成LEDC、12位ADC与低功耗双核架构,成为PPG终端的理想主控平台;结合定制化指夹式光学探头与比率法血氧算法,可实现非诊断级但趋势可靠的日常健康监测。本文围绕硬件电路设计、电源管理策略与嵌入式信号处理流程展开,覆盖从LED驱动、跨阻放大

weixin_29025501的博客 137

K8s(二十一):在 Kubernetes 集群中部署 MySQL8.0 高可用集群(1主2从)

🔴 K8s(二十一):在 Kubernetes 集群中部署 MySQL8.0 高可用集群(1主2从)

✨ 欢迎来到【Seal ^_^ 的CSDN博客】!✨ 3万+

ESP32与DS18B20温度传感器的数据采集与告警系统

并且,通过自定义的微信告警功能,我们可以及时收到温度超过阈值的告警消息。随着物联网的快速发展,传感器在各种应用场景中发挥着重要的作用。本文将介绍如何使用ESP32微控制器与DS18B20温度传感器结合,通过串口输出和Web服务器实现温度数据的采集和监控,并使用自定义微信告警功能。上传完成后,打开串口监视器,您将看到ESP32连接到Wi-Fi网络,并开始监测温度。在您的计算机或移动设备上,打开一个Web浏览器,并输入ESP32的IP地址。在浏览器中输入ESP32的IP地址后,您将看到显示当前温度的页面。

loop_class349的博客 2257

vb 6.0并口开发操作实例

vb6并口开发,简体中文,试例内有inpout32.dll动态链接库

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

上一篇: R语言作图——Violin plot with dot (小提琴图+点图)
下一篇: R语言作图——Slope chart(坡度图)
生信了(公众号同名)
博客等级 码龄8年 1857粉丝 105原创
评论 7
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值