論文
Structure and function of the soil microbiome underlying N2O emissions from global wetlands
https://www.nature.com/articles/s41467-022-29161-3#Sec21
沒有找到論文的代碼,但是論文的數(shù)據(jù)是公開的,可以用論文中的數(shù)據(jù)復(fù)現(xiàn)一下論文中的結(jié)果,今天的推文試著復(fù)現(xiàn)一下論文中的figure1a
世界地圖的數(shù)據(jù)
ggplot2自帶了一份地圖數(shù)據(jù),可以直接使用,這里需要注意的是我們畫的是沒有國家邊界的世界地圖,如果是帶有國家邊界的地圖,使用數(shù)據(jù)的時候需要小心。
ggplot2畫地圖
library(ggplot2)
world<-map_data("world")
ggplot() +
geom_polygon(data=world,aes(x=long,y=lat,group=group),
fill="#dedede")+
theme_bw()+
scale_y_continuous(expand = expansion(mult=c(0,0)))+
scale_x_continuous(expand = expansion(add=c(0,0))) -> world.map
world.map

image.png
采樣地點(diǎn)部分?jǐn)?shù)據(jù)

image.png
讀取數(shù)據(jù)
library(readxl)
dat01<-read_excel("data/20220603/NC/41467_2022_29161_MOESM12_ESM.xlsx",
sheet = "Fig.1a")
head(dat01)
給數(shù)據(jù)集增加新的一列
dat01 %>%
mutate(n2o=case_when(
N2O<10 ~ "-2..10",
N2O >= 10 & N2O < 100 ~ "10..100",
N2O >= 100 ~ "100..500"
)) -> new.dat01
作圖代碼
library(ggstar)
world.map +
geom_star(data=dat01,
aes(x=Longitude,y=Latitude,
starshape=Land_use,
color=`AamoA/nir`,
fill=`AamoA/nir`),
size=4,
position = position_jitter(width = 10,
height = 10,
seed = 1234))+
scale_starshape_manual(values=c(11:15,20,9))+
scale_fill_gradient2(low = "#429eb3",
mid = "#e9c922",
high = "#f22101",
midpoint = 0.5)+
scale_color_gradient2(low = "#429eb3",
mid = "#e9c922",
high = "#f22101",
midpoint = 0.5) -> world.map.01
world.map.01 +
geom_point(data=new.dat01,
aes(x=Longitude,y=Latitude,
shape=n2o),
position = position_jitter(width = 10,
height = 10,
seed = 1234))+
scale_shape_manual(values = c(3,4,8),
name= expression("A^2"))+
theme(#legend.position = c(0.5,0.5),
legend.background = element_rect(fill = "transparent"))+
labs(x="Longitude",y="Latitude")

image.png
這里遇到兩個問題
1 這里有三個圖例,有沒有辦法用代碼調(diào)整每個圖例的位置呢?暫時沒有找到解決辦法
2 圖例的標(biāo)題如何用代碼設(shè)置上下標(biāo)暫時沒有找到解決辦法
這連個問題目前的解決辦法是出圖后編輯圖片
采樣地點(diǎn)數(shù)據(jù)可以到論文中去下載,代碼可以在推文中復(fù)制,如果需要我整理好的代碼可以給推文打賞1元獲取
歡迎大家關(guān)注我的公眾號
小明的數(shù)據(jù)分析筆記本
小明的數(shù)據(jù)分析筆記本 公眾號 主要分享:1、R語言和python做數(shù)據(jù)分析和數(shù)據(jù)可視化的簡單小例子;2、園藝植物相關(guān)轉(zhuǎn)錄組學(xué)、基因組學(xué)、群體遺傳學(xué)文獻(xiàn)閱讀筆記;3、生物信息學(xué)入門學(xué)習(xí)資料及自己的學(xué)習(xí)筆記!