NatureCommunications|国沿海泥滩潮间带病毒组的生物多样性研究 (四)

图1 | 滩涂潮间带沉积物中病毒和微生物的概述。
c 潮间带沉积物中溶菌性和溶原性病毒的相对比例。箱线图显示了不同生活方式病毒的相对比例差异。箱线图中的点代表每个采样区域八个样本的平均值。箱体的中线表示12个采样区域的中位值。箱体的上下边界代表四分位范围,其中下边界对应第一个四分位数,上边界对应第三个四分位数。须线表示在第一个和第三个四分位数范围的1.5倍内的最低和最高值。差异的统计显著性使用双尾t检验确定。
以下是作图代码:

# Load necessary libraries
library(geojsonsf)     # For handling GeoJSON data
library(sf)            # For simple feature support for vector data
library(ggplot2)       # For creating plots
library(RColorBrewer)  # For color palettes
library(ggspatial)     # For spatial data visualization
library(cowplot)       # For combining plots
library(tidyverse)     # For data manipulation and visualization
library(scales)        # For scaling functions
library(ggsci)         # For scientific journal and sci-fi themed color palettes
library(ggforce)       # For additional ggplot2 functionality
library(reshape2)      # For data reshaping
library(dplyr)         # For data manipulation
library(readxl)        # For reading Excel files
library(ggpubr)        # For publication-ready plots
library(vegan)         # For ecological data analysis
library(ggpmisc)       # For adding mathematical annotations to ggplot2

# Read data from an Excel file
data <- read_excel("./raw_data_for_figure1/Fig.1c.xlsx")

# Set the factor levels for the 'letter' column
data$letter = factor(data$letter, levels = c("Lytic", "Lysogenic"))

# Create a violin plot with boxplot and jittered points
ggplot(data, aes(x = letter, y = ratio)) +
  geom_violin(aes(fill = letter), trim = FALSE, width = 0.32, alpha = 0.9, size = 0.15) +  # Violin plot
  geom_boxplot(width = 0.18, size = 0.15) +  # Boxplot
  labs(x = "", y = "Relative proportion (%)") +  # Axis labels
  geom_jitter(aes(x = letter, y = ratio, fill = letter), shape = 21, stroke = 0.15, size = 0.65, 
              position = position_jitterdodge(jitter.width = 0.4), alpha = 0.8) +  # Jittered points
  scale_fill_manual(values = c("#7AC5CD", "#FF9B64")) +  # Custom fill colors
  theme(axis.line = element_line(color = "black")) +  # Axis line color
  theme_test() +  # Apply test theme
  theme(panel.grid.major = element_blank(),  # Remove major grid lines
        panel.grid.minor = element_blank(),  # Remove minor grid lines
        axis.title = element_text(size = 6.5),  # Axis title text size
        axis.ticks = element_line(size = 0.3),  # Axis ticks line size
        axis.ticks.length = unit(0.04, "cm"),  # Axis ticks length
        axis.text.x = element_text(hjust = 0.5, size = 6, color = 'black'),  # X-axis text properties
        axis.text.y = element_text(size = 6, color = 'black'),  # Y-axis text properties
        panel.border = element_rect(size = 0.35)) +  # Panel border size
  ylim(0, 100) +  # Y-axis limits
  theme(legend.position = "none")  # Remove legend

作图结果:


image.png

看没看懂都点个赞呗~

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容